Reputation: 55
I have a data frame with one field corresponding to number and the next indicating the group that each entry belong to.
Is there a way to generate a plot based on the "group" info in a single command? (so that all values that belong to, for example, group1 are plotted at the 1st column and group2 at the 2nd column, and so on).
Something like plot(x, group=x$group).
I appreciate your feedback. Noosh
Upvotes: 0
Views: 34
Reputation: 28169
Is this what you're looking for:
library(ggplot2)
df1 <- data.frame(id = 1:5000, group = rep(1:5, 1000), col1 = runif(500))
with(df1, qplot(group, col1, position = 'jitter', colour = factor(group)))
Upvotes: 1