how to return the date with only the day in it in r
format(as.Date(df$x,format="%Y-%m-%d"), format = "%d")
# or
format(df_meas$Time, format= %d")
# where df_meas$Time is of as.POSIXlt class
how to return the date with only the day in it in r
format(as.Date(df$x,format="%Y-%m-%d"), format = "%d")
# or
format(df_meas$Time, format= %d")
# where df_meas$Time is of as.POSIXlt class
extract year from date in r
#create data frame
df <- data.frame(date=c("02/10/2021", "03/07/2020" , "14/03/2021"),
sales=c(21, 36, 38))
#view data frame
df
date sales
1 02/10/2021 21
2 03/07/2020 36
3 14/03/2021 38
#create new variable that contains year
df$year <- format(as.Date(df$date, format="%d/%m/%Y"),"%Y")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us