0

I need to create a column ("rt") that sums up 50 selected columns in each row of a dataframe ("data"). I already have a vector named "rtvecnum" which contains the 50 columns' numbers needed to be summed.

  • the first row of the dataframe is irrelevent for that purpose.

The first error referred to X not being numeric, hence the "as.numeric"... but then i got the second error of:

"error in evaluating the argument 'x' in selecting a method for function 'rowSums': 'list' object cannot be coerced to type 'double'".

This is where I got stuck.

I would appreciate your help guys...

data$rt <- rowSums(as.numeric(data[2:nrow(data), c(rtvecnum)], na.rm=TRUE))
Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
ChenG
  • 19
  • 3

0 Answers0