Closed esppk closed 6 years ago
Could you maybe give a fully reproducible example? Using latest R and tidyverse (see session info) I cannot reproduce this right now:
library(tidyr)
df_err <- data.frame(feature = c("one_of", "a_lot"),
frequency = c(1387, 1091),
stringsAsFactors = F)
class(df_err) <- c("frequency", "textstat", "data.frame")
class(df_err)
#> [1] "frequency" "textstat" "data.frame"
df_err
#> feature frequency
#> 1 one_of 1387
#> 2 a_lot 1091
df_err %>% separate(feature, c("V1","V2"))
#> V1 V2 frequency
#> 1 one of 1387
#> 2 a lot 1091
Oh, sorry about that. Some misjudgment on my side. I just found out that the error starts to occur after loading following package. ( with exact code @rbloehm used )
library(quanteda)
(quanteda web site)
Still think this behavior is kind of buggy, though not sure it's a tidyr's issue.
Say I have a df with extra class names:
class(df_err)
#"frequency" "textstat" "data.frame"
df_err
#feature
frequency
#one_of
1387
#a_lot
1091
Then use
seperate
orextract
will causefrequency
returnNA
df_err %>% separate(feature, c("V1","V2"))
V1 V2 feature frequency
one of NA NA
a lot NA NA
following code will work fine:df_err %>% as.data.frame() %>% separate(feature, c("V1","V2"))
V1 V2 frequency
one of
1387
a lot
1091