Choosing specific Date Range from non-sequential Date: Problem Fixed
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<-read.table("MOSC",colClasses=c("Date","numeric")) and tried:
Year <- subset(d1, d1[[1]] > "1998-01-01" & d1[[1]] < "2006-01-01")
and arrived at my goal.
Thank you for the hint.
Best regards
Ogbos
On Mon, Sep 9, 2019 at 8:22 PM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
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 reprex package to verify that your example is reproducible. On September 9, 2019 12:14:50 PM PDT, Ogbos Okike <giftedlife2014 at gmail.com> wrote:
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-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.06826431469008 1998-04-19 -2.49834620746286 1998-05-02 -6.4357083781542 1998-05-17 -2.25359807972754 1998-05-21 -2.55799006865995 1999-08-22 -2.25114162617707 1999-08-25 -1.47905397376409 1999-09-05 -0.641589808755325 1999-09-09 -0.648954682695949 1999-09-13 -0.726364489272492 1999-09-16 -1.28445236942011 The first column is date and the second is another data of interest. The date is long but note sequential. Runs randomly from 1953 to 2019. I would like to select any range of date from year A to year B. Thank you again for your help. Best Ogbos On Mon, Sep 9, 2019 at 6:18 PM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:
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
<bgunter.4567 at gmail.com> 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 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 coming
along
and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Sep 9, 2019 at 8:55 AM Ogbos Okike
<giftedlife2014 at gmail.com>
wrote:
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.06826431469008 1998-04-19 -2.49834620746286 1998-05-02 -6.4357083781542 1998-05-17 -2.25359807972754 1998-05-21 -2.55799006865995 1999-08-22 -2.25114162617707 1999-08-25 -1.47905397376409 1999-09-05 -0.641589808755325 1999-09-09 -0.648954682695949 1999-09-13 -0.726364489272492 1999-09-16 -1.28445236942011 The events happen randomly and so the date is non-sequential. It
run
form
1953 to 2019. I would like to select all the events/dates between 1998 to 2005. One of the things I tried is: Year <- subset(MOSCFD50, date > "1998-01-01" & date <
"2005-12-31").
But it didn't work.
I would be thankful if you could please redirect me.
Thank you very much.
Best regards
Ogbos
[[alternative HTML version deleted]]
______________________________________________ R-help at 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 at 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.
-- Sent from my phone. Please excuse my brevity.