[R] SAS user now converting to R - Help with Transpose
Daniel Malter
daniel at umd.edu
Mon Sep 28 18:16:17 CEST 2009
?reshape
hth,
Daniel
baxterj wrote:
>
> I am just starting to code in R and need some help as I am used to doing
> this in SAS.
>
> I have a dataset that looks like this:
>
> Chemical Well1 Well2 Well3 Well4
> BOD 13.2 14.2 15.5 14.2
> O2 7.8 2.6 3.5 2.4
> TURB 10.2 14.6 18.5 17.3
> and so on with more chemicals....
>
> I would like to transpose my data so that it looks like this:
> Chemical WellID Value
> BOD Well1 13.2
> BOD Well2 14.2
> BOD Well3 15.5
> BOD Well4 14.2
> O2 Well1 7.8
> O2 Well2 2.6
> .... and so on
>
> In sas I would code it like this:
> proc sort data=ds1; by chemical; run;
> Proc Transpose data=ds1 out=ds2;
> by chemical;
> var Well1 Well2 Well3 Well4;
> run;
> data ds3; set ds2;
> rename _name_ = WellID;
> rename col1 = value;
> run;
>
> How can I do this in R?? Any help is much appreciated. Thanks!
>
--
View this message in context: http://www.nabble.com/SAS-user-now-converting-to-R---Help-with-Transpose-tp25645393p25647137.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list