r - name columns after using aggregate function -
i used aggregate function range factor level. trying rename columns, output aggregate function not have min , max separate columns.
# example data size_cor <- data.frame(spcode=rep(c(200,400,401),3),length=(c(45,23,56,89,52,85,56,45,78)))   # aggregate function spcode_range <- with(size_cor, aggregate(length, list(spcode), fun = range))   output:
spcode_range     group.1 x.1 x.2 1     200  45  89 2     400  23  52 3     401  56  85   data structure:
str(spcode_range)  'data.frame':   3 obs. of  2 variables:  $ group.1: num  200 400 401  $ x      : num [1:3, 1:2] 45 23 56 89 52 85  dim(spcode_range) [1] 3 2   the output has 3 columns: group.1, x.1 (min) , x.2 (max), dataframe has 2 columns.  have tried setnames, rename , name no success because trying name 3 columns when r has 2 columns.  
 
 
  
Comments
Post a Comment