I want to set the day of month in a Date
to start date of current month (01
).
Now I use the following:
currentDate <- Sys.Date() #for getting current system date eg:2012-11-06
formatDate <- format(currentDate, "%Y-%m") #it return 2012-11
startDate <- as.Date(paste(formatDate, "-01", sep = ""))
# 2012-11-01
Is there any easy way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…