Re: [R] Conditional Loop For Data Frame Columns

2012-01-09 Thread Rui Barradas
Hello, I believe that the following solves it: aggregate(SD[, 3:ncol(SD)], by=list(ID), mean) aggregate(SD[, 3:ncol(SD)], by=list(ID), mean, na.rm=TRUE) It's the second you want, it will compute the means for groups that aren't only NA and return NaN for groups with all values NA. Rui Barradas

Re: [R] Conditional Loop For Data Frame Columns

2012-01-09 Thread Rui Barradas
P.S. If you want to use your function, revised, it may be a good idea: it's faster #write indexed mean function meanfun - function(x, inx, na.rm=FALSE) { meanSD - matrix(0, nrow=length(levels(inx)), ncol=length(3:ncol(x))) for(i in 3:ncol(x)) { meanSD[, i - 2] -

[R] Conditional Loop For Data Frame Columns

2012-01-08 Thread jawbonemurphy
Hi, I am trying to create a script that will evaluate each column of a data frame, regardless of # columns, using some function and sorting the results by an index vector: #upload data (112 rows x 73 columns) SD - read.csv(/Users/johnjacob/Desktop/StudentsData_RInput.csv, header=TRUE) #assign

Re: [R] Conditional Loop For Data Frame Columns

2012-01-08 Thread David Winsemius
On Jan 8, 2012, at 4:48 PM, jawbonemurphy wrote: Hi, I am trying to create a script that will evaluate each column of a data frame, regardless of # columns, using some function and sorting the results by an index vector: ?lapply ?[ ?order #upload data (112 rows x 73 columns) SD -

Re: [R] Conditional Loop For Data Frame Columns

2012-01-08 Thread jawbonemurphy
Hi Dave, Thanks for your response! I'm new at R, and I'm afraid I'm not sure what you mean by: ?lapply ?[ ?order Were these suggestions for other commands to try? If so, can you be more specific? I apologize for being clueless :) Secondly, you're right that the script I have now leaves me

Re: [R] Conditional Loop For Data Frame Columns

2012-01-08 Thread David Winsemius
On Jan 9, 2012, at 12:02 AM, jawbonemurphy wrote: Hi Dave, Thanks for your response! I'm new at R, and I'm afraid I'm not sure what you mean by: ?lapply ?[ ?order It means I thought you might get the answers you needed by looking at those functions' help pages. Were these

[R] conditional loop

2008-09-30 Thread PDXRugger
I am looking up a number based upon a randomly selected number and then proceed to the rest of my code if the corresponding value is greater than or equal to yet another value. so if Dev_Size = 14 and my randomly selected number is 102 and i am looking up 102 in the following table 100

Re: [R] conditional loop

2008-09-30 Thread jim holtman
It looks like you are test against TAZDetermine before it is defined. Try something like this: while(TRUE){ ...generate random number if (value Dev_size) break } On Tue, Sep 30, 2008 at 6:56 PM, PDXRugger [EMAIL PROTECTED] wrote: I am looking up a number based upon a randomly selected