[R] reshaping a data frame

Abhishek Pratap abhishek.vit at gmail.com
Mon Jun 10 08:15:48 CEST 2013


Hi Guys

I am trying to cast a data frame but not aggregate the rows for the
same variable.

here is a contrived example.

**input**
temp_df  <- data.frame(names=c('foo','foo','foo'),variable=c('w','w','w'),value=c(34,65,12))
> temp_df
  names variable value
1   foo        w    34
2   foo        w    65
3   foo        w    12


###########
**Want this**
############
names  w
foo         34
foo         65
foo         12


##
**getting this***
##
> cast(temp_df)
Aggregation requires fun.aggregate: length used as default
  names w
1   foo 3


In real dataset  the categorical column 'variable' will have many more
categorical variable.

Thanks!
-Abhi



More information about the R-help mailing list