r - 将列表写入 txt 文件
问题描述
我想在操作后将段落列表写入 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")
推荐阅读
- c - STDC 否定定义(例如 __STDC_NO_VLA__)背后的动机是什么?
- facebook - 自定义 FB 登录流程
- server - ColdFusion - 会话变量 - 丢失它们
- node.js - 生产环境中的 Socket.io 和 nginx CORS
- html - 悬停效果结束后如何完成整个动画png?
- javascript - ASP.NET MVC 中的 GUID 模型绑定
- python - 有没有一种技术可以找到连接组件的厚度?
- django - Django 在模型中创建对象时定义 update_fields
- python - 如何将 Tkinter 条目放入 SQLite 数据库中?
- javascript - 如何下载 VoiceRSS API 请求的返回?