[R] Plot rows of CSV

Joshua Wiley jwiley.psych at gmail.com
Fri May 27 22:59:38 CEST 2011


Hi,

This is not fancy or especially elegant, but....

## so you can see each plot at a time before moving on
par(ask = TRUE)
## apply() the function plot() to each row of the
## rows of mtcars you extracted by name
apply(mtcars[c("Mazda RX4", "Merc 450SLC", "Maserati Bora"), ], 1, plot)

I use as an example the mtcars dataset.  As long as you have your data
in R with row names, something like this should work.  Importantly,
apply() coerces the object it functions on to a matrix, so if you have
character and numeric data, everything will be converted to the
highest level of the hierarchy (see the documentation for ?cbind to
see the hierarchy of data types).

If you need more specific types of plots, be more specific ;)

Cheers,

Josh

On Fri, May 27, 2011 at 10:27 AM, rmje <robinmjelle at gmail.com> wrote:
> http://r.789695.n4.nabble.com/file/n3555898/example.jpg
>
> Hi,
>
> I have a CSV-file (see image) that I would like to plot.
>
> I want to make a plot-function where I only plot one row at the time. I want
> to define which row to plot in the function based on the row-names
> (non-numeric) in column 1 in the CSV-file.
>
> Could you help me out?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Plot-rows-of-CSV-tp3555898p3555898.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list