Hello there, I am fairly new to R programming and am trying to complete a project for my course. I am trying to use the summary() function to give me my min, max, etc. but it isn't working. Instead of giving me regular min, 1st Qu, median, etc., it only tells me length, class, and mode. I'm aware that this is because it's not in numeric order, but I already changed my data frame using as.numeric(). It displays that mode is numeric, but my class is difftime. How can I change my class, or why is the summary function not working?
# Using the is.factor() function and told false. Proceeded to change character to numeric and when I ran the is.numeric() function afterward, is displayed True.
is.factor(Annual_trip_data$ride_length)
Annual_trip_data$ride_length <- as.numeric(as.character(Annual_trip_data$ride_length))
is.numeric(Annual_trip_data$ride_length)
Hey there William, I can try. I'm new to using R studio, if I am able to share files to do what I'm trying then I can reproduce my code. I had to get ride length by using difftime between two variables that I had to convert into date and time using ymd_hms. And the string for those two variables became posixct. When I use str(), ride length is classified as 'difftime' num
hey there william, I actually did create a reproduction of the same issue I can into. I'm trying to get the summary of the ride_length but only get class and mode rather than mean, min, max, etc. Here's the following code:
I appreciate that but I made up those tables. When I try to run that same code, it tells me that the data vectors have to be the same size for tibble to work. I am going to try and look at it tomorrow. I tried running as.vector(as.character(trip_data$ride_length)) and then ran is.numeric() afterward and got True but I don't know. Thank you for your help!
data_table$ride_length <- lubridate::as.duration(difftime(data_table$end_time,data_table$start_time, units = "secs"))
I didnt see that you used any packages/libraries apart from lubridate, so assuming you want to transition to using tidyverse I've reproduced the code in your post in a more tidyverse way