[R] formatting data???

David Winsemius dwinsemius at comcast.net
Sun Apr 11 17:37:05 CEST 2010


On Apr 10, 2010, at 8:40 PM, Barb Tomlin wrote:

>
> I am just learning and only know the bare basics of R.
> The data looks like this:
> Year 	Jan	Feb	Mar	Apr	May	Jun	Jul	Aug	Sep	Oct	Nov	Dec
> 1973	2.785	2.723	2.673	2.631	2.68	2.82	3.155	3.316	3.349	3.203	3.037	 
> 2.9451974	2.853	2.777	2.729	2.671	2.76	3.045	3.271	3.496	3.557	3.609	 
> 3.622	3.9861975....
>
> and in a nut-shell, I need it to look like this:
> 1973.1 	2.7851973.2	2.7231973.3	2.631
> etc...

You have not offer a cut-and-paatable example and your specification  
seems a bit vague ...possibly compounded by some HTML formatting  
problems.

I suspect you are trying to go from what in R is called "wide" format  
over to what is called "long" format.

Here are some functions and packages that are possibly useful

?stack
?reshape

package::reshape
package::plyr

Depending on what your ultimate plans are for this data you may also  
find useful functions in the time series and zoo packages.


-- 
David
>
> and I have no idea how to do it without manually changing it, and  
> then reading it, but the file it is significantly bigger then this  
> and I may need to apply it to others, so knowing how to go about it  
> with R would be good.
> Thanks,B 		 	   		
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list