William Dunlap wrote >>> eval(parse(text=paste("dataset",IVcat[k],sep="$")))<-relevel(eval(parse(text=paste("dataset",IVcat[k],sep="$"))),ref="online") >>This code returns the following error: >>Error in eval(parse(text = paste("dataset", IVcat[k], sep = "$"))) <- >>relevel(eval(parse(text = paste("dataset", : >> target of assignment expands to non-language object > > Replace > eval(parse(text=paste("dataset", IVcat[k], sep="$"))) > with > dataset[[ IVcat[k] ]] > everywhere.
Thanks so much for the response, Bill - this was very helpful. I feel silly for not thinking of this myself - I had originally started with this approach, but abandoned it because for some inexplicable reason it seemed to call the wrong dataset column (which it did again when I substituted your code for mine). However, I figured out a modification that did work: apparently I needed to convert the output of IVcat[k] to a string, like this, and then the code ran fine: dataset[[ toString(IVcat[k]) ]] Thanks again! -- View this message in context: http://r.789695.n4.nabble.com/equivalent-code-that-doesn-t-return-same-results-tp4655788p4655852.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org 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.