[R] ANY ONE HERE PLZ Urgent

Mark Sharp msharp at txbiomed.org
Fri Aug 29 04:31:25 CEST 2014


If you use the lubridate package, this is very easy.
See the help file for month() within lubridate for more examples.

library(lubridate)
x <- now()
month(x)
month(x, label = TRUE)
month(x, label = TRUE, abbr = FALSE)
as.character(month(x, label = TRUE, abbr = FALSE))

When you run the above your get the following.

> library(lubridate)
> x <- now()
> month(x)
[1] 8
> month(x, label = TRUE)
[1] Aug
Levels: Jan < Feb < Mar < Apr < May < Jun < Jul < Aug < Sep < Oct < Nov < Dec
> month(x, label = TRUE, abbr = FALSE)
[1] August
12 Levels: January < February < March < April < May < June < July < ... < December
> as.character(month(x, label = TRUE, abbr = FALSE))
[1] "August"

Mark

On Aug 28, 2014, at 5:33 AM, arun <smartpink111 at yahoo.com> wrote:

> Try:
>
> format(as.Date("05/07/2014", "%m/%d/%Y"), "%m")
> #[1] "05"
>
> #or
> strptime("05/07/2014", "%m/%d/%Y")$mon+1
> #[1] 5
>
>
>
> A.K.
>
>
> How to extract a Month from Date object?
>
> almost 13 peoples visited my Question with out replying in New to R , i have task yaar
>
>
>
> don't mind plz could you HELP ME
>
> How to extract a Month from Date object?
>
> as.month("05/07/2014", format = "%m")
>
> tried wityh this
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.


NOTICE:  This E-Mail (including attachments) is confidential and may be legally privileged.  It is covered by the Electronic Communications Privacy Act, 18 U.S.C.2510-2521.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution or copying of this communication is strictly prohibited.  Please reply to the sender that you have received this message in error, then delete it.



More information about the R-help mailing list