【问题标题】:Splitting Columns that contain decimal point values in R拆分 R 中包含小数点值的列
【发布时间】:2016-08-15 11:40:10
【问题描述】:

我在 R 中遇到了拆分列的困难。例如

        Col1.Col2.Col3 
        12.3,10,11
        11.3,11,50
        85,89.3,90
        and over 100x records

我做到了

       tidyr::separate(df, Col1.Col2.Col3, 
                c("Col1", "Col2", "Col3" ))

我明白了

        Col1 Col2 Col3 
        12   3    10
        11   3    11
        85   89   3
        and over 100x records

我意识到十进制值被移到下一列,而 Col3 的值被忽略了。我该如何解决这个问题,或者有没有更好的方法来拆分列?

【问题讨论】:

  • 你是如何读取数据源的?
  • 独立函数有 sep 参数,sep = ","
  • 我做了 df

标签: r multiple-columns


【解决方案1】:

tidyr::separate 有一个 sep 参数,用于控制拆分发生的位置。使用sep = ","

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多