Issue when knitting R Markdown File - Variables not recognised
up vote 0 down vote favorite I'm having issues referencing the output of a group by statement in R when knitting a markdown file. When I refer the variable name of the output of a group_by and summarise statement, I get an error saying the variable doesn't exist. Below is a version of the code that works when run in R Studio but fails in R Markdown. DF1 <- data.frame(name = c("1", "1", "2", "2", "3", "1" ), s_id = c("ab", "ab", "cd", "ab", " bc", "ab"), t_id = c("12A", "12A", "12A", "14B", "14B", "14B")) breakdown <- DF1 %>% group_by(name, s_id) %>% summarise(count = n_distinct(t_id)) breakdown_v2 <- mutate(.data = breakdown, number_of_trips = ifelse (s_id == 'ab', (count*5), ifelse (s_id == 'cd', (count*2), (count*1)))) Something similar happened to me...