0

I have an ff object. One of the columns, which is a string variable, has white spaces, and I want to remove these.

I have tried the following:

1). newcol <- gsub("[[:space:]]", "", mydata$mystr)

2). newcol<- as.ffdf(gsub("[[:space:]]", "", mydata$mystr))

I also tried to use the as.character command, such that I said the following before applying the gsub command:

mydata$mystr <- as.character(ff(c(mydata$mystr)))

However, none of these options works. Any suggestions/help would be greatly appreciated.

EDIT: SOLUTION GIVEN MY AKRUN BELOW

skeletonnoire
  • 81
  • 1
  • 1
  • 3
  • 3
    What exactly didn't work? Can you provide `dput(head(mydata$mystr))` or some other *representative* small example of your data? – David Arenburg May 05 '15 at 09:05

1 Answers1

0

May be you can try with ffbase

library(ffbase)
library(ff)
head(ffd$y[])
 #[1] p     l       k     a     i     v  
 #20 Levels:   a   c   c   e   f   h   i     j   k   k   l   l   n 
 #n   o ...   v
ffd$y <- with(ffd, gsub('[[:space:]]', '', y))
head(ffd$y[])
#[1] p l k a i v
#Levels: a c e f h i j k l n o p q t v

data

set.seed(24)
d <- data.frame(x=1:26, y=sample(c(letters, paste(' ', letters, ' ')), 
        26, replace=TRUE), z=Sys.time()+1:26)
ffd <- as.ffdf(d)
akrun
  • 874,273
  • 37
  • 540
  • 662