美文网首页生信星球培训第108期
Day3-Hector-Input&Output of File

Day3-Hector-Input&Output of File

作者: Hector | 来源:发表于2021-05-16 22:28 被阅读0次

    · Rownames

    在Rstudio读取文件时,常用的参数有Heading, Separat-or,Rownames等等。



    其中,参数Row names表示是否将数据框的第一列作为行名,它的设置有无用R代码表示如下:

    huahua1 <- read.delim("F:/huahua.txt",row.names = NULL)
    huahua2 <- read.delim("F:/huahua.txt",row.names=1)
    

    对应的原始txt文件,huahua1,huahua2如下所示:


    huahua
    huahua1
    huahua2

    对R中的数据框再次用write.table输出,可以改变分隔符等参数:

    write.table(huahua1,file="huahua1_1.txt",sep=",",quote=FALSE)
    #将huahua1输出,分隔符由原来的空格改为逗号,字符串不加引号。
    write.table(huahua1,file="huahua1_2.txt",sep=" ",quote=TRUE)
    #将huahua1输出,分隔符由原来的空格改为空格,字符串加引号。
    
    huahua1_1
    huahua1_2
    object X not found就是字面意思,没有定义X

    相关文章

      网友评论

        本文标题:Day3-Hector-Input&Output of File

        本文链接:https://www.haomeiwen.com/subject/fpzrjltx.html