Hello all everyone,
I am learning about R studio and doing one case study. (this case study is the final lesson of the learning program before receiving the certificate for the junior data analyst). With one raw table data 44.4 MB, please look at the screenshot with the first 15 rows.
I wrote on the scrip at R studio with function dmy_hm -> I tried to convert all rows of the column "ActivityMinute" from string into numeric. But I failed.
I tried change the format setting for the whole column "ActivityMinute" with the script:
format(minuteStepsNarrow_merged$ActivityMinute, format = "%b/%d/%Y %I:%M %p")
result: R system runs well. However, the data type is still class as string-character.
the final goal try to reach: separating the original column "ActivityMinute" into 2 columns which are "date" and "time" with the correspondent component. for example: the column "date" should be the numeric type and print as "4/12/2016". the column "time" should be the numeric and print as "12:09:00 AM **
So far, I write the script: minuteStepsNarrow_merged$date <- as.Date(minuteStepsNarrow_merged$ActivityMinute)
And then hit "run" . next, R system performs the job -> I use the function class() to check the data type -> R system shows it is date type -> this column "date" is done as I want.
Move to the leftover column "time".
I did try the separate() function with the script
minuteStepNarrow_merged <- separate( minuteStepNarrow_merge,
col = “ActivityMinute” ,
into = c( “date”, “time”),
sep = “ “)
the result was NAs for the whole column "time"
I also tried format() function plus the class as.POSIXct() function. the result was not like I expected. I wrote the script as minuteStepsNarrow_merged$time <- format(as.POSIXct(minuteStepsNarrow_merged$ActivityMinute), format = "% %I:%M %p")
I spent near 10 hours search in Google also visit a few websites from other data scientists. However, I still get struck with the column "time".
Please help me inspect my process and guide me to the solution.