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
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 ... > > JohI 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
On Monday 19 February 2007 17:49, jim holtman wrote:> have you tried 'unlist(strsplit(....))'? The 'unlist' will probably give > you more values than you have rows, so it would be good if you could > explain what it is you are trying to do.I want to isolate a data frame containing all rows of 'dataframe' which contain a member of 'list' in the field 'Field', which itself is a comma separated list of entries. Better this (know in brain ...)? Joh> On 2/19/07, Johannes Graumann <johannes_graumann at web.de> 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 > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code.-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 827 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070219/3d05a24c/attachment.bin