Re: [R] is get() really what I want here?

2010-10-20 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 20.10.2010 07:58:29: Hi Josh, What I'm really trying to do is to refer to objects whose names I have stored in a vector. This example was arbitrary. I do a lot of looping through files in the working directory, or through objects in the namespace,

Re: [R] is get() really what I want here?

2010-10-20 Thread Joshua Wiley
On Tue, Oct 19, 2010 at 10:58 PM, Daniel Weitzenfeld dweitzenf...@gmail.com wrote: Hi Josh, What I'm really trying to do is to refer to objects whose names I have stored in a vector.  This example was arbitrary. I do a lot of looping through files in the working directory, or through objects

[R] is get() really what I want here?

2010-10-19 Thread Daniel Weitzenfeld
# Let's say I have 5 objects, object_1, object_2, etc. for (i in 1:5) { assign(paste(object_,i, sep=), i+500) } # Now, for whatever reason, I don't know the names of the objects I've created, but I want to operate on them. list-ls(pattern=^obj) #Is get best? for (l in list) { cat(\n, l,

Re: [R] is get() really what I want here?

2010-10-19 Thread Joshua Wiley
Hi Daniel, get() will work for any object, but cat() may not. cat() should work for arrays, but it will be messy even for relatively small ones. For example, run: cat(Hello, array(1:100, dim = c(10, 10)), sep = ) What are you really trying to do? If you are just trying to figure out what

Re: [R] is get() really what I want here?

2010-10-19 Thread Daniel Weitzenfeld
Hi Josh, What I'm really trying to do is to refer to objects whose names I have stored in a vector. This example was arbitrary. I do a lot of looping through files in the working directory, or through objects in the namespace, and I'm confused about how best to call upon them from within a loop.