Re: [R] R Function to extract columnNames

2013-05-01 Thread arun
HI, I am not sure what is wrong in your side.  I cut and paste the same code and I get this: library(plyr) set.seed(25)  mydf<- data.frame(subid=rep(1:5,each=3),Col=sample(c(0:5,NA),15,replace=TRUE))  retsample <- function(df, Column,size) {  set.seed(1234)  mysel <- ddply(df, .(subid),function(

Re: [R] R Function to extract columnNames

2013-05-01 Thread arun
Hi, If you are using Rstudio, please check this link (http://support.rstudio.org/help/discussions/problems/850-ddply-misbehaving-in-rstudio-and-only-in-rstudio). A.K. - Original Message - From: arun To: R help Cc: David Winsemius Sent: Wednesday, May 1, 2013 9:49 PM Subject: Re: R

Re: [R] R Function to extract columnNames

2013-05-01 Thread arun
Hi ST, You could try this: library(plyr) set.seed(25) mydf<- data.frame(subid=rep(1:5,each=3),Col=sample(c(0:5,NA),15,replace=TRUE)) retsample <- function(df, Column,size) { set.seed(1234) mysel <- ddply(df, .(subid),function(x) summarize(x,missing=sum(is.na(x[[Column]])|x[[Column]]==0))) myids<-

Re: [R] R Function to extract columnNames

2013-04-30 Thread David Winsemius
On Apr 30, 2013, at 6:00 AM, arun wrote: > Hi, > May be this helps: > funcName<- function(df1, x){ > whatCol=df1[[x]] > print("Got it") > print(whatCol) > } > > funcName(df,"ColA") > #[1] "Got it" > #[1] 1 2 3 4 5 > funcName(df,"ColB") > #[1] "Got it" > #[1] A B C D E > #Levels: A B C D E

Re: [R] R Function to extract columnNames

2013-04-30 Thread arun
Hi, May be this helps: funcName<- function(df1, x){  whatCol=df1[[x]]  print("Got it")  print(whatCol)  }   funcName(df,"ColA") #[1] "Got it" #[1] 1 2 3 4 5   funcName(df,"ColB") #[1] "Got it" #[1] A B C D E #Levels: A B C D E A.K. >I am trying to extract the 2nd column from a dataframe using a