对于一个特殊问题,我有一个非常低效的解决方案.我有文本数据,由于各种原因,它以随机的间隔跨越数据帧的各行.然而,已知某些子集基于数据帧中其他变量的唯一组合而属于一起.例如,参见MWE演示结构和我的初始解决方案:
# Data
df <- read.table(text="page passage person index text
1 123 A 1 hello
1 123 A 2 my
1 123 A 3 name
1 123 A 4 is
1 123 A 5 guy
1 124 B 1 well
1 124 B 2 hello
1 124 B 3 guy",header=T,stringsAsFactors=F)
master<-data.frame()
for (i in 123:max(df$passage)) {
print(paste0('passage ',i))
tempset <- df[df$passage==i,]
concat<-''
for (j in 1:nrow(tempset)) {
print(paste0('index ',j))
concat<-paste(concat, tempset$text[j])
}
tempdf<-data.frame(tempset$page[1],tempset$passage[1], tempset$person[1], concat, stringsAsFactors = FALSE)
master<-rbind(master, tempdf) …Run Code Online (Sandbox Code Playgroud) 我是新手使用R发布表单然后从网上下载数据.我有一个问题可能很容易让那里的人发现我做错了什么,所以我感谢你的耐心等待.我有一台Win7 PC和Firefox 23.x是我的典型浏览器.
我正在尝试发布显示的主要表单
我有以下R脚本:
your.username <- 'username'
your.password <- 'password'
setwd( "C:/Users/Desktop/Aplia/data" )
require(SAScii)
require(RCurl)
require(XML)
agent="Firefox/23.0"
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
curl = getCurlHandle()
curlSetOpt(
cookiejar = 'cookies.txt' ,
useragent = agent,
followlocation = TRUE ,
autoreferer = TRUE ,
curl = curl
)
# list parameters to pass to the website (pulled from the source html)
params <-
list(
'userAgent' = agent,
'screenWidth' = "",
'screenHeight' = "",
'flashMajor' = "",
'flashMinor' …Run Code Online (Sandbox Code Playgroud)