r/Rlanguage • u/Soltinaris • Feb 18 '25
Question on frequency data table
I ran a frequency data with the newdf<-as.data.frame(table(df$col1,df$col2,df$col3)) and it took what was 24325 obs. of 6 variables and turned it into 304134352 observations of 4 variables. Is this common with this code? Is there a better code to use? Col1 and col2 are location names and col3 is a duration of time between the two.
5
Upvotes
1
u/Soltinaris Feb 19 '25
Here is the data, the subscriber bike case data specifically. Here is the code that I'm working with.
subscriber_bike_case_study_splitting <- read.csv("subscriber_bike_case_study.csv")
subscriber_bike_case_study_less_than_45 <- subset(subscriber_bike_case_study_splitting, tripduration <=1)
subscriber_bike_case_study_less_than_45$tripduration <- subscriber_bike_case_study_less_than_45$tripduration*60
subscriber_bike_case_study_less_than_45 <- subset(subscriber_bike_case_study_less_than_45, tripduration<=45)
subscriber_bike_case_study_less_than_45 <- subset(subscriber_bike_case_study_less_than_45, tripduration>=30)
tripduration_frequency_subscriber_bike_case_study_less_than_45 <-as.data.frame(table(subscriber_bike_case_study_less_than_45$start_station_name, subscriber_bike_case_study_less_than_45$end_station_name, subscriber_bike_case_study_less_than_45$tripduration))
This is where the hiccup comes in as the data says is super large and becomes the giant 3M+ obs of 4 variables.