简体   繁体   中英

Convert days to calendar dates within a data frame in R

I have a dataframe like

ID |TRTSDT| TRTEDT
101|17952 | 18037
102|17956 | 18041

How can i convert the days into Date format...Thank you

Try

df1[-1] <- lapply(df1[-1], as.Date, origin='1970-01-01')

data

df1 <- structure(list(ID = 101:102, TRTSDT = c(17952L, 17956L),
TRTEDT = c(18037L, 
18041L)), .Names = c("ID", "TRTSDT", "TRTEDT"), class = "data.frame", 
row.names = c(NA, -2L))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM