参数意味着不同的行数:20,0

时间:2018-05-15 12:24:00

标签: r dataframe

我试图从猎头公司获取统计数据。

library(RCurl)
library(jsonlite)
library(purrr)
library(stringr)
library(rvest)
library(dplyr)
library(jsonlite)

Sys.setlocale(locale = "Russian")
vacanciesdf <- data.frame(
   Name = character(),  
   Currency = character(),
   From = character(), 
   Area = character(), 
   Requerement = character(), stringsAsFactors = T,
   Experience = character() 
   ) 

for (pageNum in 0:1) {
  data <- jsonlite::fromJSON(paste0("https://api.hh.ru/vacancies?text=\"machine+learning\"&page=", pageNum))
  vacanciesdf <- rbind(vacanciesdf, data.frame(
    data$items$area$name,
    data$items$salary$currency,
    data$items$salary$from,
    data$items$employer$name,
    data$items$snippet$requirement,
    data$items$experience$name 
    ))
  print(pageNum)
  Sys.sleep(3)
}
行中出现

错误:数据$ items $体验$ name,没有此行的代码有效。 完整错误文字:

Error in data.frame(data$items$area$name, data$items$salary$currency,  : 
  arguments imply differing number of rows: 20, 0

1 个答案:

答案 0 :(得分:0)

npm install @ionic/app-scripts@nightly --save-dev