On 02/03/2010 5:42 PM, carol white wrote:
Hi, How to turn a character string into an unevaluated R object? I want to load some files in a directory into data matrix R objects. I could do this with read.table and assign (see below). Then, I want to turn the character string representing a file name (the evaluated expression of i) into an unevaluated R object. Basically, I want to create matrices whose names are the same as the related file names.
I don't understand what you mean by an "unevaluated R object". The code you give below looks as though it would do the rest of what you describe; what goes wrong with it?
Chees, Carol ---------------------------- suppose I have mat1, mat2, mat3 files v = list.files(".", all.files = F, pattern = "mat") for (i in v) assign(i, read.table(i, sep = "\t"), pos = 1)
I would leave off "pos = 1" here, though it should be harmless. It will only make a difference if you execute this code inside a function or other local environment.
Duncan Murdoch
then, I want to have 3 objects with the names mat1, mat2, mat3 containing what mat1, mat2, mat3 files contain. ______________________________________________ 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.
______________________________________________ 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.