我想将段落列表写入txt文件中,以在对其进行操作后查看,该列表被调用psw_list
,您可以使用引用第一段psw_list$p1
。psw_list$p1
好像:
> psw_list$p1
[1] "For more than five years, William Sencion did the same task over and over. He signed onto the New York City’s housing lottery site and applied for one of the city’s highly coveted, below-market apartments. Each time, he got the same response: silence."
有任何想法吗?
您正在寻找write(...)函数。如果要将所有段落写入一个文件,则需要使用unlist(...)函数,如下所示。
这些函数会将生成的.txt文件转储到您的工作目录中。
psw_list <- c()
psw_list$p1 <- "For more than five years, William Sencion did the same task over and over. He signed onto the New York City’s housing lottery site and applied for one of the city’s highly coveted, below-market apartments. Each time, he got the same response: silence."
psw_list$p2 <- "Something something dark side. Luke I am your father."
write(psw_list$p1, "first_paragraph.txt")
write(unlist(psw_list), "all_pragraphs.txt")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句