EXPORT SUMMARY FILE FOR FURTHER ANALYSIS using PC

I am trying to create a csv file by on a PC. I have tried a few codes, but it is not coming together. I am new to RStudio. Below is the code and error message. Please help

Data_Frame <- aggregate(all_trips_v2$ride_length ~ all_trips_v2$member_casual + all_trips_v2$day_of_week, FUN = mean)

write.csv(df, file = 'C:/Users/Sabri/OneDrive/Desktop/final/avg_ride_length.csv')

Error in as.data.frame.default(x[[i]], optional = TRUE) :
cannot coerce class ‘"function"’ to a data.frame

The object returned by aggregate is named Data_Frame. If you want to export that, use

write.csv(Data_Frame, file = 'C:/Users/Sabri/OneDrive/Desktop/final/avg_ride_length.csv')

There is a function named df and R thinks you are trying write that to a csv. That is why the error message says "cannot coerce class ‘"function"’ to a data.frame"