我有一个带html代码的变量.
这里是R控制台中的代码变量outpout:
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我尝试将内容保存到txt文件中
write.table(code, file='C:/Users/Desktop/code_result.txt')
Run Code Online (Sandbox Code Playgroud)
但它堆积了这个错误:
Error in as.data.frame.default(x[[i]], optional = TRUE) :
c("cannot coerce class \"c(\"HTMLInternalDocument\", \"HTMLInternalDocument\", \"XMLInternalDocument\", \" to a data.frame", "cannot coerce class \"\"XMLAbstractDocument\")\" to a data.frame")
Run Code Online (Sandbox Code Playgroud) 在 R selenium 中,可以像这样设置时间睡眠:
Sys.sleep(15)
Run Code Online (Sandbox Code Playgroud)
怎么可能设置随机时间?在Python中是这样的:
time.sleep(random.uniform(3.5,6.9))
Run Code Online (Sandbox Code Playgroud) 我有一个数据框列,其数据如下:
df$names
"stock 1"
"stock stock1 2"
"stock 2"
Run Code Online (Sandbox Code Playgroud)
我想删除每行文本的空格.结果如下:
df$names
"stock1"
"stockstock12"
"stock2"
Run Code Online (Sandbox Code Playgroud)
并为文件名添加一个路径,并有一个这样的最终列(所有行的路径相同)
df$names
"C:/Desktop/stock_files/stock1"
"C:/Desktop/stock_files/stockstock12"
"C:/Desktop/stock_files/stock2"
Run Code Online (Sandbox Code Playgroud)