Installing "separate" package (Newbie difficulty)

Newbie here... I am 7/8ths of the way through the Data Analysis with RStudio course in Coursera... I've been doing quite well but have suddenly been stymied with a seemingly very simple operation.

I have been tasked with splitting the names in the "name" column into two new columns labeled 'first name' and 'last name'. Presumably (and according to the video), all I need to do is execute a simple command in the console:

separate(employee, name, into=c('first_name', 'last_name'), sep=' ')

But when I do so in RStudio (fully upto date) I am not allowed to separate the column. It informs me : "> library("separate")
Error in library("separate") : there is no package called β€˜separate’""

When I install tidyr. the installation goes as expected:

'library("tidyverse")
── Attaching core tidyverse packages ──
:heavy_check_mark: dplyr 1.1.3 :heavy_check_mark: readr 2.1.4
:heavy_check_mark: forcats 1.0.0 :heavy_check_mark: stringr 1.5.0
:heavy_check_mark: ggplot2 3.4.4 :heavy_check_mark: tibble 3.2.1
:heavy_check_mark: lubridate 1.9.3 :heavy_check_mark: tidyr 1.3.0
:heavy_check_mark: purrr 1.0.2
── Conflicts ──────────────────────────
:heavy_multiplication_x: dplyr::filter() masks stats::filter()
:heavy_multiplication_x: dplyr::lag() masks stats::lag()
:information_source: Use the conflicted package to force all conflicts to become errors'

Finally, I felt compelled to install a different, seemingly bootleg sEparaTe package, hoping that it would do the trick. It doesn't work either. Should I reinstall RStudio entirely? Any ideas, helpful hints?

Thanks.

P.S. Wrote a lot because I don't know how much I need to tell you in order to provide information that's tantamount to reprex.

1 Like

Separate is not a package, it's a function within the {tidyr}package. So, there are two ways to call it:

library(tidyr)
separate(employee, name, into=c('first_name', 'last_name'), sep=' ')

or

tidyr::separate(employee, name, into=c('first_name', 'last_name'), sep=' ')

plus a third way (since {tidyverse} is a meta-package that includes {tidyr}):

library(tidyverse)
separate(employee, name, into=c('first_name', 'last_name'), sep=' ')

but calling library(separate) is meaningless, you are asking R to load a package called {separate}, which of course doesn't exist.

2 Likes

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.