thmsfuller066 at gmail.com
2010-Jul-07 16:56 UTC
[R] Weired problem when passing arguments using ...?
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 -- Tom
Henrique Dallazuanna
2010-Jul-07 19:18 UTC
[R] Weired problem when passing arguments using ...?
Try write.table instead. On Wed, Jul 7, 2010 at 1:56 PM, thmsfuller066@gmail.com < thmsfuller066@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 > > -- > Tom > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Charles C. Berry
2010-Jul-07 19:29 UTC
[R] Weired problem when passing arguments using ...?
On Wed, 7 Jul 2010, 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?Its not a _problem_, its a _feature_. read ?write.csv and use write.table()> > > ##################### > 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 > > -- > Tom > > ______________________________________________ > 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. >Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:cberry at tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
David Winsemius
2010-Jul-07 19:38 UTC
[R] Weired problem when passing arguments using ...?
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' ignoredwrite.csv sets col.names according to hard-coded rules which you are (unsuccessfully attempting to override. -- David Winsemius, MD West Hartford, CT