[R] reshape direction=wide

Thomas Lumley tlumley at u.washington.edu
Thu Feb 19 20:06:19 CET 2004


On Thu, 19 Feb 2004, Hanke, Alex wrote:

>
> v.names=c("var1","var2") creates a separate column for each combination of
> variables in v.names and level of variable identified by timevar.
>

yes, but that's not what he actually wants.

He needs to create a new id variable that combines ID and BID first

df$newid<-paste(df$ID,df$BID)


	-thomas

>
>
> I am reshaping a data.frame bids --> reshaped as shown below.
>
> I thought this should be possible with a single invocation of
> reshape, but the only way I came up with is reshaping subsets for each
> keyword and then joining them together. Does anyone have an idea how to
> solve this in a more elegant way? Efficiency is a concern as the datasets
> are very large.
>
> Is there a way to specify multiple v.names?
>
>
>
> Alex Hanke
> Department of Fisheries and Oceans
> St. Andrews Biological Station
> 531 Brandy Cove Road
> St. Andrews, NB
> Canada
> E5B 2L9
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list