Re: [R] Converting Character date to Dates in r
Hi Admire, Your attachment didn't get through, although CSV format should. The code you included seems a very roundabout way to extract a series of dates as character strings and as there is no assignment of return values in some lines, is unlikely to work. Perhaps if you send just a few of the original strings, someone can answer your question. Jim On Thu, Sep 29, 2022 at 4:02 AM Admire Tarisirayi Chirume wrote: > > 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: addtar...@icloud.com/tchir...@rbz.co.zw > Skype: admirechirume > Call: +263773369884 > whatsapp: +818099861504 > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting Character date to Dates in r
Hello, Can you post sample data? Please post the output of dput(head(inflation.2$period)) Hope this helps, Rui Barradas Às 18:42 de 28/09/2022, Admire Tarisirayi Chirume escreveu: 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: addtar...@icloud.com/tchir...@rbz.co.zw Skype: admirechirume Call: +263773369884 whatsapp: +818099861504 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting Character date to Dates in r
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: addtar...@icloud.com/tchir...@rbz.co.zw Skype: admirechirume Call: +263773369884 whatsapp: +818099861504 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.