[R] Another subsetting enigma
Marc Schwartz
marc_schwartz at comcast.net
Mon Feb 19 18:02:57 CET 2007
On Mon, 2007-02-19 at 16:13 +0100, Johannes Graumann wrote:
> Hello again,
>
> I'm trying to do the following:
>
> subset(dataframe,list %in% strsplit(dataframe[[Field]],","))
>
> But This returns always the complete dataframe, since the
> strsplit(dataframe[[Field]],",") is evaluated as one big list for the whole
> data frame rather than one list per row. How can I have this evaluated on a
> per row basis?
>
> After 1.5 h hitting head against wall - begging for insights ...
>
> Joh
I may be misunderstanding your desired end result, but what about:
subset(dataframe,list %in% strsplit(Field, ","))
This way 'Field' is evaluated within the data frame (default behavior
for 'subset') on a row-wise basis, rather than passing the entire
column.
This entire process also presumes that 'Field' has embedded commas,
delimiting component entries. If not, then strsplit() is not required.
HTH,
Marc Schwartz
More information about the R-help
mailing list