[R] Using R lines() to show sunrise and sunset
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Tue Jul 19 03:26:59 CEST 2022
a) Wouldn't distinguishing between sunrise and sunset just amount to referring to the relevant column in your data frame? Why is this a problem you need help with?
b) There is no problem with plotting datetimes in R. But you might want to consider plotting hour-of-day instead on the y axis to avoid the monotonocally increasing appearance you would end up with. R does not have a concept of time-of-day separate from date, due to different days having different numbers of hours in them. To compute hour-of-day subtract the beginning of day (use trunc.POSIXt, units = "days") from the actual time and convert the resulting difftime to numeric.
3) General challenges with formulating a response: I can't tell what to do with your command lines, and your use of formatted email is mushing stuff together. You have been vague about what inputs you have (have you imported the data?) or what kind of plot you expect to get using the lines function. (Also I avoid base R plotting functions most of the time, so I tend to sit out on threads that are looking for help with it.)
On July 18, 2022 5:17:51 PM PDT, Gregory Coats via R-help <r-help using r-project.org> wrote:
>Thanks. Yes, I can follow
>Dates and Times in R
>But my problem is, How to direct R to accept the first computed value as a sunrise, and the second computed values as a sunset?
>> On Jul 18, 2022, at 7:58 PM, David Winsemius <dwinsemius using comcast.net> wrote:
>> The first thought it to do is make sure you have the data in POSIXct format for the date times.
>> Sent from my iPhone
>>> On Jul 18, 2022, at 6:51 PM, Gregory Coats via R-help <r-help using r-project.org> wrote:
>>> I compiled a program on my Apple MacBook that takes as inputs
>>> Year and Month and Day
>>> Latitude and Longitude
>>> And then computes these two outputs
>>> Sunrise Year-Month-Day Hour:Minute:Second
>>> Sunset Year-Month-Day Hour:Minute:Second
>>> It automatically handles Daylight Savings Time.
>>> A typical input, followed by the automatically computed outputs looks likes this.
>>> ./sunrise_05 2022 01 1 38.8586314239524 77.0512533684194
>>> 2022-01-01 07:26:45 2022-01-01 16:57:07
>>> ./sunrise_05 2022 01 2 38.8586314239524 77.0512533684194
>>> 2022-01-02 07:26:52 2022-01-02 16:57:56
>>> I want to use R’s lines() command to show the sunrise and sunset times for the year 2012. How do I tell R that the first computed output is sunrise, and the second computer output is sunset?
>>> Greg Coats
>>> [[alternative HTML version deleted]]
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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 using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
More information about the R-help