A QuiRk

September 18, 2010

So I’m working away in R on some analyses for the food safety folks at the BCCDC.  I’ve written a nice little function that takes a data frame and an integer as its arguments and I want to loop through all the data frame / integer combinations.

for (i in integers){

for (frame in dataframes){

do function(frame, i)

}

}

No dice.  I get the error “Error in frame$Variable : $ operator is invalid for atomic vectors”.  Whaaat? Sure enough, looping through the data frames this way somehow causes them to be passed to the function as a set of vectors.  I’m sure I’ll find a way to work around it, but I really don’t understand why it’s happening.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.