I have a DF called data that has multiple columns. One of them is a column called 'swim_hours' that is a column of integers. I want to use dyplr to do some manipulations on this DF, but I also want to keep this column intact, though I am not manipulating it in any way. My code is as follows:
trial_swim = data %>%
group_by(penguin, date, trial, location) %>%
summarise(swim_t = as.numeric(datetime[n()] - datetime[1])) %>%
summarise(hours = swim_hours)
Again, the purpose of the last line is to simply maintain my 'swim_hours' column into my new DF 'trial_swim'.
When I run this, I get the error message: Error in summarise_impl(.data, dots) : Evaluation error: object 'swim_hour' not found.
Clearly 'swim_hours' is in my 'data' DF, why can't it find it?
Is there an easier way to keep a column that is not being manipulated when using dyplr and pipes??