我正在尝试从以下网址抓取数据:\n https://university.careers360.com/colleges/list-of- Degree-colleges-in-India \n我想单击每个大学名称并获取每个学院的具体数据。
\n\n首先,我所做的是将所有大学网址收集到一个向量中:
\n\n#loading the package:\nlibrary(xml2)\nlibrary(rvest)\nlibrary(stringr)\nlibrary(dplyr)\n\n#Specifying the url for desired website to be scrapped\nbaseurl <- "https://university.careers360.com/colleges/list-of-degree-colleges-in-India"\n\n#Reading the html content from Amazon\nbasewebpage <- read_html(baseurl)\n\n#Extracting college name and its url\nscraplinks <- function(url){\n #Create an html document from the url\n webpage <- xml2::read_html(url)\n #Extract the URLs\n url_ <- webpage %>%\n rvest::html_nodes(".title a") %>%\n rvest::html_attr("href") \n #Extract the link text\n link_ <- webpage %>%\n rvest::html_nodes(".title a") %>%\n rvest::html_text()\n return(data_frame(link = link_, url = url_))\n}\n\n#College names and Urls\nallcollegeurls<-scraplinks(baseurl)\nRun Code Online (Sandbox Code Playgroud)\n\n到目前为止工作正常,但是当我对每个 url …
我有一个包含数字的因子列。一些数字以 k 格式书写,例如。99k, 9.25k, 91.9k 等,而其他人则像 998、575 等一样完整地编写。我想做的两件事-:
如果我首先将其转换为数字应用 as.numeric,k 格式数字将成为 NAs。
我想不出什么来解决这个问题。任何人都可以帮助我解决 r 问题吗?
以下是样本数据
df=data.frame(
ID = c(1:8),
Likes = c('99k', '997','15.5k', '9.25k','575', '800', '8.5k', '2,400')
)
Run Code Online (Sandbox Code Playgroud)
编辑我仍然不知道是什么问题。在尝试了此处提供的所有解决方案后,仍然生成了 NA。我正在提供完整数据的链接。请通过它并帮助我找到问题。我关心的专栏是“喜欢”。
https://drive.google.com/file/d/1tR0F4SwGmsVjh5NGGpONP6LTaqgDOM4l/view?usp=sharing