Dear list. I cannot manage to select all data.frames, which have no data inside. names <- c("data.fame1", "data.fame2","data.fame4","data.fame4") for (i in names) { ifelse(dim(i)[1]==0, rm(i)) } perhaps anybody could help thank you. -- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20021115/a9e41357/attachment.bin
Try this inside your loop: if (dim(get(i))[1] == 0) rm(list=i) HTH, Andy -----Original Message----- From: Stephan Holl [mailto:sholl at gmx.net] Sent: Friday, November 15, 2002 5:31 PM To: r-help at stat.math.ethz.ch Subject: [R] simple for loop Dear list. I cannot manage to select all data.frames, which have no data inside. names <- c("data.fame1", "data.fame2","data.fame4","data.fame4") for (i in names) { ifelse(dim(i)[1]==0, rm(i)) } perhaps anybody could help thank you. -- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ============================================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
At Fri, 15 Nov 2002 20:34:28 -0500 Liaw, Andy wrote: Hello Andy,> Try this inside your loop: > > if (dim(get(i))[1] == 0) rm(list=i)this works so far, but could you please give my a hint what I did wrong? what does the get() do ? I was struggeling inside some other for loops, and it seems that there was another get() missing. So do I have to use the get() always inside a loop in order to "get" the correct i-values pasted in ? Thank you cheers Stephan -- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20021116/87156014/attachment.bin
"i" just contains a string. What you want is the object with that name, which is what get() gives you. Do read the help page for get(). Andy -----Original Message----- From: Stephan Holl [mailto:sholl at gmx.net] Sent: Saturday, November 16, 2002 2:42 AM To: r-help at stat.math.ethz.ch Cc: Liaw, Andy Subject: Re: [R] simple for loop At Fri, 15 Nov 2002 20:34:28 -0500 Liaw, Andy wrote: Hello Andy,> Try this inside your loop: > > if (dim(get(i))[1] == 0) rm(list=i)this works so far, but could you please give my a hint what I did wrong? what does the get() do ? I was struggeling inside some other for loops, and it seems that there was another get() missing. So do I have to use the get() always inside a loop in order to "get" the correct i-values pasted in ? Thank you cheers Stephan -- Stephan Holl GnuPG Key-ID: 11946A09 ICQ# 117277975 ------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it. ============================================================================= -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._