0
我有一段簡單的R代碼,它從一個網站讀取html數據,然後我嘗試遍歷頁面並從每個頁面獲取數據。我已經無數次地使用了這段代碼,它很有用。它將來自每個頁面的結果添加到R變量中,但由於某種原因,它不能工作。有任何想法嗎?R函數將不會修改全局變量
library(XML)
library(RCurl)
data <- NULL
getData <- function(url) {
#For some reason cant read directly from site, need to use RCurl to get the data first
xData <- getURL(url)
table <- data.frame(readHTMLTable(xData)$'NULL')
data <- table
}
getData(url="https://steemdb.com/accounts/reputation?page=1")
X < - 的getData(URL =「https://steemdb.com/accounts/reputation?page = 1「) x包含數據。 – Indi
如何爲函數添加'return(data)'?我不會建議混合全球環境和功能環境。 –