[R] write.xls dont find the object in function

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Dec 19 16:41:13 CET 2011



On 19.12.2011 13:30, Ronaldo Reis Júnior wrote:
> Em 18-12-2011 18:55, Rolf Turner escreveu:
>> On 19/12/11 04:29, Uwe Ligges wrote:
>>>
>>>
>>> On 18.12.2011 12:58, Ronaldo Reis Júnior wrote:
>>
>> <SNIP>
>>>> Why the write.xls dont find the object a inside a function?
>>>
>>> Because at least that part of the function is poorly written.
>>
>> Surely this should be a fortune!
>>
>> cheers,
>>
>> Rolf
>>
> Hi all,
>
> the problem in write.xls is in this little function:
>
> df.tobewritten = as.data.frame(get(s[i]))
>
> the get function is locking for objects only in user workspace, with an
> object is inside a function the get dont find it. In my example:
>
> test <- function(a){
> a <- data.frame(A=c(1,2),B=c(10,11))
> write.xls(a,file="a.xls")
> }
>
> how I can put the object a visible to userspace environment to write.xls
> find it.

You could assign() it to that environment, but working around the 
write.xls() shortcoming by another hack is maybe not the best idea.

Best wishes,
Uwe


>
> Thanks
> Ronaldo
>



More information about the R-help mailing list