Friday 15 June 2012

r - convert data.frame to ff -


I have a data. I would like to convert the frame into an FF object, as described as as .ffdf

  df.apr = as.data.frame (df.apr) # data.table data from frame cols = df .apr [1,] Coles = sapply (cols, class) df_apr = as.ffdf (Df.apr, vmode = cols)   

returns an error:

  Error in FF (initdata = initdata, length = length, level = level, ordered = command given: vmode 'numeric' is not applied   

'vmode' logic Without, the following error has been given:

  error ff (initdata = initdata, length = length, level = level, ordered = command Written by:  
  writeable (df.apr,):  

File = 'df_apr.txt', sep = '\ t', row.names = F) df.apr.ff = read.table.ffdf (file = '

But it's time consuming [and clumsy]. Is there a better way?

If you want to know all the potential vmodes which can be used in the FF type on the console.

  is required (FF). Vimplemented   

You will notice that the numerical and character modes are not in these numeracy, they are converted into pairs, then the factor for the characters in your question, in fact you have to specify your vmodes. You can use as.ffdf on your data.frame as long as the characters are coded as a factor. So this will work

  df.apr = as.data.frame (df.apr, stringsfactors = TRUE) df_apr = as.ffdf (df.apr)   

FYI If your data is coming from a flat file, consider using read.table.ffdf or if it is coming from an SQL data source, you can read.dbi.ffdf or read.odbc.ffdf to the ETLUtils package Can use from If it is coming from Hadhop through the hive, you can use read.jdbc.ffdf from the ETLUtils package.

No comments:

Post a Comment