Skip to content

Plot rows of CSV

5 messages · Joshua Wiley, rmje, jim holtman

#
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.
#
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:

  
    
1 day later
#
Because your header contains strings that are not legal names.  Check out the parameter check.name (cannot tell for sure since R is not available on the iPad).

Sent from my iPad
On May 29, 2011, at 5:17, rmje <robinmjelle at gmail.com> wrote:

            
1 day later
#
Hi, 
this works: apply(mtcars[c("Mazda RX4", "Merc 450SLC", "Maserati Bora"), ],
1, plot) 


How do you add labels and additional edit in such a plot? For instance I
want 
 mpg cyl  disp  hp drat    wt  qsec vs am gear carb to be plottet below the
X-axis

--
View this message in context: http://r.789695.n4.nabble.com/Plot-rows-of-CSV-tp3555898p3560654.html
Sent from the R help mailing list archive at Nabble.com.