I have several equal-length vectors of numbers, like
alpha <- c(1, 2, 3, 4)
beta <- c(5, 6, 7, 8)
gamma <- c(9, 10, 11, 12)
and I want to put these into a data frame or something with columns labelled alpha, beta, and gamma. Like
alpha | beta | gamma
1 | 5 | 9
2 | 6 | 10
3 | 7 | 11
4 | 8 | 12
which qplot should be able to read and separate out by colour = labels. cbind and rbind result in a matrix which qplot cannot read. And c lines up alpha beta and gamma, without labelling them as separate.
The diamonds data set displays what I’m after with qplot(carat, price, data = diamonds, colour = color) except I want to plot my shared-dimensional data against an index like x=1:4.
In regular R I would do plot(alpha); points(beta); points(gamma).
Sorry for asking such a basic question.
If you want a data.frame, then
data.framewill do that:And this can be passed to the
qplotorggplot.In the case of
qplot, you don’t need to create data.frame. Just calling with the variables is sufficient like this:And updated after the comment.
I’m still not sure what is desired, but this example may help: