Error in View: invalid caption argument [closed]

1

I was moving the following script:

library(tidyverse) 
library(dplyr) 
library(readxl) 

cirurgia <- read_excel("C:/Users/Agnes/Desktop/Coisas com R/R/2_MIOMECTOMIA_HISTERECTOMIA-MAR_SET-2017.xlsx", 
                       sheet = "Plan1", 
                       col_types = c("text", "text", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric")) 
View(cirurgia) 
pretas <- cirurgia %>% 
 select(estado, PROCEDIMENTO, PRETA, PARDA, TOTAL) %>% 
 filter(PROCEDIMENTO == "HISTERECTOMIA TOTAL") %>% 
 View(pretas)
  

Error in View: invalid caption argument

What does this mean?

    
asked by anonymous 01.12.2018 / 23:10

1 answer

2

What is happening here is independent of your database.

  

Remember that the %>% operator causes the object to its left to be used as an argument to the function to its right.

Therefore, the following two lines are equivalent:

mtcars %>% View()
View(mtcars)

When you do:

x <- mtcars %>% View(x)

You're doing something equivalent to:

x <- View(mtcars, x)

However, the variable x does not yet exist, so this is equivalent to:

x <- View(mtcars, NULL)

It turns out that the second argument of the function View is a title for the table and that title can not be NULL , so the error:

  

Error in View: invalid caption argument

    
05.12.2018 / 13:04