Skip to content

simple for loop

2 messages · Liaw, Andy, Stephan Holl

#
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.
#
At Fri, 15 Nov 2002 20:34:28 -0500 Liaw, Andy wrote:
Hello Andy,
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