I am stil trying to understand some basics of the purrr package, and was wondering whether someone could explain me why the last command below doesn't work. I understand its something basic, and I have other ways to solve the issue, but it would help to know why it doesn't work.
library(tidyverse)
#> Warning: Paket 'tibble' wurde unter R Version 3.5.2 erstellt
#> Warning: Paket 'readr' wurde unter R Version 3.5.2 erstellt
#> Warning: Paket 'purrr' wurde unter R Version 3.5.2 erstellt
df2 <- structure(list(group = c("B-C", "A,B,C", "B A C"), overlap = list(
logical(0), c("B", "C"), c("B", "A", "C"))), class = "data.frame", row.names = c(NA,
-3L))
df2$overlap %>% map(.,length)
#> [[1]]
#> [1] 0
#>
#> [[2]]
#> [1] 2
#>
#> [[3]]
#> [1] 3
df2$overlap %>%
map(.,length)
#> [[1]]
#> [1] 0
#>
#> [[2]]
#> [1] 2
#>
#> [[3]]
#> [1] 3
df2 %>%
mutate(length.overlap=map(overlap, length))
#> group overlap length.overlap
#> 1 B-C 0
#> 2 A,B,C B, C 2
#> 3 B A C B, A, C 3
df2 %>%
map(overlap, length)
#> Error in as_mapper(.f, ...): Objekt 'overlap' nicht gefunden