Um texto embutido e sem conjunto de caracteres especificado foi limpo... Nome: n?o dispon?vel Url: <https://stat.ethz.ch/pipermail/r-help/attachments/20111218/2247bc71/attachment.pl>
write.xls dont find the object in function
7 messages · Ronaldo Reis Júnior, Rolf Turner, Uwe Ligges +1 more
On 18.12.2011 12:58, Ronaldo Reis J?nior wrote:
Hi, I try to use write.xls from dataframes2xls inside a function. The write.xls work normally in console, but inside a function it dont find the object. Look this example:
> library(dataframes2xls)
> test<- function(x){
+ a<- data.frame(A=c(1,2),B=c(10,11)) + write.xls(a,file="a.xls") + }
> test()
Erro em get(s[i]) : objeto 'a' n?o encontrado Why the write.xls dont find the object a inside a function?
Because at least that part of the function is poorly written. Uwe Ligges
Thanks Ronaldo
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
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
Um texto embutido e sem conjunto de caracteres especificado foi limpo... Nome: n?o dispon?vel Url: <https://stat.ethz.ch/pipermail/r-help/attachments/20111219/7c2f9469/attachment.pl>
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
1 day later
Or:
require(xlsx)
test <- function(x){
+ a <- data.frame(A=c(1,2),B=c(10,11)) + write.xlsx(a,file="a.xlsx") + }
test() list.files(patt='xlsx')
[1] "a.xlsx"
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 12/19/11 4:30 AM, "Ronaldo Reis J?nior" <chrysopix at gmail.com> 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.
>
>Thanks
>Ronaldo
>
>--
>10? lei - Seu orientador espera que a sua produtividade seja baixa
> inicialmente e esteja acima da m?dia ap?s um ano.
>
> --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228.
>
>> Prof. Ronaldo Reis J?nior
>| .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional
>| : :' : Campus Universit?rio Prof. Darcy Ribeiro, Vila Mauric?ia
>| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
>| `- Fone: (38) 3229-8192 |ronaldo.reis at unimontes.br
>|http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366
>
>
> [[alternative HTML version deleted]]
>
2 days later
Um texto embutido e sem conjunto de caracteres especificado foi limpo... Nome: n?o dispon?vel Url: <https://stat.ethz.ch/pipermail/r-help/attachments/20111223/fb8fd312/attachment.pl>