Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear All, Many thanks for all your contributions, suggestions and advice. I find them all useful. Best wishes Ogbos On Mon, Sep 9, 2019 at 9:35 PM Rui Barradas wrote: > > Hello, > > I cannot reproduce the error but I coerce to class "Date" first. > > > MOSCFD50[[1]] <- as.Date(MOSCFD50[[1]]) > na

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Rui Barradas
Hello, I cannot reproduce the error but I coerce to class "Date" first. MOSCFD50[[1]] <- as.Date(MOSCFD50[[1]]) names(MOSCFD50) <- c("date", "value") # Your subset Year <- subset(MOSCFD50, date > "1998-01-01" & date < "2005-12-31") # Another way, if there are NA's, use which(i) i <- MOSCFD50$

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread William Dunlap via R-help
To get a quick answer to your question you should provide a smallexample that one can simply copy and paste into an R session. It also helps to show some details about how something does not work, more than " But it didn't work." E.g., d <- read.table(header=FALSE, text="1997-11-23 -2.917096290

[R] Choosing specific Date Range from non-sequential Date: Problem Fixed

2019-09-09 Thread Ogbos Okike
Dear Bert and Jeff, The result is an output of another code and it will be too long or unnecessary to show all I'm I did to arrive at the given data frame. Since my single line code works for Jeff, I had to take a second look and try to get it working for me. I then read the data frame using d<-re

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Jeff Newmiller
Works for me. Apparently you are not showing us everything you are doing. As Bert recommended, you need to use the dput function rather than dumping numbers into the email if we are to know how your data are stored in memory which will affect what results you get. I highly recommend using the re

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear Bert and Jeff, Thank you for looking at this. I am surprised my message was not in plain text. It has been configured to send message to the list in plain text earlier before. The data again please. 1997-11-23 -2.91709629064653 1997-12-07 -0.960255426066815 1997-12-11 -1.98210752999868 1997-

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Jeff Newmiller
Or the column is not named "date", or it is a factor... and the question is not posted in plain text On September 9, 2019 9:55:48 AM PDT, Bert Gunter wrote: >I would guess that you first need to convert your textual dates to a >date-time object via as.date, but as you failed to provide a >re

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Bert Gunter
I would guess that you first need to convert your textual dates to a date-time object via as.date, but as you failed to provide a reproducible example (e.g. via dput) I may be wrong. Maybe others may have greater insight. Bert Gunter "The trouble with having an open mind is that people keep comin

[R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear Contributors, I have a data frame of the form: 1997-11-23 -2.91709629064653 1997-12-07 -0.960255426066815 1997-12-11 -1.98210752999868 1997-12-20 -1.10800598439855 1998-01-01 -1.00090115428118 1998-01-29 -1.03056081882709 1998-03-27 -0.873243859498216 1998-04-09 -2.06378384750109 1998-04-12 -2