I import a dataframe with library rvest and I want to sort it with subset function, import is alright, cause I can print a dataframe. But when I want to sort data from it, I see error object not found. What should I do?
library(rvest)
html_content <- read_html(url("https://ki.ujep.cz/cs/historie/"))
table <- html_table(html_content, header = TRUE)
print(subset(table, subset = `Dosud na UJEP?` == "ANO"))
I have tested function subset for iris dataframe and it works perfectly, so I don’t know what I have to do else
Игорь Блохин is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You should select what table want to select from. Just add table[[2]]
> print(subset(table[[2]], subset = `Dosud na UJEP?` == "ANO"))
# A tibble: 6 × 4
Jméno Od Do `Dosud na UJEP?`
<chr> <int> <chr> <chr>
1 Ing. Mgr. Jiří Barilla 1993 1996 ANO
2 Ing. Mgr. Jiří Barilla, CSc. 2001 2006 ANO
3 Prof. RNDr. Ivo Nezbeda, DrSc. 2006 2008 ANO
4 Doc. RNDr. Viktor Mashkov, DrSc. 2009 2011 ANO
5 prof. RNDr. Stanislav Novák, CSc. 2011 2014 ANO
6 RNDr. Jiří Škvor, Ph.D. 2014 Dosud ANO