Re: [R] Date and Time
On 7/17/2022 8:47 PM, Gregory Coats via R-help wrote: For the year from 2022-01-01 to 2022-12-31, I computed the sunrise and sunset times for Reston, Virginia, USA. I am seeking the syntax to direct R to read in these dates and times, and then graphical plot the sunrise and sunset times for each day in the year 2022. How do I tell R that I store the Sunrise Date and Time like this? -mm-dd HH:MM:SS 2022-01-01 7:28:10 2022-01-02 7:28:17 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. Here is one way using the strptime function, > in_dt_str <- '2022-01-01 7:28:10' > dt <- strptime(in_dt_str,'%Y-%m-%d %H:%M:%S') if the date and time are stored in different variables then paste them together before converting > in_dt <- '2022-01-01' > in_tm <- '7:28:10' > dtm <- strptime(paste(in_dt, in_tm, sep=' '),'%Y-%m-%d %H:%M:%S') Hope this is helpful, Dan -- Daniel Nordlund Port Townsend, WA USA -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus __ 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] Date and Time
Maybe this [1] will help? Or just read ?strptime... You can also calculate sunrise/sunset (crepuscule) using maptools, but you need to be careful with timezones. [1] https://jdnewmil.github.io/time-2018-10/MoreDatetimeHowto.html On July 17, 2022 8:47:19 PM PDT, Gregory Coats via R-help wrote: >For the year from 2022-01-01 to 2022-12-31, I computed the sunrise and sunset >times for Reston, Virginia, USA. I am seeking the syntax to direct R to read >in these dates and times, and then graphical plot the sunrise and sunset times >for each day in the year 2022. How do I tell R that I store the Sunrise Date >and Time like this? >-mm-dd HH:MM:SS >2022-01-01 7:28:10 >2022-01-02 7:28:17 >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. -- 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.
[R] Extract time and state of charge (Start and End) and Count
Dear all, I have data of Battery Electric vehicle (BEV). I would like to extract data from every hour starting from 0.00 to 0.59, 1:00-1:59 for SOC(state of charge) start to end. Some examples: I can extract data from SOC=0 and SOC=12 dt_2014[which(dt_2014$Starting_SoC_of_12==0 & dt_2014$Ending_SoC_of_12==12),] I can extract data from SOC=1 and SOC=12 dt_2014[which(dt_2014$Starting_SoC_of_12==1 & dt_2014$Ending_SoC_of_12==12),] and I would like to further categorise the data by hour and count how many cars from 0 state charge to 12 state charge at in that particular hour. Thank you so much for any help given. Some data > dput(dt_2014[1:10,]) structure(list(ï..CarID = c("GC10", "GC10", "GC10", "GC10", "GC10", "GC10", "GC10", "GC10", "GC10", "GC10"), BatteryChargeStartDate = c("16/2/2014 16:05", "16/2/2014 18:20", "17/2/2014 8:10", "18/2/2014 7:41", "18/2/2014 15:36", "18/2/2014 16:36", "18/2/2014 21:26", "19/2/2014 8:57", "19/2/2014 21:08", "20/2/2014 18:11"), BCStartTime = c("16:05", "18:20", "8:10", "7:41", "15:36", "16:36", "21:26", "8:57", "21:08", "18:11"), Year = c(2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L), Month = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Day = c(16L, 16L, 17L, 18L, 18L, 18L, 18L, 19L, 19L, 20L), BatteryChargeStopDate = c("16/2/2014 17:05", "16/2/2014 19:00", "17/2/2014 15:57", "18/2/2014 9:52", "18/2/2014 15:39", "18/2/2014 17:36", "19/2/2014 1:55", "19/2/2014 14:25", "20/2/2014 5:17", "20/2/2014 23:20" ), BCStopTime = c("17:05", "19:00", "15:57", "9:52", "15:39", "17:36", "1:55", "14:25", "5:17", "23:20"), Year2 = c(2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L ), Month2 = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Day2 = c(16L, 16L, 17L, 18L, 18L, 18L, 19L, 19L, 20L, 20L), Starting_SoC_of_12 = c(1L, 2L, 4L, 5L, 4L, 2L, 8L, 8L, 4L, 8L), Ending_SoC_of_12 = c(11L, 11L, 12L, 8L, 4L, 10L, 12L, 12L, 12L, 12L)), row.names = c(NA, 10L), class = "data.frame") -- *Roslinazairimah Zakaria* *Tel: +609-5492370; Fax. No.+609-5492766* *Email: roslina...@gmail.com * University Malaysia Pahang Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia [[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 reduce the (whitespace) gap between boxplots
Make your xlim values narrower, as I showed you! Alternatively, you could also us the "boxwex" parameter passed to bxp() like this: boxplot(RF,Ranger, SVM, KNN, DT, range = 0, col=colors, at = seq(1:5), boxwex = .5, names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency with default and optimized settings") -- Bert On Sun, Jul 17, 2022 at 1:33 PM Neha gupta wrote: > > Thank you so much. > > When I modify this, like the following > > xlim = c(.2,4.2), > > The spaces between boxplots are reduced but the main box (the container) > remains the same which still takes space. Can I reduce the size of the main > box (which contains all the boxplots) to take less space. > > > > On Sun, Jul 17, 2022 at 10:25 PM Bert Gunter wrote: >> >> 1. Typo: should be "KNN = (your data)" -- not "knn" >> >> You specified at.x, but failed to use it. You need to specify the >> "at" parameter of boxplot() and probably also "xlim" (which is passed >> down to bxp(), the function that actually draws the plot). >> >> e.g. >> >> boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors, >> at = seq(1,3,by = .5), xlim = c(.8,3.2), >> names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of >> consistency >> with default and optimized settings") >> >> Modify to your taste. >> >> Cheers, >> Bert >> >> On Sun, Jul 17, 2022 at 12:06 PM Neha gupta wrote: >> > >> > Hi >> > >> > I have the following code to display boxplots. The problem is it has a wide >> > space (gap) between them which takes a lot of space on paper. How can I >> > reduce the size so that it takes less time in a word document. >> > >> > RF= c(81.8, 81.8, 42.8, 42.8, 100, 53.8) >> > Ranger= c(66.6, 81.8, 81.8, 33.3, 81.8, 53.8) >> > SVM= c(81.8, 66.6, 81.8, 53.8, 81.8, 66.6 ) >> > knn= c(17.64, 33.33, 42.8, 25, 53.84, 17.64) >> > DT= c(33.3 , 66.6, 33.3, 66.6, 33.3, 25) >> > >> > >> > colors = rep("green",6) >> > at.x <- seq(1,by=.4, length.out = 10) >> > boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors, >> > names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency >> > with default and optimized settings") >> > >> > [[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] How to reduce the (whitespace) gap between boxplots
Thank you so much. When I modify this, like the following xlim = c(.2,4.2), The spaces between boxplots are reduced but the main box (the container) remains the same which still takes space. Can I reduce the size of the main box (which contains all the boxplots) to take less space. On Sun, Jul 17, 2022 at 10:25 PM Bert Gunter wrote: > 1. Typo: should be "KNN = (your data)" -- not "knn" > > You specified at.x, but failed to use it. You need to specify the > "at" parameter of boxplot() and probably also "xlim" (which is passed > down to bxp(), the function that actually draws the plot). > > e.g. > > boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors, > at = seq(1,3,by = .5), xlim = c(.8,3.2), > names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of > consistency > with default and optimized settings") > > Modify to your taste. > > Cheers, > Bert > > On Sun, Jul 17, 2022 at 12:06 PM Neha gupta > wrote: > > > > Hi > > > > I have the following code to display boxplots. The problem is it has a > wide > > space (gap) between them which takes a lot of space on paper. How can I > > reduce the size so that it takes less time in a word document. > > > > RF= c(81.8, 81.8, 42.8, 42.8, 100, 53.8) > > Ranger= c(66.6, 81.8, 81.8, 33.3, 81.8, 53.8) > > SVM= c(81.8, 66.6, 81.8, 53.8, 81.8, 66.6 ) > > knn= c(17.64, 33.33, 42.8, 25, 53.84, 17.64) > > DT= c(33.3 , 66.6, 33.3, 66.6, 33.3, 25) > > > > > > colors = rep("green",6) > > at.x <- seq(1,by=.4, length.out = 10) > > boxplot(RF,Ranger, SVM, KNN, DT, range = 0, boxwex = 0.2, col=colors, > > names= c("RF","Ranger", "SVM", "KNN", "DT"),main="Degree of consistency > > with default and optimized settings") > > > > [[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.