geom-col

How to have separate columns for duplicate x-axis values in geom_col()?

早过忘川 提交于 2021-01-29 19:54:11
问题 I have a dataframe as below (very simple structure) and I want to draw a column chart to show the amount for each date. The issue is that the date has duplicate entries (e.g., 2020-01-15 ). # A tibble: 5 x 2 date amount <date> <dbl> 1 2020-01-02 4000 2 2020-01-06 2568. 3 2020-01-15 2615. 4 2020-01-15 2565 5 2020-01-16 2640 When I try doing the following it somehow groups the similar dates together and draws a stacked column chart which is NOT what I want. df %>% ggplot(aes(x= factor(date), y

How to use geom_bar() to create two grouped columns in R

左心房为你撑大大i 提交于 2021-01-28 03:30:28
问题 There has got to be an easy way to create one set of grouped bars for aware column and a another set of grouped bars for serious column with the individual bars within each group being the value for the respective regions. Final image should look similar to attached image. Thanks! data I'm working with Image I'm seeking approximately by_region <- country_obs_df %>% group_by(Region) %>% summarize( #region_avg_gdp = GDPperUS, #region_avg_co2 = CO2emi, #region_avg_pop = Population.2008, region

How to use geom_bar() to create two grouped columns in R

人盡茶涼 提交于 2021-01-28 02:13:24
问题 There has got to be an easy way to create one set of grouped bars for aware column and a another set of grouped bars for serious column with the individual bars within each group being the value for the respective regions. Final image should look similar to attached image. Thanks! data I'm working with Image I'm seeking approximately by_region <- country_obs_df %>% group_by(Region) %>% summarize( #region_avg_gdp = GDPperUS, #region_avg_co2 = CO2emi, #region_avg_pop = Population.2008, region

geom_col is assigning the wrong independent variable

左心房为你撑大大i 提交于 2020-06-21 05:30:44
问题 I have a simple two variable data frame with a third variable acting as a factor DF <- data.frame(Depth = c(8.6, 19.6, 42.6, 60.6, 79.4, 101.4, 121.4, 137.6, 163, 180), Rb = c(103, 59, 99, 53, 107, 87, 52, 33, 105, 49), Litho = as.factor(c(1,2,1,2,1,1,2,2,1,2))) I want to create a bar graph of the absolute values so I am using geom_col() . I want to plot Rb as a function of Depth therefore Depth should be the discrete variable. However, when I plot using ggplot (DF, aes(x=Depth, y=Rb))+ geom

Color/fill bars in geom_col based on another variable?

旧巷老猫 提交于 2020-06-17 04:19:46
问题 I have an uncolored geom_col and would like it to display information about another (continuous) variable by displaying different shades of color in the bars. Example Starting with a geom_col library(dplyr) library(ggplot2) set.seed(124) iris[sample(1:150, 50), ] %>% group_by(Species) %>% summarise(n=n()) %>% ggplot(aes(Species, n)) + geom_col() Suppose we want to color the bars according to how low/high mean(Sepal.Width) in each grouping (note: I don't know if there's a way to provide