Questions tagged [geom-bar]

`geom_bar` is the geometric object description for creating a barplot in `ggplot2`

geom_bar is the geometric object description for creating a barplot in ggplot2, which is an actively maintained open-source chart-drawing library for R. is written by Hadley Wickham and based upon the principles of "Grammar of Graphics".

Resources for using geom_bar:

1029 questions
-1
votes
1 answer

how to make a filter that counts values in a column

I am working with taxonomic data, and want to filter my data in order to make a more precise graph. I am working with Family level data, and need to make a code that filters for all Families that appear more than 100 times in the data. I want this…
Emily
  • 1
-1
votes
1 answer

Grouped bar chart in R with 4 bars for each group

So basically I am trying to figure out how to make a bar chart look like this in ggplot2 - and failing... and this is my data DF <- structure(list(Location = c("PC_of_recapped_cells", "PC_of_infested_cells", "PC_Recapped_and_Infested",…
Natasha Reece
  • 53
  • 1
  • 5
-1
votes
1 answer

How to change the positions of numbers on the x-axis in geom_bar()

First, sorry for my bad english :( . I have a question to the geom_bar: In my plot, the numbers are in the middle of a bar. For example, there appears to be nearly 50'0000 trees (Bäume) with IBaum = 5, but in realitythere are nearly 50'000 trees…
-1
votes
1 answer

How to change count to percentage in geom_bar when combining with other plot (ggplot2)?

I am trying to plot two graphics in one using ggplot2. I have two data frames that share a common variable (factor). They look like this: tb1: study caribbean south.america alison_2010 1 0 james_1998 0 1 ... tb2: study …
lemosl
  • 5
  • 4
-1
votes
1 answer

r - reordering of barplot with ggplot2

Looking for how to reorder bars in ggplot2::geom_bar and none of the already posted answers helped solve the issue. A reproducible example: # sample dataframe cf <- data.frame(a = rnorm(1000, mean = 50, sd = 50)) # just creating additional…
adl
  • 1,390
  • 16
  • 36
-1
votes
1 answer

Specifying color for geom bars in ggplot2

My data frame is as follows School Gender Value ColorGroup 1 School1 Male 10 1Male 2 School1 Female 30 1Female 3 School2 Male 40 1Male 4 School2 Female 70 1Female 5 School3 Male 5 2Male 6 School3 Female …
Vik G
  • 539
  • 3
  • 8
  • 22
-1
votes
4 answers

Creating Stacked Bar Chart With one Variable for each Bar, using melt, and ggplot

This question is raising different points as the one I posted yesterday, with a better description, so I hope for your understanding. I have the following Data: Data <- data.frame(LMX = c(1.92, 2.33, 3.52, 5.34, 6.07, 4.23, 3.45, 5.64), Thriving =…
Andreas G.
  • 190
  • 11
-1
votes
1 answer

How to make a sorted geom_bar() ggplot

My dataframe is called: d3with variable names : course_name,id,total_enrolled,total_capacity I did: d3a <- head(d3[order(d3$total_capacity, decreasing = T),], 15) d3.plottable <- d3a[, c(1,3,4)] d3.plottable <- melt(d3.plottable, id.vars =…
Iniciador
  • 93
  • 2
  • 8
-1
votes
1 answer

Bar chart offset and layer overlays

Hello all R enthusiasts I have a problem with doing a bar graph that should look like this: I do not have 10 reputation points so I have to use a link (four bars in one category) http://matma4u.pl/uploads/imgs/pre_1499074482__wyk2.jpg Generally I…
Jarekzulus
  • 13
  • 4
-1
votes
1 answer

Using guide_legend with geom_bar in ggplot

Is there anyway of making geom_legend work with geom_bar? I want to have too lines in my legend. It works for geom_line but not for geom_bar charts. It works fine when I used it here: ggplot(diamonds, aes(x,y)) + geom_point(aes(colour = z))+ …
-1
votes
1 answer

Add second y-axis without corresponding x-data

I'm making a graphical analysis of the course evaluations. I got the following data: > str(dataJ2) 'data.frame': 16 obs. of 22 variables: ... $ lk_nummer : Factor w/ 111 levels "051-0311-00S",..: 19 30 38 47 49 50 51 55 56 59 ... $…
Mat D.
  • 453
  • 6
  • 15
-1
votes
1 answer

Label error in geom_bar

I'm trying put label in geom_bar but I can't. My code df <- data.frame( uni = rep(c("D","E","F","G","H"),3), Var1 = factor(c(rep("A",5),rep("B",5),rep("C",5))), Freq =…
shasj
  • 85
  • 1
  • 6
-1
votes
1 answer

Cannot make stacked barplot in ggplot2

I am trying to make a stacked bar plot in ggplot2 but I am not getting it right. Here is the code for making barplot. ggplot(chr_all_m, aes(chr, value, fill=factor(Genome))) + stat_summary(fun.y = "mean", geom="bar",…
upendra
  • 2,141
  • 9
  • 39
  • 64
-2
votes
1 answer

geom_bar, how to only make the x highest frequency appear?

I'm working with a dataframe on state-sponsored cyberattacks (my main three variable are thus Date, Sponsor and Victim). I want to create a geom_bar where for each year, the top five victims of cyber attacks will appear. I'm not sure how I could…
Nea
  • 11
  • 3
-2
votes
2 answers

geom_text making label appear on plot doesn't work

I am trying to make the values of the column "activité en valeur" of my dataframe appear above my bars in geom_bar, yet it doesn't work as i get the following message of error "Aesthetics must be either length 1 or the same as the data (11): label".…
1 2 3
68
69