Re: [R] Placing a column name in a variable XXXX

2011-08-28 Thread Petr PIKAL
Hi or if Dan prefers data frame (which is also a list) CInew2 <-function(x,alpha){ data.frame(variable = deparse(substitute(x)), mean=mean(x), alpha = alpha) } > CInew2(JOBSTAT, 0.05) variable mean alpha 1 JOBSTAT 0.4567117 0.05 Regards Petr > > In this case you want to use a 'list

Re: [R] Placing a column name in a variable XXXX

2011-08-27 Thread jim holtman
In this case you want to use a 'list' since you want character and numerics returned: > JOBSTAT<-rnorm(10) > > > # new function that does not return 'x' > > CInew <-function(x,alpha){ + list(variable = deparse(substitute(x)), mean=mean(x), alpha = alpha) + } > > CInew(JOBSTAT, 0.05) $variable [1]

Re: [R] Placing a column name in a variable XXXX

2011-08-27 Thread jim holtman
The function is doing exactly what you are telling it to do. You have 'cbind(x, mean(x), alpha)' which is creating a matrix where the first column is all the values in 'x' and the next two are the recycled values of mean and alpha. Is this what you want: > JOBSAT<-rnorm(10) > > CI<-function(x,al

[R] Placing a column name in a variable XXXX

2011-08-27 Thread Dan Abner
Hi everyone, How does one place an object name (in this case a vector name) into another object (while essentially masking the values of the first object? For example: > JOBSAT<-rnorm(40) > > CI<-function(x,alpha){ + result<-cbind(x,mean=mean(x),alpha) + print(result) + } > CI(JOBSAT,.05) I wan