[R] Using R lines() to show sunrise and sunset

Ebert,Timothy Aaron tebert @end|ng |rom u||@edu
Tue Jul 19 02:31:53 CEST 2022


Make a dummy variable using an if test. Ifelse(as.numeric(hour(time))<11,df$rise=0,df$rise=1)
Then you could use filter() to split the dataset into two parts, or you could use pivot_wider().
Tim

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Gregory Coats via R-help
Sent: Monday, July 18, 2022 8:18 PM
To: David Winsemius <dwinsemius using comcast.net>
Cc: Gregory Coats via R-help <r-help using r-project.org>
Subject: Re: [R] Using R lines() to show sunrise and sunset

[External Email]

Thanks. Yes, I can follow
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.stat.berkeley.edu_-7Es133_dates.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=cc9Eq3DGpCl6kcfJbKVLDsJ9i6TKk7SF79PHaRy8-GoQctAlVTXhQIVEHHwO08Q8&s=ym6pjfQa0pw3I4kXT4_gM3iUDXXy52lWTJkwCbXi2NM&e=
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?
Greg Coats
571-423-9847

> 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 
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mai
>> lman_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVe
>> AsRzsn7AkP-g&m=cc9Eq3DGpCl6kcfJbKVLDsJ9i6TKk7SF79PHaRy8-GoQctAlVTXhQI
>> VEHHwO08Q8&s=7qZYIyeP1-uuz3co5hy-m-ZI7YGOslQI_-_I89eoJ5I&e=
>> PLEASE do read the posting guide 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.o
>> rg_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kV
>> eAsRzsn7AkP-g&m=cc9Eq3DGpCl6kcfJbKVLDsJ9i6TKk7SF79PHaRy8-GoQctAlVTXhQ
>> IVEHHwO08Q8&s=EZBJpqiZa4ZdtRdgor6WYiCsrheRBMsp1O31mCpoHPU&e=
>> 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 https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=cc9Eq3DGpCl6kcfJbKVLDsJ9i6TKk7SF79PHaRy8-GoQctAlVTXhQIVEHHwO08Q8&s=7qZYIyeP1-uuz3co5hy-m-ZI7YGOslQI_-_I89eoJ5I&e=
PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwIFaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=cc9Eq3DGpCl6kcfJbKVLDsJ9i6TKk7SF79PHaRy8-GoQctAlVTXhQIVEHHwO08Q8&s=EZBJpqiZa4ZdtRdgor6WYiCsrheRBMsp1O31mCpoHPU&e=
and provide commented, minimal, self-contained, reproducible code.


More information about the R-help mailing list