Reply To: Pre-processing self-paced reading data in R

PennController for IBEX Forums Support Pre-processing self-paced reading data in R Reply To: Pre-processing self-paced reading data in R

#7186
Jeremy
Keymaster

Hi Ana,

There is no one-size-fits-all answer to your question. What pcibex.read does is find the rows with the most columns and use those for the whole table

It’s pretty easy to subset a data frame in R and delete a column, then rename the remaining ones:

df <- data.frame(colInts=c(1,2,3),colLetters=c(NA,NA,NA),colExtra=c('a','b','c'),colBools=c(T,F,T),colRats=c(1/1,1/2,1/3))
cols <- names(df)
df[,2] <- NULL
cols <- cols[c(seq(1,2),seq(4,5))]
names(df) <- cols

The value of df after the first line:

  colInts colLetters colExtra colBools   colRats
1       1         NA        a     TRUE 1.0000000
2       2         NA        b    FALSE 0.5000000
3       3         NA        c     TRUE 0.3333333

The value of df after the last line:

  colInts colLetters  colBools   colRats
1       1          a      TRUE 1.0000000
2       2          b     FALSE 0.5000000
3       3          c      TRUE 0.3333333

Jeremy