[R] get() return nothing

David Winsemius dwinsemius at comcast.net
Tue Feb 14 06:06:30 CET 2017


> On Feb 13, 2017, at 8:50 AM, Fix Ace via R-help <r-help at r-project.org> wrote:
> 
> Well, I am not trying to print anything. I just would like to get the dimension information for all the dataframes I created. Could you please help me to develop the script?

You should post R code that builds objects of similar structure as your use case. 
(
At the moment we don't know how these dataframes are assembled (in a list?) or having names with a structure that we need to get() or with an associated character vector with their names that are not R names.)

-- 
David.
> Thanks.
> Ace 
> 
>    On Saturday, February 11, 2017 7:53 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> 
> 
> On 11/02/2017 1:33 PM, Fix Ace via R-help wrote:
>> Hello, there,
>> I wrote a loop to check the dimension of all the .txt dataframes:> ls()
>>   [1] "actualpca.table" "b4galnt2"        "b4galnt2.txt"    "data"
>>   [5] "galnt4"          "galnt4.txt"      "galnt5"          "galnt5.txt"
>>   [9] "galnt6"          "galnt6.txt"      "glyco"          "glyco.txt"
>> [13] "i"              "mtscaled"        "newsig.table"    "nicepca"
>> [17] "pca"            "sig.txt"        "st3gal3"        "st3gal3.txt"
>> [21] "st3gal5"        "st3gal5.txt"    "st6gal1"        "st6gal1.txt"
>>> for(i in ls(pattern="txt")){dim(get(i))}
>>> 
>> If I check individual ones, they are ok:
>>> dim(get("galnt4.txt"))
>> [1] 8 3
>>> 
>> could anyone help me to figure out why it did not work with a loop?
>> Thanks a lot!
> 
> It's the difference between
> 
> for (i in 1:10) i
> 
> (which prints nothing) and
> 
> for (i in 1:10) print(i)
> 
> Duncan Murdoch
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list