activity <- activity %>%
rename( date = "activity_date") %>%
mutate(date = as.Date(date, format = "%m/%d/%Y"))
head(activity)
I run this code. activity is name assigned to the dailyActivity_merged.csv file in the Fitbit bellabeat dataset.
I was working with the Bellabeat dataset but the format function was not working in the function. Please help me where is the mistake.
The dataset is available on Kaggle.
as.Date is for going from character to date, the format is a way to specify the way the character representation looks from which to build the standard date. In R the date class on which calculations can be made is printed in a standard format.
Its important to distinguish between calculation and reporting. Just as we want to use numerics for calculation and high precision, we often want to print them ina report to a fixed precision. Similarly for a date. If we want to represent the date a particular way in a report then we format them into a character representation.
The question is therefore; is your goal at this stage to calculate, or are you ready to produce a report ?
I am at the calculative stage. Thanks for this guidance. It was helpful.
And if i were at the report stage, how would it have been done to generate the same format date printing in all tables of the dataset?
Please help.
thanks a lot.