Evgenia
2015-Feb-09 13:14 UTC
[R] Save a plot with a name given as an argument in a function
test<-function(data, TitleGraph){ pdf("TitleGraph.pdf",width=7,height=5) plot(data) dev.off() } test(cars <- c(1, 3, 6, 4, 9),TitleGraph="etc") My problem is that I want graph pdf being saved as etc and not as Titlegraph.pdf -- View this message in context: http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965.html Sent from the R help mailing list archive at Nabble.com.
Evgenia
2015-Feb-09 13:30 UTC
[R] Save a plot with a name given as an argument in a function
Thanks alot -- View this message in context: http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965p4702969.html Sent from the R help mailing list archive at Nabble.com.
Jorge I Velez
2015-Feb-09 13:32 UTC
[R] Save a plot with a name given as an argument in a function
Hi Evgenia, Try test2 <- function(data, TitleGraph){ pdf(paste0(TitleGraph, ".pdf"), width = 7, height = 5) plot(data) dev.off() } instead. Take a look at ?paste0 for more information. HTH, Jorge.- On Tue, Feb 10, 2015 at 12:14 AM, Evgenia <evgts at aueb.gr> wrote:> test<-function(data, TitleGraph){ > > > pdf("TitleGraph.pdf",width=7,height=5) > plot(data) > dev.off() > } > > test(cars <- c(1, 3, 6, 4, 9),TitleGraph="etc") > > My problem is that I want graph pdf being saved as etc and not as > Titlegraph.pdf > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Save-a-plot-with-a-name-given-as-an-argument-in-a-function-tp4702965.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]