Re: [R] How do I "teach" R that columns 1, 2, and 3 are the Year-Month-Day

2022-06-15 Thread Gregory Coats via R-help
I do not see any posting on this topic from Jeff Newmiller.
I seek a way to “teach” R that "2021-07-25” represents a Year, Month, and Day.
Greg Coats

> Fuel <- c(50.45, 61.48, 59.07, 55.40, 30.63, 41.35, 32.81, 49.86, 62.99, 
> 89.37)
> plot (Fuel)
> Dates <- c("2021-07-25", "2021-08-27", "2021-09-26", "2021-11-04", 
> "2021-11-22", "2021-11-26", "2021-12-06", "2022-01-14", "2022-04-29", 
> "2022-06-11")
> plot (Dates)
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

> xyplot (Dates, Fuel)
Error in xyplot(Dates, Fuel) : could not find function "xyplot"

> On Jun 15, 2022, at 6:02 AM, Martin Maechler  
> wrote:
> Jeff Newmiller's answer which was much shorter *and* only
> used base R  instead of an extra package


[[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] How do I "teach" R that columns 1, 2, and 3 are the Year-Month-Day

2022-06-14 Thread Gregory Coats via R-help
# Column 1 is the Year
# Column 2 is the Month
# Column 3 is the Day
# Column 4 is the Fuel
Fuel <- c(50.45, 61.48, 59.07, 55.40, 30.63, 41.35, 32.81, 49.86, 62.99, 89.37)
plot (Fuel)

2021  7 25   50.45  
2021  8 27   61.48  
2021  9 26   59.07 
2021 11  4   55.40  
2021 11 22   30.63 
2021 11 26   41.35  
2021 12  6   32.81  
2022  1 14   49.86  
2022  4 29   62.99  
2022  6 11   89.37  

How do I "teach" R that columns 1, 2, and 3 are the Year-Month-Day?
Greg Coats
[[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] library(hms)

2021-03-17 Thread Gregory Coats via R-help
It appears that 
install.libraries(“hms”)
is unsuccessful, but that
install.packages(“hms”)
is successful.

install.packages("lubridate")
downloaded 1.5 MB
install.packages("hms")
downloaded 95 KB
install.packages("data.table")
downloaded 2.2 MB
Greg
> On Mar 17, 2021, at 1:07 PM, Gregory Coats via R-help  
> wrote:
> 
> On my MacBook, I do not have, and do not know how to install, library(hms).
> Greg Coats
> 
>> library(hms)
> Error in library(hms) : there is no package called ‘hms’
>> Install.libraries(“hms”)
> Error: unexpected input in "Install.libraries(“"
>> 
>   [[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.


[R] library(hms)

2021-03-17 Thread Gregory Coats via R-help
On my MacBook, I do not have, and do not know how to install, library(hms).
Greg Coats

> library(hms)
Error in library(hms) : there is no package called ‘hms’
> Install.libraries(“hms”)
Error: unexpected input in "Install.libraries(“"
> 
[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
Thank you very much.
In addition to what your did, for event 1, I would like to draw a horizontal 
line connecting from day 1 to day 2 to day 3 to day 4.
Then, for event 2, I would like to draw a horizontal line connecting from day 1 
to day 2 to day 3 to day 4.
Similarly for events 3, and 4. Is that convenient to do?
Greg Coats

> On Mar 16, 2021, at 8:01 PM, Avi Gross via R-help  
> wrote:
> 
> Here is an example that worked for me doing roughly what I mentioned but
> note my names changed. It makes two plots.
> 
> library (ggplot2)
> myDat <- read.table(text =
>  "datetimeraw
> 2021-03-12 05:16:46
> 2021-03-12 09:17:02
> 2021-03-12 13:31:43
> 2021-03-12 22:00:32
> 2021-03-13 09:21:43
> 2021-03-13 13:51:12
> 2021-03-13 18:03:13
> 2021-03-13 22:20:28
> 2021-03-14 08:59:03
> 2021-03-14 13:15:56
> 2021-03-14 17:25:23
> 2021-03-14 21:36:26",
>sep = ",", header = TRUE)
> head(myDat)
> myDat$datetime <- as.POSIXct(myDat$datetimeraw, tz = "", format ="%Y-%M-%d
> %H:%M:%OS")
> myDat$date <- factor(format(myDat$datetime, "%Y-%m-%d"))
> myDat$time <- format(myDat$datetime, "%H:%M")
> myDat$seq <- factor(rep(1:4, 3))
> 
> # just dots
> ggplot(data=myDat,aes(x=date, y=time)) + geom_point(aes(color=seq))
> 
> # Also text
> ggplot(data=myDat,aes(x=date, y=time, label=time)) + 
>  geom_point(aes(color=seq)) + 
>   geom_text(aes(color=seq))

[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
Dan, Thank you for this guidance.
Unfortunately, I do not have the library lubridate, and I do not at this moment 
know where to go to get this library for an Apple MacBook.

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

Greg Coats
Reston, Virginia USA

> On Mar 16, 2021, at 7:49 PM, Daniel Nordlund  wrote:
> 
> # create timepart variable - tme
> library(lubridate)


[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
Thank you. Let me redefine the situation.
Each time an event starts, I record the date and time.
Each day there are 4 new events. Time is the only variable.
I would like to graphically show how the time for events 1, 2, 3, and 4 for the 
current day compare to the times for events 1, 2, 3, and 4 for the previous 
day. How would I plot / display those times differences?
Greg Coats

library (ggplot2)
myDat <- read.table(text =
"datetime
2021-03-12 05:16:46
2021-03-12 09:17:02
2021-03-12 13:31:43
2021-03-12 22:00:32
2021-03-13 09:21:43
2021-03-13 13:51:12
2021-03-13 18:03:13
2021-03-13 22:20:28
2021-03-14 08:59:03
2021-03-14 13:15:56 
2021-03-14 17:25:23
2021-03-14 21:36:26",
sep = ",", header = TRUE)
head(myDat)
myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format ="%Y-%M-%d 
%H:%M:%OS")

> On Mar 16, 2021, at 3:34 PM, John Fox  wrote:
> 
> Dear Greg,
> 
> Coordinate plots typically have a horizontal (x) and vertical (y) axis. The 
> command
> 
>   ggplot(myDat, aes(x=datetime, y = datetime)) + geom_point()
> 
> works, but I doubt that it produces what you want.
> 
> You have only one variable in your data set -- datetime -- so it's not 
> obvious what you want to do. If you can't clearly describe the structure of 
> the plot you intend to draw, it's doubtful that I or anyone else can help you.
> 
> Best,
> John
> 
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> web: https://socialsciences.mcmaster.ca/jfox/ 
> 

[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
I need a plot that shows the date and time that each event started.
This ggplot command was publicly given to me via this R Help Mailing LIst.
But the result of issuing the ggplot command is an Error in FUN message.
ggplot(myDat, aes(x=datetime, y = Y_Var)) + geom_point()
Error in FUN(X[[i]], ...) : object 'Y_Var' not found
Greg Coats

> On Mar 16, 2021, at 2:18 PM, John Fox  wrote:
> 
> There is no variable named Y_Var in your data set. I suspect that it's 
> intended to be a generic specification in the recipe you were apparently 
> given. In fact, there appears to be only one variable in myDat and that's 
> datetime. What is it that you're trying to do?


[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
I want to plot the date and time of the event, as reflected in data.
2021-03-11 10:00:00
Greg Coats

> On Mar 16, 2021, at 2:23 PM, Jeff Newmiller  wrote:
> 
> You don't seem to have a Y_Var in your data. What is it that you want to plot?
> 
> On March 16, 2021 9:21:05 AM PDT, Gregory Coats via R-help 
>  wrote:
>> Sarah, Thank you. Yes, now as.POSIXct works.
>> But the ggplot command I was told to use yields an Error message, and
>> there is no output plot.
>> Please help me. Greg
>>> library(ggplot2)
>>> myDat <- read.table(text =
>> + "datetime
>> + 2021-03-11 10:00:00
>> + 2021-03-11 14:17:00
>> + 2021-03-12 05:16:46
>> + 2021-03-12 09:17:02
>> + 2021-03-12 13:31:43
>> + 2021-03-12 22:00:32
>> + 2021-03-13 09:21:43",
>> + sep = ",", header = TRUE)
>>> head(myDat)
>>datetime
>> 1 2021-03-11 10:00:00
>> 2 2021-03-11 14:17:00
>> 3 2021-03-12 05:16:46
>> 4 2021-03-12 09:17:02
>> 5 2021-03-12 13:31:43
>> 6 2021-03-12 22:00:32
>>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format
>> ="%Y-%M-%d %H:%M:%OS”)
>>> ggplot(myDat, aes(x=datetime, y = Y_Var)) + geom_point()
>> Error in FUN(X[[i]], ...) : object 'Y_Var' not found
>> 
>>> On Mar 16, 2021, at 9:36 AM, Sarah Goslee 
>> wrote:
>>> 
>>> Hi,
>>> 
>>> It doesn't have anything to do with having a Mac - you have POSIX.
>>> 
>>> It's because something is wrong with your data import. Looking at the
>>> head() output you provided, it looks like your data file does NOT
>> have
>>> a header, because there's no datetime column, and the column name is
>>> actually X2021.03.11.10.00.0
>>> 
>>> So you specified a nonexistent column, and got a zero-length answer.
>>> 
>>> With correct specification, the as.POSIXct function works as expected
>> on Mac:
>>> 
>>> myDat <- read.table(text =
>>> "datetime
>>> 2021-03-11 10:00:00
>>> 2021-03-11 14:17:00
>>> 2021-03-12 05:16:46
>>> 2021-03-12 09:17:02
>>> 2021-03-12 13:31:43
>>> 2021-03-12 22:00:32
>>> 2021-03-13 09:21:43",
>>> sep = ",", header = TRUE)
>>> 
>>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format =
>>> "%Y-%M-%d %H:%M:%OS")
>>> 
>>> Sarah
>>> 
>>> On Tue, Mar 16, 2021 at 9:26 AM Gregory Coats via R-help
>>>  wrote:
>>>> 
>>>> My computer is an Apple MacBook. I do not have POSIX.
>>>> The command
>>>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format =
>> "%Y-%M-%d %H:%M:%OS")
>>>> yields the error
>>>> Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
>>>> replacement has 0 rows, data has 13
>>>> Please advise, How to proceed?
>>>> Greg Coats
>>>> 
>>>>> library(ggplot2)
>>>>> # Read a txt file on the Desktop, named "myDat.txt"
>>>>> myDat <- read.delim("~/Desktop/myDat.txt", header = TRUE, sep =
>> ",")
>>>>> head(myDat)
>>>> X2021.03.11.10.00.00
>>>> 1  2021-03-11 14:17:00
>>>> 2  2021-03-12 05:16:46
>>>> 3  2021-03-12 09:17:02
>>>> 4  2021-03-12 13:31:43
>>>> 5  2021-03-12 22:00:32
>>>> 6  2021-03-13 09:21:43
>>>>> # convert data to date time object
>>>>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format =
>> "%Y-%M-%d %H:%M:%OS")
>>>> Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
>>>> replacement has 0 rows, data has 13
>>>>> 
>>>>   [[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.
>>> -- 
>>> Sarah Goslee (she/her)
>>> http://www.numberwright.com
>> 
>> 
>>  [[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.
> 
> -- 
> Sent from my phone. Please excuse my brevity.

__
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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
Sarah, Thank you. Yes, now as.POSIXct works.
But the ggplot command I was told to use yields an Error message, and there is 
no output plot.
Please help me. Greg
> library(ggplot2)
> myDat <- read.table(text =
+ "datetime
+ 2021-03-11 10:00:00
+ 2021-03-11 14:17:00
+ 2021-03-12 05:16:46
+ 2021-03-12 09:17:02
+ 2021-03-12 13:31:43
+ 2021-03-12 22:00:32
+ 2021-03-13 09:21:43",
+ sep = ",", header = TRUE)
> head(myDat)
 datetime
1 2021-03-11 10:00:00
2 2021-03-11 14:17:00
3 2021-03-12 05:16:46
4 2021-03-12 09:17:02
5 2021-03-12 13:31:43
6 2021-03-12 22:00:32
> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format ="%Y-%M-%d 
> %H:%M:%OS”)
> ggplot(myDat, aes(x=datetime, y = Y_Var)) + geom_point()
Error in FUN(X[[i]], ...) : object 'Y_Var' not found

> On Mar 16, 2021, at 9:36 AM, Sarah Goslee  wrote:
> 
> Hi,
> 
> It doesn't have anything to do with having a Mac - you have POSIX.
> 
> It's because something is wrong with your data import. Looking at the
> head() output you provided, it looks like your data file does NOT have
> a header, because there's no datetime column, and the column name is
> actually X2021.03.11.10.00.0
> 
> So you specified a nonexistent column, and got a zero-length answer.
> 
> With correct specification, the as.POSIXct function works as expected on Mac:
> 
> myDat <- read.table(text =
> "datetime
> 2021-03-11 10:00:00
> 2021-03-11 14:17:00
> 2021-03-12 05:16:46
> 2021-03-12 09:17:02
> 2021-03-12 13:31:43
> 2021-03-12 22:00:32
> 2021-03-13 09:21:43",
> sep = ",", header = TRUE)
> 
> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format =
> "%Y-%M-%d %H:%M:%OS")
> 
> Sarah
> 
> On Tue, Mar 16, 2021 at 9:26 AM Gregory Coats via R-help
>  wrote:
>> 
>> My computer is an Apple MacBook. I do not have POSIX.
>> The command
>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d 
>> %H:%M:%OS")
>> yields the error
>> Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
>>  replacement has 0 rows, data has 13
>> Please advise, How to proceed?
>> Greg Coats
>> 
>>> library(ggplot2)
>>> # Read a txt file on the Desktop, named "myDat.txt"
>>> myDat <- read.delim("~/Desktop/myDat.txt", header = TRUE, sep = ",")
>>> head(myDat)
>>  X2021.03.11.10.00.00
>> 1  2021-03-11 14:17:00
>> 2  2021-03-12 05:16:46
>> 3  2021-03-12 09:17:02
>> 4  2021-03-12 13:31:43
>> 5  2021-03-12 22:00:32
>> 6  2021-03-13 09:21:43
>>> # convert data to date time object
>>> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d 
>>> %H:%M:%OS")
>> Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) :
>>  replacement has 0 rows, data has 13
>>> 
>>[[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.
> -- 
> Sarah Goslee (she/her)
> http://www.numberwright.com


[[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] How to plot dates

2021-03-16 Thread Gregory Coats via R-help
My computer is an Apple MacBook. I do not have POSIX. 
The command
myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d 
%H:%M:%OS")
yields the error
Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) : 
  replacement has 0 rows, data has 13
Please advise, How to proceed?
Greg Coats

> library(ggplot2)
> # Read a txt file on the Desktop, named "myDat.txt"
> myDat <- read.delim("~/Desktop/myDat.txt", header = TRUE, sep = ",")
> head(myDat)
  X2021.03.11.10.00.00
1  2021-03-11 14:17:00
2  2021-03-12 05:16:46
3  2021-03-12 09:17:02
4  2021-03-12 13:31:43
5  2021-03-12 22:00:32
6  2021-03-13 09:21:43
> # convert data to date time object
> myDat$datetime <- as.POSIXct(myDat$datetime, tz = "", format = "%Y-%M-%d 
> %H:%M:%OS")
Error in `$<-.data.frame`(`*tmp*`, datetime, value = numeric(0)) : 
  replacement has 0 rows, data has 13
> 
[[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] How to plot dates

2021-03-15 Thread Gregory Coats via R-help
I store in a text file the dates and times that an event occurred.
How do I direct R to import these text characters, and store the year, month, 
day, hour, minute, and second as a date?
How do I then plot this series of dates?
2021-03-11 10:00:00
2021-03-11 14:17:00
2021-03-12 05:16:46
2021-03-12 09:17:02
2021-03-12 13:31:43
2021-03-12 22:00:32
2021-03-13 09:21:43
2021-03-13 13:51:12
2021-03-13 18:03:13
2021-03-13 22:20:28
2021-03-14 08:59:03
2021-03-14 13:15:56 
2021-03-14 17:25:23
2021-03-14 21:36:26
Greg Coats
gregco...@me.com


[[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] A question regarding 749 R[21525:2855847] Warning

2021-01-15 Thread Gregory Coats via R-help
I reported this behavior on Thu Jan 7, 2021.
You did nothing wrong.
No fix has been issued.

This evening, I upgraded from R 4.0.2 to the Duke University R 4.0.3 for Apple 
Mac. Now all I can get from R 4.0.3 is this red error message (that means 
nothing to me). Is there an easy fix? Greg

2021-01-07 22:58:42.997 R[8311:37566] 
Warning: Expected min height of view: 
() 
to be less than or equal to 30 but got a height of 32.00. This error will 
be logged once per view in violation.

> On Jan 14, 2021, at 11:28 PM, maedeh kamali  wrote:
> 
> Dear Sir/Madam,
> 
> After installing R package version 4.0.3 and launching the R Console for the 
> first time, below warning message appeared:
> 
> 021-01-15 11:52:28.749 R[21525:2855847] Warning: Expected min height of view: 
> () to be less than or equal to 
> 30 but got a height of 32.00. This error will be logged once per view in 
> violation.
> 
> Could you please guide me how to fix it.
> 
> Best, 
> Maedeh KAMALI
>   [[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.


[R] Expected min height of view

2021-01-07 Thread Gregory Coats via R-help
I upgraded from R 4.0.2 to R 4.0.3 for Apple Mac at Duke University. Now, the 
only output I get from R 4.0.3 is an error message. Greg Coats
2021-01-07 22:58:42.997 R[8311:37566] Warning: Expected min height of view: 
() to be less than or equal to 30 
but got a height of 32.00. This error will be logged once per view in 
violation.
> version
   _   
platform   x86_64-apple-darwin17.0 
arch   x86_64  
os darwin17.0  
system x86_64, darwin17.0  
status 
major  4   
minor  0.3 
year   2020
month  10  
day10  
svn rev79318   
language   R   
version.string R version 4.0.3 (2020-10-10)
nickname   Bunny-Wunnies Freak Out 
> 
[[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] A Labeling the median

2020-12-29 Thread Gregory Coats via R-help
After calling plot, I draw a horizontal line representing the median with aline.
abline (h=median(walk_seconds), lty=1, lwd=2.0, col="firebrick4")
Then, I want to label that line as the median and do so by calling mtext.
mtext  (side=4, "median", col="firebrick4", adj=“0.50”)
The dilemma is I do not see how to know what value to pass for adj in mtext so 
that the horizontal line for median, and the text for median line up.
Greg
walk_seconds <- c (5207, 4276, 5351, 4218, 5104, 4229, 3916, 3441, 4319, 4277, 
5341, 5397, 4963, 6416, 3781, 4284, 2820, 3090, 3620, 3540, 3660, 3600, 3630, 
3640, 3479, 3154, 3495, 3040, 3535, 3600, 3165, 3225, 3737, 4183, 4354, 3236, 
3234, 3714, 3599, 3570, 2227, 4692, 3596, 3030, 3390, 3669, 4495, 5079, 5225, 
5407, 4042, 5582, 5449, 5471, 6681, 5717, 5825, 3997, 4026, 4065, 4223, 5448, 
5284, 5180, 3937, 3871, 4265, 4999, 5119, 5411, 4481, 5600, 4414, 4282, 5095, 
4904, 4311, 4542, 4481, 5257, 4774, 4037, 4409, 4944, 4616, 4153, 4401, 3708, 
5338, 4250, 3353, 4154, 4631, 4333, 3856, 5220, 4056, 4077, 5252, 3768, 4122, 
3757, 3890, 5344, 5311, 3809, 3736, 4028, 4177, 6815, 4795, 6217, 4480, 5667, 
6010, 5671, 6457, 4671, 5416, 5256, 5713, 6023, 5400, 5327, 5104, 5282, 5534, 
6452, 5481, 5126, 6464, 5540, 6362, 5027, 5247, 4826, 5697, 5252, 5478, 4948, 
5192, 4187, 5391, 5110, 5032, 5042, 5139, 4314, 5277, 5284, 4892, 4797, 5145, 
4921, 5960, 5219, 4377, 4946, 5557, 4063, 5457, 5279, 5422, 4343, 4227, 5725, 
4863, 5451, 3651, 5459, 4621, 5894, 4940, 5792, 4952, 5556, 5636, 5511, 3861, 
6017, 5520, 4564, 4756, 3966, 4529, 4138, 4782, 4253, 4810, 4708, 5504, 5603, 
5897, 6128, 5618, 5289, 5694, 5263, 5482, 5442, 4497, 3180, 7110, 3194, 2154, 
4532, 4340, 4031, 3451, 4839, 4730, 4223, 3515, 3542, 4708, 4078, 4938, 4153, 
3126, 3492, 4025, 4380, 4517, 4961, 4080, 4226, 4551, 3625, 4375, 5112, 5377, 
3811, 3268, 2722, 3125, 3134, 3376, 3316, 2928, 2712, 3062, 3238, 4540, 4595, 
3878, 4158, 4922, 6083, 4812, 5278, 5216, 4970, 3892, 4996, 3617, 3849, 3980, 
5682, 4373, 3860, 5086, 4936, 5252, 5228, 5220, 5009, 4858, 4953, 5170, 5468, 
6674, 3907, 4671, 3836, 3692, 3945, 3731, 5003, 3882, 3637, 3459, 3699, 3690, 
4138, 3990, 3448, 3983, 5309, 4146, 4027, 4307, 4707, 4166, 3600, 3600, 3600, 
5324, 3600, 4379, 3647, 3875, 5190, 4228, 4790, 3858, 4741, 3644, 3793, 3901, 
3779, 3820, 3680, 3455, 3896, 3621, 3449, 4013, 3417, 3752, 3546, 3466, 2947, 
3587, 3634, 4948, 3538, 3414, 3571, 3935, 3756, 4586, 3713, 4782, 3957, 3806, 
3717, 3574, 3811, 3849, 2880, 4219, 3038, 2831, 3138, 4918, 3485, 3300, 3456, 
3609, 3682, 4380, 3600, 3795, 3154, 4338, 3925, 3719, 2700, 3045, 3751, 3771, 
3457, 3794)
plot(walk_seconds, type="l", xaxt="n", xlab=" ", yaxt="n", ylab="Duration", 
col="blue")
abline  (v=1,   lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31),  lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29),   lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31),lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30), lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31),  lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30),   lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31),lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31+31), lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31+31+30),  lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31+31+30+31),   lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31+31+30+31+30),lty=4, lwd=1.0, 
col="grey60")
abline  (v=(1+31+29+31+30+31+30+31+31+30+31+30+31), lty=4, lwd=1.0, 
col="grey60")
axis(side=1, at=1,   cex.axis=1.0, 
label="1-1")
axis(side=1, at=(1+31),  cex.axis=1.0, 
label="2-1")
axis(side=1, at=(1+31+29),   cex.axis=1.0, 
label="3-1")
axis(side=1, at=(1+31+29+31),cex.axis=1.0, 
label="4-1")
axis(side=1, at=(1+31+29+31+30), cex.axis=1.0, 
label="5-1")
axis(side=1, at=(1+31+29+31+30+31),  cex.axis=1.0, 
label="6-1")
axis(side=1, at=(1+31+29+31+30+31+30),   cex.axis=1.0, 
label="7-1")
axis(side=1, at=(1+31+29+31+30+31+30+31),cex.axis=1.0, 
label="8-1")
axis(side=1, at=(1+31+29+31+30+31+30+31+31), cex.axis=1.0, 
label="9-1")
axis(side=1, at=(1+31+29+31+30+31+30+31+31+30),  cex.axis=1.0, 
label="10-1")
axis(side=1, at=(1+31+29+31+30+31+30+31+31+30+31),   cex.axis=1.0, 
label="11-1")
axis(side=1, at=(1+31+29+31+30+31+30+31+31+30+31+30),cex.axis=1.0, 
label="12-1")
axis(side=1, at=(1+31+29+31+30+31+30+31+31+30+31+30+31), cex.axis=1.0, 
label="1-1")
abline  

Re: [R] How to specify year-month-day for a plot

2020-12-18 Thread Gregory Coats via R-help
I need to be able to draw and label a vertical line, representing the date of 
some arbitrary event. The date of the first entry is 2013-11-29. How would I 
draw, and label a red vertical line at 2019-04-06? Greg

gcdf<-read.table(text="2013-11-29 19.175
2014-01-20 10.072
2014-02-12 10.241
2014-03-02 05.916
2014-03-15 05.942
2014-03-23 03.639
2014-04-06 08.283
2014-04-20 07.323
2014-05-11 09.807
2014-05-30 10.398
2014-06-15 13.949
2014-07-06 13.840
2014-07-18 07.906
2014-07-21 13.609
2014-08-03 17.316
2014-08-10 09.585
2014-08-24 16.022
2014-09-07 15.403
2014-09-21 14.880
2014-10-08 18.950
2014-10-24 18.185
2014-11-03 10.178
2014-11-09 07.438
2014-11-23 16.053
2014-12-07 12.896
2014-12-21 18.306
2015-01-05 16.580
2015-01-18 14.603
2015-01-25 08.192
2015-02-08 15.690
2015-02-16 08.677
2015-03-08 15.493
2015-03-22 16.065
2015-04-05 15.990
2015-04-19 19.076
2015-04-26 11.310
2015-05-03 09.243
2015-05-10 13.366
2015-05-17 11.191
2015-05-25 12.329
2015-05-31 08.324
2015-06-07 12.985
2015-06-15 12.605
2015-06-21 09.759
2015-06-28 14.906
2015-07-05 09.106
2015-07-12 11.306
2015-07-19 10.052
2015-07-26 08.845
2015-08-02 11.634
2015-08-09 07.718
2015-08-16 06.057
2015-08-23 08.341
2015-08-30 06.702
2015-09-07 05.972
2015-09-13 08.249
2015-09-20 05.758
2015-10-05 13.772
2015-10-19 14.144
2015-11-03 14.305
2015-11-13 09.932
2015-11-20 17.418
2015-12-06 13.529
2015-12-20 15.440
2016-01-03 10.573
2016-01-19 09.592
2016-02-25 12.664
2016-04-03 18.993
2016-05-01 16.869
2016-06-07 15.012
2016-06-23 07.549
2016-06-27 13.756
2016-08-07 18.581
2016-09-01 11.334
2016-09-30 11.327
2016-11-06 18.018
2016-11-27 14.597
2016-12-04 15.347
2016-12-23 09.243
2017-01-05 16.035
2017-02-07 13.219
2017-02-19 16.196
2017-03-12 07.436
2017-05-08 19.747
2017-06-29 19.503
2017-08-15 19.676
2017-09-08 15.558
2017-10-17 16.705
2017-12-06 14.876
2018-01-12 13.748
2018-03-15 19.139
2018-04-13 19.056
2018-05-20 17.756
2018-06-02 15.631
2018-06-17 14.049
2018-07-05 18.870
2018-07-22 16.654
2018-08-06 17.171
2018-08-26 20.139
2018-09-09 18.442
2018-09-26 18.646
2018-10-14 17.144
2018-11-02 19.508
2018-11-20 12.454
2018-12-04 09.355
2018-12-14 09.152
2019-01-11 10.998
2019-02-02 07.739
2019-02-19 09.891
2019-03-22 18.716
2019-04-30 18.880
2019-06-03 19.247
2019-07-07 18.289
2019-08-30 19.021
2019-09-29 15.892
2019-10-26 18.180
2019-11-17 17.693
2019-12-08 16.528
2020-01-05 15.973
2020-02-15 18.832
2020-03-10 17.392
2020-05-04 14.774
2020-06-21 19.248
2020-08-01 14.913
2020-08-27 15.226
2020-09-28 14.338
2020-11-09 18.777
2020-12-11 19.652",
header=FALSE,stringsAsFactors=FALSE,
col.names=c("date","gallons"))
gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d")
grid_dates<-as.Date(paste(2013:2021,1,1,sep="-"),"%Y-%m-%d")
plot   (gcdf$date, gcdf$gallons, ylab="Refueling Gallons", xlab="",type="b", 
col="blue", yaxt="n")
mtext  (side=3, line="+0", "2014 Toyota 4Runner")
abline (h=seq(4,20,by=2), lty=3)
abline (v=grid_dates, lty=4)
axis   (side=2, at=seq(4,20,by=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] How to specify year-month-day for a plot

2020-12-16 Thread Gregory Coats via R-help
I would like to be able to draw and label a vertical line, representing the 
date of some arbitrary event. The date of the first non-zero entry is 
2013-11-29. How would I draw and label a red vertical line at 2019-04-06? Greg

gcdf<-read.table(text="2013-11-29 00.000
2013-12-29 19.175
2014-01-20 10.072
2014-02-12 10.241
2014-03-02 05.916
2014-03-15 05.942
2014-03-23 03.639
2014-04-06 08.283
2014-04-20 07.323
2014-05-11 09.807
2014-05-30 10.398
2014-06-15 13.949
2014-07-06 13.840
2014-07-18 07.906
2014-07-21 13.609
2014-08-03 17.316
2014-08-10 09.585
2014-08-24 16.022
2014-09-07 15.403
2014-09-21 14.880
2014-10-08 18.950
2014-10-24 18.185
2014-11-03 10.178
2014-11-09 07.438
2014-11-23 16.053
2014-12-07 12.896
2014-12-21 18.306
2015-01-05 16.580
2015-01-18 14.603
2015-01-25 08.192
2015-02-08 15.690
2015-02-16 08.677
2015-03-08 15.493
2015-03-22 16.065
2015-04-05 15.990
2015-04-19 19.076
2015-04-26 11.310
2015-05-03 09.243
2015-05-10 13.366
2015-05-17 11.191
2015-05-25 12.329
2015-05-31 08.324
2015-06-07 12.985
2015-06-15 12.605
2015-06-21 09.759
2015-06-28 14.906
2015-07-05 09.106
2015-07-12 11.306
2015-07-19 10.052
2015-07-26 08.845
2015-08-02 11.634
2015-08-09 07.718
2015-08-16 06.057
2015-08-23 08.341
2015-08-30 06.702
2015-09-07 05.972
2015-09-13 08.249
2015-09-20 05.758
2015-10-05 13.772
2015-10-19 14.144
2015-11-03 14.305
2015-11-13 09.932
2015-11-20 17.418
2015-12-06 13.529
2015-12-20 15.440
2016-01-03 10.573
2016-01-19 09.592
2016-02-25 12.664
2016-04-03 18.993
2016-05-01 16.869
2016-06-07 15.012
2016-06-23 07.549
2016-06-27 13.756
2016-08-07 18.581
2016-09-01 11.334
2016-09-30 11.327
2016-11-06 18.018
2016-11-27 14.597
2016-12-04 15.347
2016-12-23 09.243
2017-01-05 16.035
2017-02-07 13.219
2017-02-19 16.196
2017-03-12 07.436
2017-05-08 19.747
2017-06-29 19.503
2017-08-15 19.676
2017-09-08 15.558
2017-10-17 16.705
2017-12-06 14.876
2018-01-12 13.748
2018-03-15 19.139
2018-04-13 19.056
2018-05-20 17.756
2018-06-02 15.631
2018-06-17 14.049
2018-07-05 18.870
2018-07-22 16.654
2018-08-06 17.171
2018-08-26 20.139
2018-09-09 18.442
2018-09-26 18.646
2018-10-14 17.144
2018-11-02 19.508
2018-11-20 12.454
2018-12-04 09.355
2018-12-14 09.152
2019-01-11 10.998
2019-02-02 07.739
2019-02-19 09.891
2019-03-22 18.716
2019-04-30 18.880
2019-06-03 19.247
2019-07-07 18.289
2019-08-30 19.021
2019-09-29 15.892
2019-10-26 18.180
2019-11-17 17.693
2019-12-08 16.528
2020-01-05 15.973
2020-02-15 18.832
2020-03-10 17.392
2020-05-04 14.774
2020-06-21 19.248
2020-08-01 14.913
2020-08-27 15.226
2020-09-28 14.338
2020-11-09 18.777
2020-12-11 19.652",
header=TRUE,stringsAsFactors=FALSE,
col.names=c("date","gallons"))
gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d")
grid_dates<-as.Date(paste(2013:2021,1,1,sep="-"),"%Y-%m-%d")
plot   (gcdf$date, gcdf$gallons, ylab="Refueling Gallons", xlab="",type="l", 
col="blue", yaxt="n")
mtext  (side=3, line="+0", "2014 Toyota 4Runner")
abline (h=seq(4,20,by=2), lty=3)
abline (v=grid_dates, lty=4)
axis   (side=2, at=seq(4,20,by=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] How to specify year-month-day for a plot

2020-12-16 Thread Gregory Coats via R-help
I added a zero initial entry to the data set. Greg
gcdf<-read.table(text="2013-11-29 00.000
2013-12-29 19.175
2014-01-20 10.072
2014-02-12 10.241
2014-03-02 05.916

> On Dec 16, 2020, at 12:32 PM, Gregory Coats via R-help  
> wrote:
> 
> Jim, Thank you!
> The data set begins
> gcdf<-read.table(text="2013-12-29 19.175
> 2014-01-20 10.072
> 2014-02-12 10.241
> I note that data begins in 2013. But the plot command does not show this 
> first entry in 2013, and instead shows the second data pair as the first data 
> pair. As a consequence, plot does not show the first data pair for 2013, and 
> begins in 2014.
> Greg
> 
>> On Dec 16, 2020, at 1:08 AM, Jim Lemon  wrote:
>> 
>> Hi Greg,
>> I think this does what you want:
>> 
>> gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d")
>> grid_dates<-as.Date(paste(2014:2020,1,1,sep="-"),"%Y-%m-%d")
>> plot(gcdf$date, gcdf$gallons, main="2014 Toyota 4Runner", xlab="Date",
>> ylab="Gallons",type="l",col="blue",yaxt="n")
>> abline(h=seq(4,20,by=2),lty=4)
>> abline(v=grid_dates,lty=4)
>> axis(side=2,at=seq(4,20,by=2))
>> 
>> Jim
>> 
>> On Wed, Dec 16, 2020 at 2:16 PM Gregory Coats  wrote:
>>> 
>>> Jim, Thanks for your help with R.
>>> Feeding into R the file R_plot_18.r yields for me, on my Mac, 
>>> R_plot_18.pdf. Success.
>>> I used abline to draw a horizontal background grid, and then used axis 
>>> label to identify the values represented by the horizontal dashed 
>>> background lines.
>>> abline (h=c(2,4,6,8,10,12,14,16,18,20,22,24), lty=4, lwd=1.0, col="grey60")
>>> Similarly, I would like to draw a dashed vertical background grid. But it 
>>> is unclear to me how to direct R to draw a vertical dashed background grid 
>>> because I am again baffled how to specify to R a date value such as 
>>> 2018-10-20 @18:00. I welcome your guidance.
>>> Greg
>>> 
>>> On Dec 13, 2020, at 10:58 PM, Jim Lemon  wrote:
>>> 
>>> Hi Gregory,
>>> 
>>> On Mon, Dec 14, 2020 at 12:34 PM Gregory Coats  wrote:
>>> 
>>> ...
>>> Is there a convenient way to tell R to interpret “2020-12-13” as a date?
>>> 
>>> Notice the as.Date command in the code I sent to you. this converts a
>>> string to a date with a resolution of one day. If you want a higher
>>> time resolution, use strptime or one of the other POSIX date
>>> conversion functions.
>>> 
>>> 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] How to specify year-month-day for a plot

2020-12-16 Thread Gregory Coats via R-help
Jim, Thank you!
The data set begins
gcdf<-read.table(text="2013-12-29 19.175
2014-01-20 10.072
2014-02-12 10.241
I note that data begins in 2013. But the plot command does not show this first 
entry in 2013, and instead shows the second data pair as the first data pair. 
As a consequence, plot does not show the first data pair for 2013, and begins 
in 2014.
Greg

> On Dec 16, 2020, at 1:08 AM, Jim Lemon  wrote:
> 
> Hi Greg,
> I think this does what you want:
> 
> gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d")
> grid_dates<-as.Date(paste(2014:2020,1,1,sep="-"),"%Y-%m-%d")
> plot(gcdf$date, gcdf$gallons, main="2014 Toyota 4Runner", xlab="Date",
> ylab="Gallons",type="l",col="blue",yaxt="n")
> abline(h=seq(4,20,by=2),lty=4)
> abline(v=grid_dates,lty=4)
> axis(side=2,at=seq(4,20,by=2))
> 
> Jim
> 
> On Wed, Dec 16, 2020 at 2:16 PM Gregory Coats  wrote:
>> 
>> Jim, Thanks for your help with R.
>> Feeding into R the file R_plot_18.r yields for me, on my Mac, R_plot_18.pdf. 
>> Success.
>> I used abline to draw a horizontal background grid, and then used axis label 
>> to identify the values represented by the horizontal dashed background lines.
>> abline (h=c(2,4,6,8,10,12,14,16,18,20,22,24), lty=4, lwd=1.0, col="grey60")
>> Similarly, I would like to draw a dashed vertical background grid. But it is 
>> unclear to me how to direct R to draw a vertical dashed background grid 
>> because I am again baffled how to specify to R a date value such as 
>> 2018-10-20 @18:00. I welcome your guidance.
>> Greg
>> 
>> On Dec 13, 2020, at 10:58 PM, Jim Lemon  wrote:
>> 
>> Hi Gregory,
>> 
>> On Mon, Dec 14, 2020 at 12:34 PM Gregory Coats  wrote:
>> 
>> ...
>> Is there a convenient way to tell R to interpret “2020-12-13” as a date?
>> 
>> Notice the as.Date command in the code I sent to you. this converts a
>> string to a date with a resolution of one day. If you want a higher
>> time resolution, use strptime or one of the other POSIX date
>> conversion functions.
>> 
>> 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] How to specify year-month-day for a plot

2020-12-13 Thread Gregory Coats via R-help
Hi Jim,
Thank you VERY much!
In what I tried, my values for the vertical Y were automatically understood by 
R.
But it appears that the string -mm-dd was NOT recognized by R as a date for 
the X axis, and gave a red error message.
My values for Year-Month-Day were NOT understood by R.
Is there a convenient way to tell R to interpret “2020-12-13” as a date?

data <- data.frame(
  day = as.Date("2020-02-15", "2020-03-10", "2020-05-04", "2020-06-21", 
"2020-08-01", "2020-08-27", "2020-09-28", "2020-11-09", "2020-12-11")
  value = (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, 14.338, 
18.777, 19.652))
p <- ggplot(data, aes(x=day, y=value))
  geom_line()
  xlab("X Label")
p
Error: unexpected symbol in:
"  day = as.Date("2020-02-15", "2020-03-10", "2020-05-04", "2020-06-21", 
"2020-08-01", "2020-08-27", "2020-09-28", "2020-11-09", "2020-12-11")
  value"

Greg Coats
gregco...@me.com
Reston, Virginia USA

> On Dec 13, 2020, at 5:42 PM, Jim Lemon  wrote:
> 
> Hi Gregory,
> Here's a start:
> 
> gcdf<-read.table(text="2020-01-05 15.973
> 2020-02-15 18.832
> 2020-03-10 17.392
> 2020-05-04 14.774
> 2020-06-21 19.248
> 2020-08-01 14.913
> 2020-08-27 15.226
> 2020-09-28 14.338
> 2020-11-09 18.777
> 2020-12-11 19.652",
> header=TRUE,stringsAsFactors=FALSE,
> col.names=c("date","gallons"))
> gcdf$date<-as.Date(gcdf$date,"%Y-%m-%d")
> plot(gcdf$date,gcdf$gallons,main="Gallons by date",
> xlab="Date",ylab="Gallons")
> 
> Jim
> 
> On Mon, Dec 14, 2020 at 9:33 AM Gregory Coats via R-help
>  wrote:
>> 
>> Starting with year-month-day, for the variable gallons, I can easily plot 
>> the variable gallons, while disregarding the date.
>> gallons <- c (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, 
>> 14.338, 18.777, 19.652)
>> plot (gallons, type="l", xlab="X label", ylab="Y label", col="blue”)
>> 
>> How do I direct R to plot the variable gallons, at the appropriate, 
>> irregularly-spaced places on the X axis, while paying attention to the 
>> year-month-day?
>> 
>> format = "%Y-%m-%d”
>> 2020-01-05 15.973
>> 2020-02-15 18.832
>> 2020-03-10 17.392
>> 2020-05-04 14.774
>> 2020-06-21 19.248
>> 2020-08-01 14.913
>> 2020-08-27 15.226
>> 2020-09-28 14.338
>> 2020-11-09 18.777
>> 2020-12-11 19.652
>>[[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.


[R] How to specify year-month-day for a plot

2020-12-13 Thread Gregory Coats via R-help
Starting with year-month-day, for the variable gallons, I can easily plot the 
variable gallons, while disregarding the date. 
gallons <- c (15.973, 18.832, 17.392, 14.774, 19.248, 14.913, 15.226, 14.338, 
18.777, 19.652)
plot (gallons, type="l", xlab="X label", ylab="Y label", col="blue”)

How do I direct R to plot the variable gallons, at the appropriate, 
irregularly-spaced places on the X axis, while paying attention to the 
year-month-day?

format = "%Y-%m-%d”
2020-01-05 15.973
2020-02-15 18.832
2020-03-10 17.392
2020-05-04 14.774
2020-06-21 19.248
2020-08-01 14.913
2020-08-27 15.226
2020-09-28 14.338
2020-11-09 18.777
2020-12-11 19.652
[[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] R Compied for Mac OS X

2020-06-25 Thread Gregory Coats via R-help
Today, I downloaded, and installed the June 6, 2020 version of R, from the CRAN 
official site at Carnegie Mellon University. Unfortunately, while the CMU 
compiled Mac OS X R application provides access to base R stat functions, like 
mean, it does not provide me with access to any of R’s more advanced functions 
like movavg, and ggplot.
>From where can I download a more complete R executable, compiled for Mac OS X?
Greg Coats

http://lib.stat.cmu.edu/R/CRAN/ 
Download R for (Mac) OS X
R-4.0.2.pkg (notarized and signed)
> version  
platform   x86_64-apple-darwin17.0 
arch   x86_64  
os darwin17.0  
system x86_64, darwin17.0  
status 
major  4   
minor  0.1 
year   2020
month  06  
day06  
svn rev78648   
language   R   
version.string R version 4.0.1 (2020-06-06)
nickname   See Things Now  
> mean
function (x, ...) 
UseMethod("mean")


> movavg
Error: object 'movavg' not found
> ggplot
Error: object 'ggplot' not found
>  
[[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
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 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 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 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.


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


[R] How to direct R to read commands from a text file

2015-10-30 Thread Gregory Coats
All of the R commands that I want to issue are in a text file that concludes 
with the R command quit (save = “yes”), and is called R_commands.txt. I can 
start R, and then manually issue
source (“R_commands.txt”).
But I would prefer to issue, from the bash command line, a one line command, 
directing R to start, execute all of the R commands in R_commands.txt, and then 
quit. How do I do that?
Greg Coats
__
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.