[R] shuffling of data

David Winsemius dwinsemius at comcast.net
Thu Sep 16 19:26:48 CEST 2010


On Sep 16, 2010, at 1:14 PM, fugelpitch wrote:

>
> I have a file that reads like this:

How much R do you know? Are you still at the stage where you need  
basic help reading a file into a session?

>
> Species,Year,Julian_day
> Alnus_glutinosa, 1873, 123
> Sorbus_aucuparia, 1873, 122
> ....(more species...)
> Alnus_glutinosa, 1874, 134
> Sorbus_aucuparia, 1874, 143
> ....(more species and years)
>
> Is there a way to plot this as julian day over years so that each  
> species
> get a different color?


If (as is quite likely) that species variable is (or will be)   
actually a factor, you could use as.numeric(Species) as a vector for  
the color argument.

with(dfname, plot(Julian_day, Year, col=as.numeric(Species)))


> Also is it possible to convert this data into the format:
> Alnus_glutinosa, Sorbus_aucuparia,....(more species)
> 123                 122
> 134                 143
> ...(more years)

?reshape
package::reshape2

(and possibly other tabulating, time-series, and recoding options,  
depending on all those devilish details you have unfortunately omitted.)

>
> Then I could attatch a time series to the data.
> -- 
> View this message in context: http://r.789695.n4.nabble.com/shuffling-of-data-tp2542615p2542615.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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list