Re: [R] Adding Year-Month-Day to X axis

2018-05-11 Thread Jim Lemon
Hi Jayaganesh,
I'm not sure this will help, but here is a simple example using box.heresy:

y_duration <- c (16.438, 15.321, 12.700, 12.397, 10.795, 9.928, 10.386)
library(plotrix)
box.heresy(1,mean(y_duration),uinner=std.error(y_duration)
 ,ulim=sd(y_duration),intervals=TRUE)
#add the median as a circle symbol
points(1,median(y_duration))

Jim


On Wed, May 9, 2018 at 3:25 PM, Jayaganesh Anbuganapathy
 wrote:
> Helo Greg - I got it with help of your code and I would like to add the
> value into the boxplot chart. How to do that.
>
> y_duration <- c (16.438, 15.321, 12.700, 12.397, 10.795, 9.928, 10.386)
>
>
>
>
> On May 09, 2018, at 10:06 AM, Jayaganesh Anbuganapathy 
> wrote:
>
> Actually I would like to get an output on the below snapshot. I have tried
> various method like points, labels.. but nothing works. Attached is the data
> for your reference.
>
>
>
> On May 09, 2018, at 09:59 AM, Gregory Coats  wrote:
>
> I do not see any difference between the x versus y plot drawn in blue, and
> the y only plot drawn in red. Is the correct?
> Greg
>
> y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883,
> 342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166,
> 282.01816, 280.0)
> x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27",
> "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02",
> "2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07",
> "2018-05-08)"), format="%Y-%m-%d")
> plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
> ylim=range(240,480), xlab="", ylab="", col="blue")
> plot ( y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480),
> xlab="", ylab="", col="red" )
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@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.
> __
> R-help@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.

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-09 Thread Jayaganesh Anbuganapathy

Helo Greg - I got it with help of your code and I would like to add the value 
into the boxplot chart. How to do that.

y_duration <- c (16.438, 15.321, 12.700, 12.397, 
10.795, 9.928, 10.386)





On May 09, 2018, at 10:06 AM, Jayaganesh Anbuganapathy  
wrote:

Actually I would like to get an output on the below snapshot. I have tried 
various method like points, labels.. but nothing works. Attached is the data 
for your reference.



On May 09, 2018, at 09:59 AM, Gregory Coats  wrote:

I do not see any difference between the x versus y plot drawn in blue, and the 
y only plot drawn in red. Is the correct?
Greg

y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883, 
342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166, 
282.01816, 280.0)
x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27", "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02", 
"2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07", "2018-05-08)"), format="%Y-%m-%d")
plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480), xlab="", 
ylab="", col="blue")
plot ( y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480), xlab="", ylab="", 
col="red" )


       [[alternative HTML version deleted]]

__
R-help@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.
__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-09 Thread Jayaganesh Anbuganapathy

Actually I would like to get an output on the below snapshot. I have tried 
various method like points, labels.. but nothing works. Attached is the data 
for your reference.



On May 09, 2018, at 09:59 AM, Gregory Coats  wrote:

I do not see any difference between the x versus y plot drawn in blue, and the 
y only plot drawn in red. Is the correct?
Greg

y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883, 
342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166, 
282.01816, 280.0)
x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27", "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02", 
"2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07", "2018-05-08)"), format="%Y-%m-%d")
plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480), xlab="", 
ylab="", col="blue")
plot ( y_duration, type="l", xaxt="n", yaxt="n", ylim=range(240,480), xlab="", ylab="", 
col="red" )


       [[alternative HTML version deleted]]

__
R-help@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.
__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-08 Thread Gregory Coats
I do not see any difference between the x versus y plot drawn in blue, and the 
y only plot drawn in red. Is the correct?
Greg

y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883, 
342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166, 
282.01816, 280.0)
x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27", "2018-04-28", 
"2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02", "2018-05-03", 
"2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07", "2018-05-08)"), 
format="%Y-%m-%d")
plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", 
ylim=range(240,480), xlab="", ylab="", col="blue")
plot (y_duration, type="l", xaxt="n", yaxt="n", 
ylim=range(240,480), xlab="", ylab="", col="red" )


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-08 Thread Jim Lemon
Hi Greg,
This is because both plots have equally spaced x values. To see the
difference, try this:

plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
ylim=range(240,480), xlab="", ylab="", col="blue")
axis(1)
plot (y_duration, type="l", xaxt="n", yaxt="n",
ylim=range(240,480), xlab="", ylab="", col="red" )
axis(1)

Jim

On Wed, May 9, 2018 at 9:00 AM, Gregory Coats  wrote:
> I do not see any difference between the x versus y plot drawn in blue, and
> the y only plot drawn in red. Is the correct?
> Greg
>
> y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883,
> 342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166,
> 282.01816, 280.0)
> x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27",
> "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02",
> "2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07",
> "2018-05-08)"), format="%Y-%m-%d")
> plot (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
> ylim=range(240,480), xlab="", ylab="", col="blue")
> plot (y_duration, type="l", xaxt="n", yaxt="n",
> ylim=range(240,480), xlab="", ylab="", col="red" )
>

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-08 Thread Eric Berger
abline  (v=x_mmdd, lty=3, lwd=1.0, col="blue")


On Tue, May 8, 2018 at 5:23 PM, Gregory Coats  wrote:

> Since the horizontal axis side=1 is year-month-day, how do I issue an
> abline command to draw dashed vertical lines, as a background grid, within
> the graph’s border? Similar to the abline command I call below, in blue,
> for dashed horizontal lines, as a background grid.
> Greg
>
> y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883,
> 342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066,
> 258.23166, 282.01816)
> x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27",
> "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02",
> "2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07"),
> format="%Y-%m-%d")
> par (mar=c(6,4,4,2))
> plot(x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
> ylim=range(240,480), xlab="", ylab="", col="blue")
> abline  (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=3,
> lwd=1.0, col="grey50")
> axis(side=2, at=240, cex.axis=1.0, label="4:00")
> axis(side=2, at=300, cex.axis=1.0, label="5:00")
> axis(side=2, at=360, cex.axis=1.0, label="6:00")
> axis(side=2, at=420, cex.axis=1.0, label="7:00")
> axis(side=2, at=480, cex.axis=1.0, label="8:00")
> axis(side=1, at=x_mmdd, labels=format(x_mmdd, "%Y-%m-%d"),
> las=2)
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@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]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-08 Thread Gregory Coats
Since the horizontal axis side=1 is year-month-day, how do I issue an abline 
command to draw dashed vertical lines, as a background grid, within the graph’s 
border? Similar to the abline command I call below, in blue, for dashed 
horizontal lines, as a background grid.
Greg

y_duration <- c (301.59050, 387.35700, 365.64366, 317.26150, 321.71883, 
342.44950, 318.95350, 322.33233, 330.60333, 428.99516, 297.82066, 258.23166, 
282.01816)
x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27", "2018-04-28", 
"2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02", "2018-05-03", 
"2018-05-04", "2018-05-05", "2018-05-06", "2018-05-07"), format="%Y-%m-%d")
par (mar=c(6,4,4,2))
plot(x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", 
ylim=range(240,480), xlab="", ylab="", col="blue")
abline  (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=3, lwd=1.0, 
col="grey50")
axis(side=2, at=240, cex.axis=1.0, label="4:00")
axis(side=2, at=300, cex.axis=1.0, label="5:00")
axis(side=2, at=360, cex.axis=1.0, label="6:00")
axis(side=2, at=420, cex.axis=1.0, label="7:00")
axis(side=2, at=480, cex.axis=1.0, label="8:00")
axis(side=1, at=x_mmdd, labels=format(x_mmdd, "%Y-%m-%d"), las=2)


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Gregory Coats
Thanks. Regarding 
axis(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))

How do I get the text for -MM-DD to be drawn vertically, instead of 
horizontally?
Greg

> On May 6, 2018, at 11:54 PM, Jim Lemon  wrote:
> 
> axis(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
Look at par(las=2) in the graphics package. You will almost certainly
have to increase the bottom margin, e.g.:

par(mar=c(6,4,4,2)

to accomodate the vertical labels.

Jim


On Mon, May 7, 2018 at 2:11 PM, Gregory Coats  wrote:
> Thanks. Regarding
> axis(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))
>
> How do I get the text for -MM-DD to be drawn vertically, instead of
> horizontally?
> Greg
>
> On May 6, 2018, at 11:54 PM, Jim Lemon  wrote:
>
> axis(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))
>
>

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
Hi Greg,
Easy:

plot   (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
ylim=range(240,480))
abline (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=2,
lwd=1.0, col="grey40")
axis(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))
axis(2,at=seq(240,480,by=60),labels=c("4.00","5.00","6.00","7.00","8.00"))

However, you are only getting every third label. If you want to
display more of them you can use staxlab:

staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"),nlines=3)
OR
staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"),srt=45)

Jim


On Mon, May 7, 2018 at 1:26 PM, Gregory Coats  wrote:
> Jim,
> Thank you very much!
> How do I use the axis command for side=1 to label the x horizontal axis, in
> the format="%Y-%m-%d” style?
> Greg
>
> y_duration <- c (301.59050,  387.35700,  365.64366,  317.26150,  321.71883,
> 342.44950,  318.95350,  322.33233,  330.60333,  428.99516,  297.82066,
> 258.23166)
> x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27",
> "2018-04-28", "2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02",
> "2018-05-03", "2018-05-04", "2018-05-05", "2018-05-06"), format="%Y-%m-%d")
> plot   (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n",
> ylim=range(240,480))
> abline (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=2, lwd=1.0,
> col="grey40")
> axis   (side=2, at=240,  cex.axis=1.0, label="4:00")
> axis   (side=2, at=300,  cex.axis=1.0, label="5:00")
> axis   (side=2, at=360,  cex.axis=1.0, label="6:00")
> axis   (side=2, at=420,  cex.axis=1.0, label="7:00")
> axis   (side=2, at=480,  cex.axis=1.0, label="8:00")
>
> On May 6, 2018, at 3:52 AM, Jim Lemon  wrote:
>
> Hi Greg,
> By default, the "axis" function puts the labels on one line and drops
> labels that would overlap. When you have labels that are all the same
> length, this usually results in every second, or third, or fourth
> label being displayed. So you can probably get what you want by not
> using staxlab. However, if you really want to use staxlab, try this:
>
> oddones<-seq(1,length(x_mmdd)-1,by=2)
> staxlab(1,at=x_mmdd[oddones],
> labels=format(x_mmdd,"%Y-%m-%d")[oddones])
>
> It will also work with plain "axis", which is what you seem to want.
>
> Jim
>
>

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Gregory Coats
Jim,
Thank you very much!
How do I use the axis command for side=1 to label the x horizontal axis, in the 
format="%Y-%m-%d” style?
Greg

y_duration <- c (301.59050,  387.35700,  365.64366,  317.26150,  321.71883,  
342.44950,  318.95350,  322.33233,  330.60333,  428.99516,  297.82066,  
258.23166)
x_mmdd <-as.Date(c ("2018-04-25", "2018-04-26", "2018-04-27", "2018-04-28", 
"2018-04-29", "2018-04-30", "2018-05-01", "2018-05-02", "2018-05-03", 
"2018-05-04", "2018-05-05", "2018-05-06"), format="%Y-%m-%d")
plot   (x_mmdd, y_duration, type="l", xaxt="n", yaxt="n", 
ylim=range(240,480))
abline (h=c(240,270,300,330,360,390,420,450,480,510,540), lty=2, lwd=1.0, 
col="grey40")
axis   (side=2, at=240,  cex.axis=1.0, label="4:00")
axis   (side=2, at=300,  cex.axis=1.0, label="5:00")
axis   (side=2, at=360,  cex.axis=1.0, label="6:00")
axis   (side=2, at=420,  cex.axis=1.0, label="7:00")
axis   (side=2, at=480,  cex.axis=1.0, label="8:00")

> On May 6, 2018, at 3:52 AM, Jim Lemon  wrote:
> 
> Hi Greg,
> By default, the "axis" function puts the labels on one line and drops
> labels that would overlap. When you have labels that are all the same
> length, this usually results in every second, or third, or fourth
> label being displayed. So you can probably get what you want by not
> using staxlab. However, if you really want to use staxlab, try this:
> 
> oddones<-seq(1,length(x_mmdd)-1,by=2)
> staxlab(1,at=x_mmdd[oddones],
> labels=format(x_mmdd,"%Y-%m-%d")[oddones])
> 
> It will also work with plain "axis", which is what you seem to want.
> 
> Jim


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Jim Lemon
Hi Greg,
By default, the "axis" function puts the labels on one line and drops
labels that would overlap. When you have labels that are all the same
length, this usually results in every second, or third, or fourth
label being displayed. So you can probably get what you want by not
using staxlab. However, if you really want to use staxlab, try this:

oddones<-seq(1,length(x_mmdd)-1,by=2)
staxlab(1,at=x_mmdd[oddones],
 labels=format(x_mmdd,"%Y-%m-%d")[oddones])

It will also work with plain "axis", which is what you seem to want.

Jim

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-06 Thread Gregory Coats
Jim, Thanks for responding!
I am using the official R 3.5.0 for Mac OS X.
This apparently does not include library (plotrix)

library(plotrix)
Error in library(plotrix) : there is no package called ‘plotrix’

Greg

> On May 5, 2018, at 6:50 PM, Jim Lemon  wrote:
> 
> Hi Greg,
> What you are getting there is a factor, interpreted as a 1:n sequence
> based on the sort order of your "dates". Here's a way to get dates on
> your x-axis in the format you want:
> 
> x_mmdd<-as.Date(c("2018-04-25","2018-04-26","2018-04-27",
> "2018-04-28","2018-04-29","2018-04-30","2018-05-01","2018-05-02",
> "2018-05-03","2018-05-04","2018-05-05"),format="%Y-%m-%d")
> plot(x_mmdd, y_duration, type="l",xaxt="n")
> library(plotrix)
> staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))
> 
> Jim


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Gregory Coats
Jim,
That you very much!
How do I instruct staxlab to label once every n days, rather than labeling 
every day?
Greg

> On May 5, 2018, at 6:50 PM, Jim Lemon  wrote:
> 
> staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Jim Lemon
Hi Greg,
The only reason I included the staxlab function in the plotrix library
was to fit all the dates onto the axis. If you want to try it:

install.packages("plotrix")

Jim


On Sun, May 6, 2018 at 9:02 AM, Gregory Coats  wrote:
> Jim, Thanks for responding!
> I am using the official R 3.5.0 for Mac OS X.
> This apparently does not include library (plotrix)
>
> library(plotrix)
> Error in library(plotrix) : there is no package called ‘plotrix’
>
> Greg
>
> On May 5, 2018, at 6:50 PM, Jim Lemon  wrote:
>
> Hi Greg,
> What you are getting there is a factor, interpreted as a 1:n sequence
> based on the sort order of your "dates". Here's a way to get dates on
> your x-axis in the format you want:
>
> x_mmdd<-as.Date(c("2018-04-25","2018-04-26","2018-04-27",
> "2018-04-28","2018-04-29","2018-04-30","2018-05-01","2018-05-02",
> "2018-05-03","2018-05-04","2018-05-05"),format="%Y-%m-%d")
> plot(x_mmdd, y_duration, type="l",xaxt="n")
> library(plotrix)
> staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))
>
> Jim
>
>

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Bert Gunter
"Apparently, R does not understand my Year-Month-Day "

I think, rather, you need to learn how R handles dates and times.

See here to begin, perhaps:
?DateTimeClasses

There are many R resources for dealing with data over time, many of which
are listed here, and others might be found by online searching.
https://cran.r-project.org/web/views/TimeSeries.html

There are also many tutorials on dealing with time data in R. Even a
cursory web search should find many.

... and of course someone may respond directly to your query here (but not
me, as I'm not that knowledgeable).

Cheers,
Bert




Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Sat, May 5, 2018 at 11:14 AM, Gregory Coats  wrote:

> I am using R 3.5.0 for Mac OS X.
> Issuing these two commands yields the expected plot.
> y_duration <- c (301.59050,  387.35700,  365.64366,  317.26150,
> 321.71883,  342.44950,  318.95350,  322.33233,  330.60333,  428.99516,
> 297.82066)
> plot (y_duration, type="l”)
>
> Adding Year-Month-Day values for the x axis, and then calling plot (x,y),
> yields a bizarre plot. Apparently, R does not understand my Year-Month-Day
> values.
> x_mmdd <- c (2018-04-25, 2018-04-26, 2018-04-27, 2018-04-28,
> 2018-04-29, 2018-04-30, 2018-05-01, 2018-05-02, 2018-05-03, 2018-05-04,
> 2018-05-05)
> plot (x_mmdd, y_duration, type="l")
>
> I would be enormously appreciative of your guidance.
> Greg Coats
> Virginia, USA
> [[alternative HTML version deleted]]
>
> __
> R-help@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]]

__
R-help@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.


Re: [R] Adding Year-Month-Day to X axis

2018-05-05 Thread Jim Lemon
Hi Greg,
What you are getting there is a factor, interpreted as a 1:n sequence
based on the sort order of your "dates". Here's a way to get dates on
your x-axis in the format you want:

x_mmdd<-as.Date(c("2018-04-25","2018-04-26","2018-04-27",
 "2018-04-28","2018-04-29","2018-04-30","2018-05-01","2018-05-02",
 "2018-05-03","2018-05-04","2018-05-05"),format="%Y-%m-%d")
plot(x_mmdd, y_duration, type="l",xaxt="n")
library(plotrix)
staxlab(1,at=x_mmdd,labels=format(x_mmdd,"%Y-%m-%d"))

Jim

On Sun, May 6, 2018 at 4:14 AM, Gregory Coats  wrote:
> I am using R 3.5.0 for Mac OS X.
> Issuing these two commands yields the expected plot.
> y_duration <- c (301.59050,  387.35700,  365.64366,  317.26150,  321.71883,  
> 342.44950,  318.95350,  322.33233,  330.60333,  428.99516,  297.82066)
> plot (y_duration, type="l”)
>
> Adding Year-Month-Day values for the x axis, and then calling plot (x,y), 
> yields a bizarre plot. Apparently, R does not understand my Year-Month-Day 
> values.
> x_mmdd <- c (2018-04-25, 2018-04-26, 2018-04-27, 2018-04-28, 2018-04-29, 
> 2018-04-30, 2018-05-01, 2018-05-02, 2018-05-03, 2018-05-04, 2018-05-05)
> plot (x_mmdd, y_duration, type="l")
>
> I would be enormously appreciative of your guidance.
> Greg Coats
> Virginia, USA
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

__
R-help@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.


[R] Adding Year-Month-Day to X axis

2018-05-05 Thread Gregory Coats
I am using R 3.5.0 for Mac OS X.
Issuing these two commands yields the expected plot.
y_duration <- c (301.59050,  387.35700,  365.64366,  317.26150,  321.71883,  
342.44950,  318.95350,  322.33233,  330.60333,  428.99516,  297.82066)
plot (y_duration, type="l”)

Adding Year-Month-Day values for the x axis, and then calling plot (x,y), 
yields a bizarre plot. Apparently, R does not understand my Year-Month-Day 
values.
x_mmdd <- c (2018-04-25, 2018-04-26, 2018-04-27, 2018-04-28, 2018-04-29, 
2018-04-30, 2018-05-01, 2018-05-02, 2018-05-03, 2018-05-04, 2018-05-05)
plot (x_mmdd, y_duration, type="l")

I would be enormously appreciative of your guidance.
Greg Coats
Virginia, USA
[[alternative HTML version deleted]]

__
R-help@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.