I was wondering is there any parameter setting when I do the aggregates as below , the result will show the origin column names instead the generic "group.1"
data1 <- aggregate(mtcars[1:4], list(mtcars$am, mtcars$gear),mean)
data1
Group.1 Group.2 mpg cyl disp hp
1 0 3 16.10667 7.466667 326.3000 176.1333
2 0 4 21.05000 5.000000 155.6750 100.7500
3 1 4 26.27500 4.500000 106.6875 83.8750
4 1 5 21.38000 6.000000 202.4800 195.6000
Thank you so much,
by the way , I know the function names(x) in reshape.
You can try the formula method
Or rename within the list
If there are many names, then use
setNames
If you decide to use
dplyr/data.table/sqldf
the equivalent codes areUsing
data.table
Using
sqldf