删除“"写入 CSV 时从 csv 值和更改列名 [英] Delete "" from csv values and change column names when writing to a CSV

查看:30
本文介绍了删除“"写入 CSV 时从 csv 值和更改列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 R 表中创建 csv 文件.但我不明白为什么所有的值都得到当我使用 write.csv() 函数时,用"检查.我的数据如下所示:

I'm trying to create csv files out of an R table. But i cant understand why all the values get checked with "" when i use the write.csv() function. my data looks like this:

        Sample  Sample_Name Sample_Group    Pool_ID Sample_Plate    NorTum  Sentrix_ID    Sentrix_Position  HybNR
    1   00_11242    00_24200N2  MUTYH   GS0005703-OPA   GS0010004-DNA   N     1280307   R007_C005   1
    2   00_11242    00_24200N2  MUTYH   GS0005704-OPA   GS0010004-DNA   N   1280307 R007_C011   1
    3   00_11242    00_24200N2  MUTYH   GS0005702-OPA   GS0010004-DNA   N   1416198 R007_C011   2
    4   00_11242    00_24200N2  MUTYH   GS0005701-OPA   GS0010004-DNA   N   1416198 R007_C005   2
    5   00_7    00_7T   MUTYH   GS0005701-OPA   GS0010004-DNA   T   1416198 R006_C005   2
    6   00_7    00_7T   MUTYH   GS0005702-OPA   GS0010004-DNA   T   1416198 R006_C011   2
    7   00_7    00_7T   MUTYH   GS0005704-OPA   GS0010004-DNA   T   1280307 R006_C011   1
    8   00_7    00_7T   MUTYH   GS0005703-OPA   GS0010004-DNA   T   1280307 R006_C005   1
    9   01_677  01_677N HNPCC_UV    GS0005701-OPA   GS0010004-DNA   N   1416198 R002_C006   2
    10  01_677  01_677N HNPCC_UV    GS0005704-OPA   GS0010004-DNA   N   1280307 

在 CSV 输出文件中,每个值如下所示:

And in the output file which is a CSV every value looks like this:

"100" "R05_80611" "R05_80611N" "NA_FAM" "GS0005701-OPA" "GS0010004-DNA" "N" 1416198 "R003_C006" 2

为什么函数要在我的值周围加上引号,有没有办法快速做到这一点.

Why is the function putting quotes around my values and is there a way to quickly do this.

我还想知道如何在写入 CSV 文件时更改列名,但由于我是初学者,我不知道如何执行此操作.

I'm also wondering how I can change my column names when writing to CSV files but since i`m a starter I've no clue on how to do this.

推荐答案

参见手册 write.table {utils}.

help(write.csv)

write.csv(X, quote = FALSE)

默认引用字段的理由是包含逗号的未引用字段将被误解.

The justification for quoting the fields by default is that unquoted fields containing commas will be misinterpreted.

这篇关于删除“"写入 CSV 时从 csv 值和更改列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆