An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111013/226fc276/attachment.pl>
write.csv naming file after function argument
4 messages · Ivan Calandra, Jean V Adams, Kristian Lind
Hi Kristian,
If I understand correctly, you probably want to use paste():
myfun <- function(x=peter){
y <- x/2
filename <- paste(x, ".csv", sep="")
write.csv(y, file = filename)
}
HTH,
Ivan
Le 10/13/2011 11:52, Kristian Lind a ?crit :
Dear R-users,
I'm writing a program that constructs a dataset. I wish to save the dataset
to a file.
Here's a very simple example of what I'm trying to do
function(x=peter){
y<- x/2
write.csv(y, file = "...\x")
}
The problem is that I want to name the dataset as whatever the name of the
input is. In this case peter.
How do I do this?
Thank you in advance.
Kristian
[[alternative HTML version deleted]]
______________________________________________ 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.
Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Dept. Mammalogy Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111013/a11ff446/attachment.pl>
2 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111016/5b359d11/attachment.pl>