Closed Make42 closed 5 years ago
It seems fine
library(magrittr)
packageVersion("magrittr")
#> [1] '1.5'
iris %>%
extract(, 1:4) %>%
head
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1 5.1 3.5 1.4 0.2
#> 2 4.9 3.0 1.4 0.2
#> 3 4.7 3.2 1.3 0.2
#> 4 4.6 3.1 1.5 0.2
#> 5 5.0 3.6 1.4 0.2
#> 6 5.4 3.9 1.7 0.4
iris %>%
extract(1:4,) %>%
head
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3.0 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
Created on 2019-01-04 by the reprex package (v0.2.1)
You may just have a conflict with tidyr::extract
https://tidyr.tidyverse.org/reference/extract.html
You can use
iris %>%
magrittr::extract(, 1:4) %>%
head
Also, see the conflicted
📦 to help see through those situations
# this will prints an error if there is conflicts between functions
``` r
library(conflicted)
#> Warning: le package 'conflicted' a été compilé avec la version R 3.5.2
library(magrittr)
library(tidyr)
iris %>%
extract(, 1:4) %>%
head
#> Error: [conflicted] `extract` found in 2 packages.
#> Either pick the one you want with `::`
#> * tidyr::extract
#> * magrittr::extract
#> Or declare a preference with `conflict_prefer()`
#> * conflict_prefer("extract", "tidyr")
#> * conflict_prefer("extract", "magrittr")
# or extract <- magrittr::extract
conflict_prefer("extract", "magrittr")
#> [conflicted] Will prefer magrittr::extract over any other package
iris %>%
extract(,1:4) %>%
head
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1 5.1 3.5 1.4 0.2
#> 2 4.9 3.0 1.4 0.2
#> 3 4.7 3.2 1.3 0.2
#> 4 4.6 3.1 1.5 0.2
#> 5 5.0 3.6 1.4 0.2
#> 6 5.4 3.9 1.7 0.4
Can you check ?
You seem to be right. Thank you also for the tip regarding conflicted
.
running
I get the error