0

I'm trying to solve a practice question in R from a textbook(the tibble is copied from it). I can see the object is created in the environment, it looks good, I can see that the names of the columns are changed as they should be. However, the code itself shows errors. Is there something wrong with it?

#Practice 2 (book of R)
annoying <- tibble(
  `1` = 1:10,
  `2` = `1` * 2 + rnorm(length(`1`))
)
#> Error in tibble(`1` = 1:10, `2` = `1` * 2 + rnorm(length(`1`))): could not find function "tibble"

#Create another column 3 = col1/col2 

annoying$new<-annoying$'2'/annoying$'1'
#> Error in eval(expr, envir, enclos): object 'annoying' not found
#> Error in eval(expr, envir, enclos): object 'annoying' not found

Created on 2022-06-28 by the reprex package (v2.0.1)

TanyaM
  • 21
  • 4
  • Did you try library(tibble) or library(tidyverse) before? – abichat Jun 28 '22 at 15:32
  • Yes, I think I need to print it one more time here. – TanyaM Jun 28 '22 at 15:36
  • If you are getting the error "could not find function 'tibble'" then you have not loaded a package that defines the `tibble()` function. You need to include the correct calls to `library()` in each R session where you want to use a particular package. You can run `sessionInfo()` to see which packages are currently loaded. If the call to `tibble` doesn't work, then `annoying` will never be created and it also will not be found. – MrFlick Jun 28 '22 at 15:39

0 Answers0