Hi list, I'm using packaged rpy2 on Debian Squeeze in a python-grass script to perform kriging and, among other things that rpy2 executes smoothly, I need tho change the names of two columns in a dataframe. This edit is necessary because the dataframe coming from previous as.data.frame command receives arbitrary column names.
Picking up some sample code: d = {'value': robjects.IntVector((1,2,3)), 'letter': robjects.StrVector(('x', 'y', 'z'))} dataf = robjects.r['data.frame'](**d) For example, I need to change 'letter' column name into 'code' without modifying its content neither other columns. In R I would have written: names(dataf) = c("value", "code") I tried alternatively: dataf.names = robjects.r.gsub('letter','code',dataf.names) dataf.names = robjects.r.c('value','code') with no success. The error says that dataf.names doesn't support assignment. Also I didn't succeed in handling it as Python object, as the type is RVector. Gsub works when I assing the result to a copy of dataf.names. Any suggestion and link to docs/examples will be appreciated. thanks in advance Anne
signature.asc
Description: Questa รจ una parte del messaggio firmata digitalmente
------------------------------------------------------------------------------
_______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list