当前位置:网站首页>A simple and crude method for exporting R language list to local
A simple and crude method for exporting R language list to local
2022-06-26 22:44:00 【Analysis of breeding data】
occasionally , My result is a list, Can't be converted into data.frame Data frame , Force output with data frame function , The results changed , such as :
- fwrite
- write.table
- write.csv
- write.xlsx
None of this . Chinese search did not find the right answer , Later on stackoverflow eureka , You still need to search the answers in English .
https://stackoverflow.com/questions/27594541/export-a-list-into-a-csv-or-txt-file-in-r
therefore , I learned , The principle to be written , Just write a summary , It's convenient for later generations .
1. My irregular data
> va_list
$y1
component std.error z.ratio bound %ch
vm(ID, ainv) 0.04524 0.01369 3.305 P 0.1
units!units 0.09159 0.01134 8.076 P 0.1
units!R 1.00000 NA NA F 0.0
$y2
component std.error z.ratio bound %ch
vm(ID, ainv) 0.5822 0.3047 1.910 P 0.8
units!units 2.9777 0.3071 9.697 P 0.1
units!R 1.0000 NA NA F 0.0
$y3
component std.error z.ratio bound %ch
vm(ID, ainv) 0.3415 0.09944 3.434 P 0
units!units 0.7387 0.08486 8.705 P 0
units!R 1.0000 NA NA F 0
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
I want to put this result , Save to txt In file , Don't change the format .
If I force it out to txt Documents or , It turns out like this :

Or it's like this :

The format is all out of order .
here , I found two ways , It can be done . give the result as follows :

2. Method 1:sink function
sink Function first opens an empty file , Then input the contents of the following screen , Then close the file .
# Create a new file :va_result.txt
sink("va_result.txt")
# Write content
va_list
# Close file
sink()
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
You can see , No change in format .
$y1
component std.error z.ratio bound %ch
vm(ID, ainv) 0.04524 0.01369 3.305 P 0.1
units!units 0.09159 0.01134 8.076 P 0.1
units!R 1.00000 NA NA F 0.0
$y2
component std.error z.ratio bound %ch
vm(ID, ainv) 0.5822 0.3047 1.910 P 0.8
units!units 2.9777 0.3071 9.697 P 0.1
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
3. Method 2:capture.output function
Be careful ,file = An integral .
capture.output(va_list, file = "va1_result.txt")
- 1.
Results check :

The second method is simpler , Recommended .
Welcome to my official account. :
Analysis of breeding data . Mainly share R Language ,Python, Breeding data analysis , Biostatistics , Quantitative genetics , Mixed linear model ,GWAS and GS Relevant knowledge .
边栏推荐
- leetcode:6103. 从树中删除边的最小分数【dfs + 联通分量 + 子图的值记录】
- Is it safe to open an account and buy stocks? Who knows
- 6.24 学习内容
- Leetcode (122) - the best time to buy and sell stocks II
- 数据清洗工具flashtext,效率直接提升了几十倍数
- leetcode:152. Product maximum subarray [consider DP of two dimensions]
- Vulnhub's DC8
- Partage de trois méthodes de sommation automatique dans un tableau Excel
- Which securities company is the most convenient, safe and reliable for opening an account
- 【BUG反馈】WebIM在线聊天系统发消息时间问题
猜你喜欢

What are the test case design methods?
![[machine learning] - Introduction to vernacular and explanation of terms](/img/4c/e18fe52a71444c2ca08167ead9f28f.jpg)
[machine learning] - Introduction to vernacular and explanation of terms

Unity: the referenced script (unknown) on this behavior is missing“

Unity: 脚本缺失 “The referenced script (Unknown) on this Behaviour is missing!“

VB. Net class library (advanced version - 1)

vulnhub之dc8

Parsing complex JSON in fluent

CVPR 2022 - Interpretation of selected papers of meituan technical team

L'outil de nettoyage des données flashtext améliore directement l'efficacité de plusieurs dizaines de fois

在Flutter中解析复杂的JSON
随机推荐
CVPR 2022 | 美团技术团队精选论文解读
在Flutter中解析复杂的JSON
Centos7编译安装Redis
Implementation of collaborative filtering evolution version neuralcf and tensorflow2
[bug feedback] the problem of message sending time of webim online chat system
简述unity的模型动画功能
Vulnhub's DC8
买股票通过中金证券经理的开户二维码开户资金是否安全?想开户炒股
[hybrid programming JNI] details of JNA in Chapter 11
數據清洗工具flashtext,效率直接提昇了幾十倍數
Introduction to operator
vulnhub之DC9
中金财富开户安全吗?我想开户炒股。
VB. Net class library - 4 screen shots, clipping
YOLOv6:又快又准的目標檢測框架開源啦
分享三種在Excel錶格中自動求和的方法
Yolov6: the fast and accurate target detection framework is open source
Flashtext, a data cleaning tool, has directly increased the efficiency by dozens of times
Different subsequence problems I
Product design in the extreme Internet Era