[R] Weired problem when passing arguments using ...?
David Winsemius
dwinsemius at comcast.net
Wed Jul 7 21:38:57 CEST 2010
On Jul 7, 2010, at 12:56 PM, thmsfuller066 at gmail.com wrote:
> Hello All,
>
> I'm trying to pass the argument col.names to write.csv using '...'.
> But I got the following warnings. Maybe it is very simple. But I'm not
> sure what I am wrong. Could you please help point to me what the
> problem is?
>
>
> #####################
> fun=function(x, ...) {
> fr=parent.frame()
> tmp=get(x, envir=fr)
> write.csv(
> tmp
> , file=paste(x, '.csv', sep='')
> , ...
> )
> }
>
> f=data.frame(x=1:10,y=letters[1:10])
>
> fun('f', col.names=F)
> ####################
>
>> fun('f', col.names=F)
> Warning message:
> In write.csv(tmp, file = paste(x, ".csv", sep = ""), ...) :
> attempt to set 'col.names' ignored
write.csv sets col.names according to hard-coded rules which you are
(unsuccessfully attempting to override.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list