[R] Converting Character date to Dates in r
Admire Tarisirayi Chirume
@tch|rume @end|ng |rom gm@||@com
Wed Sep 28 19:42:06 CEST 2022
Hello, i hope this email finds you well. Kindly help me to format dates
shown as character to dates using as.Dates.
Attached herewith is my data in excel csv format.
The following is the r-code i have used in my analysis:
setwd("Z:/2022/September/Inflation forecasts")
inflation<-read.csv("Inflation_forecasts_1.csv")
attach(inflation)
inflation[,1:2 ] #subsetting the dataframe
inflation.df<-inflation[,1:2]
attach(inflation.df)
#Renaming variables
inflation<- rename(inflation.df,
cpi = CPI,
year=period)
#subsetting data April 2020 to current
inflation.2<-data.frame(inflation[-c(1:135),])
####Defining variables for use in the analysis
attach(inflation.2)
t <- year
class(inflation.2$cpi)
inflation.2$cpi <- as.numeric(as.character(inflation.2$cpi))
Y <- cpi
sapply(inflation.2, class)
format(as.Date(inflation.2$period), "%Y-%m")
Thank you in advance.
Admire
Alternative email: addtarris using icloud.com/TChirume using rbz.co.zw
Skype: admirechirume
Call: +263773369884
whatsapp: +818099861504
More information about the R-help
mailing list