r - Use the first Row like Column Name. Data Frame of factors -


i'm using dataframe of factors , need use first row of df column names. problem next when make

>df[1,]  df[1,]  tradestation.trade.list  na.     na..1  na..2 na..3          na..4 1                       # type date/time signal price roll on pips                          na..5                       na..6    na..7 1 shares/ctrts/units - profit/loss net profit - cum net profit % profit         na..8      na..9     na..10 na..11   na..12 1 run-up/drawdown efficiency total eff.  comm. slippage 

if make names(df) <- df[1,] receive number of different factors name, not first row.

how can that??

thank much

pd: have gotten dataframe read.xlx() xlsx library

you need coerce factors characters instead of integer representations

dat <- data.frame(a=factor(letters[1:10]),                   b=factor(letters[11:20]))  out <- setnames(dat[-1,], sapply(dat[1,], as.character))  #    k # 2  b l # 3  c m # 4  d n # 5  e o # 6  f p # 7  g q # 8  h r # 9  s # 10 j t 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -