R's tidyverse and dplyr


I was working with dplyr package and I found one problem.

The add_column() function does not work with dplyr package but it works fine with tidyverse package.

I don't know why? It should work fine with dplyr because it is part of dplyr package.

Am I missing something?

The functions add_column() and add_row are actually from the 'tibble' package, and dplyr is dependent on tibble and imports some of its functions. That's why you can call dplyr::add_row().
If you type that in your console and press F1 for help, it will take you to a page that shows all functions in dplyr that are imported from other packages and made available in dplyr. add_column() isn't one of them, I'm guessing because it's close enough to mutate() to be redundant. And it's possible it was there before and got removed on an update; I'm not sure.

tidyverse is different than a regular package; it doesn't have any functions if it's own. It's kind of like a shortcut for loading each package - dplyr, tibble, purrr, ggplot2, etc individually and having all of their functions available. I think of it as a "convenience metapackage" (by no means official terminology, just how it makes sense to me). When you loaded the tidyverse you had all of dplyr and tibble available, so that's why add_column() worked.

Anytime you get a "could not find function" error, type the function into the console with 2 question marks like
and it will link you to all documentation matching that function name in any installed package.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.