[R] Subset a data frame for plotting

jim holtman jholtman at gmail.com
Fri Apr 10 03:32:22 CEST 2009


I am not sure what you are trying to assign a value to '200706183<-';
does not look like a valid object name.  This should work:

x200706183<-subset(AllData, ID == 200706183)

Notice the use of the '==' for the logical compare.

On Thu, Apr 9, 2009 at 8:58 PM, Paul Warren Simonin
<Paul.Simonin at uvm.edu> wrote:
> Hello,
>
>  I have a question regarding how to subset/select parts of a data frame
> (matrix) in order to plot data associated only with this subset.
> Specifically I have a large data frame in which one column contains ID
> values (dates), and other columns contain data I would like to plot
> (temperature, light, etc.). I would like to break up this large matrix so as
> to plot data associated with specific ID values (dates) separately. I have
> learned of several commands that supposedly subset matrices in this manner
> and have tried the following code with no success:
>
> 200706183<-subset(AllData, ID = 200706183)
> 200706183<-gx.subset(AllData, ID == 200706183)
> 200706183<-subset(x=AllData, AllData$ID = 200706183)
> 200706183<-gx.subset(x=AllData, AllData$ID == 200706183)
>
> In using this code my plan was to create smaller data frame objects which I
> could then plot. My first question, though, is whether this is the correct
> approach. Is there a more efficient way I can create plots conditional on
> certain criteria such as "code = 200706183" ?
>  If I do need to first create separate smaller data frames, how do I go
> about doing this? Am I missing something in the above commands?
>  Any other advice is certainly welcome too, as I admit to being a bit new to
> R. Thank you very much for any answers, tips, suggestions, etc.!
>
> Best wishes,
> Paul Simonin
>
> --
> Paul W. Simonin
> Graduate Research Assistant, MS Program
> Vermont Cooperative Fish and Wildlife Research Unit
> The Rubenstein School of Environment and Natural Resources
> University of Vermont
> 81 Carrigan Dr.
> Burlington, VT 05405
> Ph:802-656-3153
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list