2
$\begingroup$

Using r if I have a data frame that contains dates and temperatures.

I would like to pull out all temperatures for January how would I go about

phrasing this. I've tried may ways such as

louisville_weather <- filter(louisville_weather$DATE <= 2013-01-31)
$\endgroup$
3
  • $\begingroup$ I think stackoverflow.com would be more appropriate for your question, as this is rather a coding issue rather than a Data Science question. $\endgroup$
    – Partha D.
    Jan 5 '19 at 12:17
  • $\begingroup$ Hey friend, r programming is for data science. Where is the best place to find fast answers: of course the data science stack exchange! $\endgroup$
    – Chris Kehl
    Jan 6 '19 at 11:52
  • $\begingroup$ Sorry @Chris Kehl if you have misunderstood me. Not that it's an incorrect or inappropriate post, but you might get more peers and hence quicker (and possibly more varied) answers on stackoverflow. Particularly since people don't have to know data science in order to answer this particular question-- but knowledge in R would be fine. However then, I would have missed the chance of answering it (and getting kudos) since someone else must surely have posted a good enough answer before me ! Thanks, anyway, dear friend. $\endgroup$
    – Partha D.
    Jan 6 '19 at 14:05
2
$\begingroup$

If louisville_weather$DATE is formatted as POSIXct, the month can be extracted, thanks @RockScience, with

lvmonth <- format(louisville_weather$DATE, "%m")

It's a character variable. So, filtering

louisville_weather <- louisville_weather[lvmonth == "01", ]

should extract your weather for January.

Hope you'll find it cold enough to balance the warmth of datascience.SX !

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.