Displaying 1 result from an estimated 1 matches for "xfreq2".
Did you mean:
freq2
2005 Feb 26
1
reshape without timevar argument?
...,3), rep('IDb', 5), rep('IDc', 2),
rep('IDd',5)), let=letters[1:5])
#add Freq to each id
xFreqdf <- merge(df, table(df['id']), by.x='id', by.y='Var1')
xFreq <- xFreqdf[,'Freq']
#general way of transforming xFreq into:
xFreq2 <- c(3:1, 5:1, 2:1, 5:1)
#substitute Freq by xFreq2
xFreqdf['Freq'] <- xFreq2
#get final df
xReshape <- reshape(xFreqdf, idvar='id', v.names='let',
timevar='Freq', direction='wide')
The final data.frame doesn't order the c...