On 2012-02-23 11:08, Niek de Klein wrote:
Hi everyone,

I have a matrix with multiple columns like this:

charge  convexhull_xCoor             id
3       3336.43               f_7936733956214261295
3       3339.73               f_7936733956214261295
3       3336.43               f_7936733956214261295
2       3797.14               f_2444900193131259878
2       3799.41               f_2444900193131259878
2       3800.93               f_2444900193131259878


I want to get only one row per uniq id, removing the rest of the rows (it doesn't matter which of the rows with the uniq id is kept). In R this is equal to:

> csv <- read.csv('/homes/ndeklein/infiles/feature.csv', head=TRUE, sep='\t')
> csvUniq <- subset(csv, !duplicated(csv$id))

So using rpy2 this would be

csvData = R.r['read.csv'](file=inputFolder+'feature.csv', head=True, sep='\t') csvUniqID = R.r['subset'](csvData, R.r['duplicated'](csvData[R_funct.index(csvData, 'id')]))

Except that I don't have !duplicated but duplicated. R.r['!duplicated'] is not recognized and doing

It is not recognised because there no symbol "!duplicated". R.r.__getitem__() is fetching objects associated with symbols, it is not evaluating R code.
rnot = R.r['!']
duplicated = R.r['duplicated']

rnot(duplicated(foo)) is now equivalent to "!duplicated(foo)"




csvUniqID = R.r['subset'](csvData, not R.r['duplicated'](csvData[R_funct.index(csvData, 'id')]))

Also doesn't work (it seems to ignore the not). So how do I get the ! infront of duplicated?

Thanks,
Niek


------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/


_______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to