[R] Help Converting Calendars
Jeff Reichman
reichmanj at sbcglobal.net
Thu Nov 9 00:05:13 CET 2017
R-Help
Trying to convert a Gregorian calendar dataset to a Persian calendar
dataset. But I end up with a list and not sure what to do. For example ...
dates <- c("2017-10-1","2017-10-2","2017-10-3")
myData <- data.frame(dates)
myData$dates <- as.Date(myData$dates, format = "%Y-%m-%d")
> myData
dates
1 2017-10-01
2 2017-10-02
3 2017-10-03
library(ConvCalendar)
p.dates <- as.OtherDate(myData$dates,"persian")
# after convering I get the following list
> p.dates
$day
[1] 9 10 11
$month
[1] 7 7 7
$year
[1] 1396 1396 1396
attr(,"row.names")
[1] 1 2 3
attr(,"class")
[1] "OtherDate"
attr(,"calendar")
[1] "persian"
How do I take that, to end up with
dates p_dates
1 2017-10-01 1396-7-9
2 2017-10-02 1396-7-10
3 2017-10-03 1396-7-11
Jeff Reichman
Penn State
More information about the R-help
mailing list