Dear all,
sorry for this very basic question, but I did not find any good example yet.
I would like to set up a variable that can be recall later to substitute a
part of a file name.
As example:
var_filename = as.name("aaa")
jpeg("var_filename.jpg")
plot()
dev.off()
It would be very useful in order to avoid to change manually many strings. I
guess it is possible, but I did not find a way.
I am using R 2.7.0 on a window machine.
Thank you very much in advance.
Laura
[[alternative HTML version deleted]]
Try this:
sprintf("%s.jpg", var_filename)
On Wed, Jul 2, 2008 at 10:31 AM, Laura Poggio <laura.poggio@gmail.com>
wrote:
> Dear all,
> sorry for this very basic question, but I did not find any good example
> yet.
>
> I would like to set up a variable that can be recall later to substitute a
> part of a file name.
> As example:
>
> var_filename = as.name("aaa")
>
> jpeg("var_filename.jpg")
> plot()
> dev.off()
>
> It would be very useful in order to avoid to change manually many strings.
> I
> guess it is possible, but I did not find a way.
> I am using R 2.7.0 on a window machine.
>
> Thank you very much in advance.
>
> Laura
>
> [[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.
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
Laura Does jpeg(paste(var_filename, "jpg", sep=".")) do what you want? Regards Richard Laura Poggio wrote:> Dear all, > sorry for this very basic question, but I did not find any good example yet. > > I would like to set up a variable that can be recall later to substitute a > part of a file name. > As example: > > var_filename = as.name("aaa") > > jpeg("var_filename.jpg") > plot() > dev.off() > > It would be very useful in order to avoid to change manually many strings. I > guess it is possible, but I did not find a way. > I am using R 2.7.0 on a window machine. > > Thank you very much in advance. > > Laura > > [[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. >-- Richard D. Pearson richard.pearson at postgrad.manchester.ac.uk School of Computer Science, http://www.cs.man.ac.uk/~pearsonr University of Manchester, Tel: +44 161 275 6178 Oxford Road, Mob: +44 7971 221181 Manchester M13 9PL, UK. Fax: +44 161 275 6204
On 02.07.2008, at 15:31, Laura Poggio wrote:> Dear all, > sorry for this very basic question, but I did not find any good > example yet. > > I would like to set up a variable that can be recall later to > substitute a > part of a file name. > As example: > > var_filename = as.name("aaa") > > jpeg("var_filename.jpg") > plot() > dev.off()try: var_filename <- 'foo' jpeg( paste( var_filename, '.jpg', sep='' ) ) See ?paste --Hans