Chris Ewanik
Chris Ewanik

Reputation: 69

round() Error in function_list[[i]](value) : object not found in R

After a decent break from working with R, I am encountering an issue. Currently, I am working with a data frame with two columns. My goal is to round the first column fheight to then filter and selectively add both fheight and sheight to a new data frame if it is equal to 71. When I add the round() function I receive the error Error in function_list[[i]](value) : object 'fheight' not found.

father.son.adjusted <- father.son %>% 
  group_by(fheight) %>%
  round(fheight) %>% 
  filter(fheight == 71) %>% 
  select(fheight, sheight)

My data is numeric as follows

    
    fheight     sheight
1   65.04851    59.77827
2   63.25094    63.21404
3   64.95532    63.34242
4   65.75250    62.79238
5   61.13723    64.28113
6   63.02254    64.24221
7   65.37053    64.08231
8   64.72398    63.99574

When I run this snippet without the round function everything works fine. I read other questions regarding issues with the round function but was unable to decipher my own error. Thank you very much for your help.

Upvotes: 0

Views: 754

Answers (1)

Duck
Duck

Reputation: 39595

Try and check this:

library(dplyr)
father.son.adjusted <- father.son %>%
  mutate(fheight=round(fheight)) %>%
  group_by(fheight) %>%
  filter(fheight == 71) %>% 
  select(fheight, sheight)

Upvotes: 1

Related Questions