[R] Subsetting across a frame for plotting

Liaw, Andy andy_liaw at merck.com
Wed Jun 22 14:13:31 CEST 2005


You might save yourself some headaches by turning it into a matrix instead,
since all the columns are either integer or numeric:

tonedata <- data.matrix(tonedata)

Data frames are really lists, so even when you get a one-row subset, it's
still a one-row data frame.  You can use unlist() to turn that into a
vector.

Andy

> From: Morten Sickel
> 
> I have a huge frame holding holding model results for a number of
> locations and time series:
> 
> > str(tonedata)
> `data.frame':   434 obs. of  339 variables:
>  $ VALUE   : int  101 104 105 106 111 118 119 121 122 123 ...
>  $ COUNT   : int  2443 184 1539 1016 132 1208 1580 654 864 560 ...
>  $ AREA    : num  6.11e+08 4.60e+07 3.85e+08 2.54e+08 3.30e+07 ...
>  $ D1_1958 : num  470 446 452 457 407 ...
>  $ D2_1958 : num  480 455 461 467 416 ...
>  $ D3_1958 : num  493 469 475 480 429 ...
>  $ D4_1958 : num  542 517 522 526 475 ...
>  $ D5_1958 : num  585 560 565 568 517 ...
> 
> I would like to be able to take all values, except the three first
> (value, count, area) and be able to plot them. I have managed 
> to make a
> subset that looks like what I want, by doing tonedata[11,4:339], but
> that data set is not a vector that can be plottet, it is 
> treated like a
> set of single values. I tried to use as.vector on the set, bot to no
> help. I am probably overlooking somehing quite simple, (not to mention
> not really understanding R's data model..) so help would be 
> appreciated.
> 
> -- 
> Morten Sickel
> Norwegian Radiation Protection Authority
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>




More information about the R-help mailing list