Creating New Data Frame

I am trying to create a sub-dataframe using R so that I can use it for analysis.

start_station_frequency <- all_trips_v2 %>%
        select(start_station_name, start_station_id) %>%

However, when I run the above code, the resulting data frame only shows 2 variables (start_station_name and frequency, which is the count). What should I write so that the corresponding start_station_id will also be shown?


Just add it to the count-function. Here's a toy example. Be aware that the first argument is used as grouping-information.


(Df <- data.frame(name = c(LETTERS[1:6], 'C' ), 
ID =c(1:6, 3)))

Df %>% count(ID, name)

Hope this helps.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.