2

I wanted to view the transformed dataframe using the flights dataset but R shows an invalid caption argument error

library(dplyr)
library(nycflights13)

view (temp <- flights %>% 
  group_by(year, month, day) %>% 
  mutate(r = min_rank(desc(dep_time))) %>% 
  filter(r %in% range(r)))

Error in View : invalid caption argument

However, this one with the piping operator works fine.

(temp <- flights %>% 
  group_by(year, month, day) %>% 
  mutate(r = min_rank(desc(dep_time))) %>% 
  filter(r %in% range(r))) %>% view()

So does this one (with a capital V)

View (temp <- flights %>% 
  group_by(year, month, day) %>% 
  mutate(r = min_rank(desc(dep_time))) %>% 
  filter(r %in% range(r)))

Even this one (where the transformed dataframe is not assigned to an object works)

view (flights %>% 
  group_by(year, month, day) %>% 
  mutate(r = min_rank(desc(dep_time))) %>% 
  filter(r %in% range(r)))

Could anyone explain what's happening and why the error in the first case and not the other three? Thank you in advance.

geldbeutel
  • 31
  • 3
  • Did you mean `View()` with an uppercase V? Because this works fine for me: `View(temp <- mtcars %>% mutate(mpg=mpg+1) %>% select(hp))`. Can you please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Jun 27 '21 at 05:48
  • Thank you, I edited the question with a reprex. – geldbeutel Jun 28 '21 at 07:47
  • I still cannot replicate and the "v" is still lowercase. What version of RStudio are you using? Is it the latest? – MrFlick Jun 28 '21 at 19:40
  • Version 1.4.1717 - the one released earlier this month. – geldbeutel Jun 29 '21 at 07:23

0 Answers0