[R] Confused: Inconsistent result?

2012-02-20 Thread Ajay Askoolum
This is copy paste from my session: xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class dim(xyz)-c(length(xyz)/2,2) allobj-function(){ + xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class; + dim(xyz)-c(length(xyz)/2,2); + return(xyz) + } xyz   [,1]  [,2]    [1,] a   

Re: [R] Confused: Inconsistent result?

2012-02-20 Thread David Winsemius
On Feb 20, 2012, at 10:07 AM, Ajay Askoolum wrote: This is copy paste from my session: xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class dim(xyz)-c(length(xyz)/2,2) allobj-function(){ + xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class; + dim(xyz)-c(length(xyz)/2,2); + return(xyz) +

Re: [R] Confused: Inconsistent result?

2012-02-20 Thread R. Michael Weylandt
Sorry, just checked it and you need to add .GlobalEnv to both ls() calls. Michael On Mon, Feb 20, 2012 at 10:17 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Short answer, environments -- ls() looks (by default) in its current environment, which is not the same as the global

Re: [R] Confused: Inconsistent result?

2012-02-20 Thread R. Michael Weylandt
Short answer, environments -- ls() looks (by default) in its current environment, which is not the same as the global environment when being called inside a function. This would (I think) give the same answer but I haven't checked it. : allobj-function(){ +

Re: [R] Confused: Inconsistent result?

2012-02-20 Thread Petr PIKAL
Hi This is copy paste from my session: xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class dim(xyz)-c(length(xyz)/2,2) allobj-function(){ + xyz-as.vector(c(ls(),as.matrix(lapply(ls(),class; + dim(xyz)-c(length(xyz)/2,2); + return(xyz) + } xyz [,1] [,2]