r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
282 stars 65 forks source link

Error in obj_is_vector(limits) : could not find function "obj_is_vector" #1918

Closed Serendipity31 closed 4 months ago

Serendipity31 commented 4 months ago

Issue

I'm exploring the use of various plotting packages that extend the functionality of ggplot2. In trying to replicate various examples from function help files, I keep getting an error related to the obj_is_vector function. Can someone help?

Example 1 (from the cowplot package help files)

library(ggplot2)
library(cowplot)

df <- data.frame(
  x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3, y4 = (1:10)^4
)

p1 <- ggplot(df, aes(x, y1)) + geom_point()
p2 <- ggplot(df, aes(x, y2)) + geom_point()
p3 <- ggplot(df, aes(x, y3)) + geom_point()

cowplot::plot_grid(p1, p2, p3,
  nrow = 3,
  labels = "AUTO",
  label_size = 12,
  align = "v"
)

Example 2 (from the ggbreak package help files)

library(ggplot2)
library(ggbreak)

set.seed(2019-01-19)
d <- data.frame(
  x = 1:20,
  y = c(rnorm(5) + 4, rnorm(5) + 20, rnorm(5) + 5, rnorm(5) + 22)
)
p <- ggplot(d, aes(x, y)) + geom_col()
p + ggbreak::scale_y_cut(breaks=c(7, 18), which=c(1, 3), scales=c(3, 0.5))

Error

In both these examples I get the following error message:

Error in obj_is_vector(limits) : could not find function "obj_is_vector"

Additionally, when I try to update the vctrs package, I get the following message (despite the fact that I've not directly loaded the package):

Warning in install.packages :
  package ‘vctrs’ is in use and will not be installed

I cannot detach or unload the package, and so cannot seem to update it.

Environment

DavisVaughan commented 4 months ago

It does look like you need to update vctrs. Completely shut down R/RStudio, and then open it back up and try install.packages("vctrs") again, or pak::pak("vctrs").

Serendipity31 commented 4 months ago

@DavisVaughan - the second option worked. I hadn't seen that before. Thanks!