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@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.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php

______________________________________________
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.

Reply via email to