[R] month and output

David Winsemius dwinsemius at comcast.net
Sat May 7 01:30:05 CEST 2016

> On May 6, 2016, at 4:11 PM, Ashta <sewashm at gmail.com> wrote:
> Hi all,
> I am trying to ge get the next month of the year.
> today <- Sys.Date()
> xx<- format(today, format="%B%Y")
> I got  "May2016",  but I want  Jun2016. How do I do that?

today <- Sys.Date()
nextmo<- paste0( month.abb[ as.numeric(format(today, format="%m"))+1] ,
                 format(today,"%Y") )
[1] "Jun2016"

> My other question is that, I read a data  and do some analysis  and I
> want to send all the results of the analysis to a pdf file
> Example
> x5 <- runif(15, 5.0, 7.5)
> x5
> I tried this one
> pdf(file=" test.pdf")
> x5
> dev.off()

pdf() opens a graphics device, so you need a function that establishes a coordinate system:

x5 <- runif(15, 5.0, 7.5)
pdf(file=" test.pdf"); 
text(1, 1, paste(round(x5, 2), collapse="\n") )

I doubt that this is what you really want, and suspect you really need to be studying the capabilities supported by the knitr package. If I'm wrong about that and you want a system that supports drawing and text on a blank page, then first study:

> library(grid)
> help(pac=grid)

If you choose that route then the text "R Graphics" by Paul Murrell will be indispensable.

David Winsemius
Alameda, CA, USA

More information about the R-help mailing list