This is a 'why' question and not a 'How to' question.
I have a tibble
as a result of an aggregation dplyr
> str(urls)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 144 obs. of 4 variables:
$ BRAND : chr "Bobbi Brown" "Calvin Klein" "Chanel" "Clarins" ...
$ WEBSITE : chr "http://www.bobbibrowncosmetics.com/" "http://www.calvinklein.com/shop/en/ck" "http://www.chanel.com/en_US/" "http://www.clarinsusa.com/" ...
$ domain : chr "bobbibrowncosmetics.com/" "calvinklein.com/shop/en/ck" "chanel.com/en_US/" "clarinsusa.com/" ...
$ final_domain: chr "bobbibrowncosmetics.com/" "calvinklein.com/shop/en/ck" "chanel.com/en_US/" "clarinsusa.com/" ...
When I try to extract the column final_domain as a character vector here's what happens:
> length(as.character(urls[ ,4]))
[1] 1
When I instead, coerce to data frame and then do it, I get what I actually want:
> length(as.character(as.data.frame(urls)[ ,4]))
[1] 144
The str
of the tibble vs. dataframe looks the same but output differs. I'm wondering why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…