Hello, I'm very new to R, and have managed to plot xy graphs, but can't seem to plot a matrix properly. The first column is my time points, and the following columns 2-4 are the replicates of my experiment. I've tried using row.names=1 to make the first column the value for that row (whereas before I had 1-31 sequence) and then my 1st column) but I can't work out how to tell it that column 1 of my dataset is the xvalue for the data in that row? It's probably really simple, but I can't seem to figure it out! Many thanks, any help appreciated! Laura -- View this message in context: http://r.789695.n4.nabble.com/Plotting-from-a-matrix-where-column-1-is-your-x-value-tp4653076.html Sent from the R help mailing list archive at Nabble.com.
Rui Barradas
2012-Dec-14 16:55 UTC
[R] Plotting from a matrix, where column 1 is your x value
Hello, There are several ways of doing this, perhaps the easiest is with ?matplot. You should provide some data example, like the posting guide says. Since you haven't, I've made up some. y <- replicate(3, cumsum(rnorm(10))) x <- matrix(c(1:10, y), ncol = 4) matplot(x[, 1], x[, -1], type = "l") Hope this helps, Rui Barradas Em 14-12-2012 11:28, masepot escreveu:> Hello, > > I'm very new to R, and have managed to plot xy graphs, but can't seem to > plot a matrix properly. > > The first column is my time points, and the following columns 2-4 are the > replicates of my experiment. > > I've tried using row.names=1 to make the first column the value for that row > (whereas before I had 1-31 sequence) and then my 1st column) but I can't > work out how to tell it that column 1 of my dataset is the xvalue for the > data in that row? > > It's probably really simple, but I can't seem to figure it out! > > Many thanks, any help appreciated! > > Laura > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting-from-a-matrix-where-column-1-is-your-x-value-tp4653076.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.