简体   繁体   中英

Plotting values of the same column grouped by an ID

I am working with R.

I have a tibble that have many columns, including these two...

Condition  Strength 
  A           0.05
  A           0.3
  A           0.2
  A           0.6
  A           0.2
  B           0.8
  B           0.4
  B           0.7
  B           0.9

I am trying to plot the data like this (then I will add a few more things)...

ggplot(mydata, aes(x = filter(condition == "A" %>% select(Strength)), 
                   y = filter(condition == "B" %>% select(Strength)))) +
  geom_point()

This gives me nothing.

So, what I want is to treat the strength as two different vectors dividing them considering the condition.

Perhaps you want a boxplot?

ggplot(mydata, aes(x = Condition, y = Strength, fill = Condition)) +
  geom_boxplot(show.legend = FALSE)

在此处输入图像描述

See this tutorial for more about ggplot and boxplots. (No affiliation)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM