R语言读取txt和csv只有1列时

多半是间隔符的问题

?read.table
read.table(file, header = FALSE, sep = "", quote = "\"'",
           dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"),
           row.names, col.names, as.is = !stringsAsFactors, tryLogical = TRUE,
           na.strings = "NA", colClasses = NA, nrows = -1,
           skip = 0, check.names = TRUE, fill = !blank.lines.skip,
           strip.white = FALSE, blank.lines.skip = TRUE,
           comment.char = "#",
           allowEscapes = FALSE, flush = FALSE,
           stringsAsFactors = FALSE,
           fileEncoding = "", encoding = "unknown", text, skipNul = FALSE)

read.csv(file, header = TRUE, sep = ",", quote = "\"",
         dec = ".", fill = TRUE, comment.char = "", ...)

read.csv2(file, header = TRUE, sep = ";", quote = "\"",
          dec = ",", fill = TRUE, comment.char = "", ...)

read.delim(file, header = TRUE, sep = "\t", quote = "\"",
           dec = ".", fill = TRUE, comment.char = "", ...)

read.delim2(file, header = TRUE, sep = "\t", quote = "\"",
            dec = ",", fill = TRUE, comment.char = "", ...)
sep

the field separator character. Values on each line of the file are separated by this character. If sep = "" (the default for read.table) the separator is ‘white space’, that is one or more spaces, tabs, newlines or carriage returns.

字段分隔符。文件中每一行的值都由该字符分隔。如果sep = "(read . table的默认值)分隔符是“空白”,即一个或多个空格、制表符、换行符或回车符。‘

data <-read.csv("file.csv",sep="\t",header=T)

data <-read.csv("file.csv",sep=",",header=T)

相关推荐

  1. R语言读取txtcsv只有1

    2024-07-23 07:22:02       33 阅读
  2. R语言计算特定(自备)

    2024-07-23 07:22:02       46 阅读
  3. 使用 R 读取Excel文件的特定

    2024-07-23 07:22:02       49 阅读
  4. R语言【base】——scan():读取数据值

    2024-07-23 07:22:02       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-23 07:22:02       172 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-23 07:22:02       190 阅读
  3. 在Django里面运行非项目文件

    2024-07-23 07:22:02       158 阅读
  4. Python语言-面向对象

    2024-07-23 07:22:02       171 阅读

热门阅读

  1. 2024 7.15~7.21 周报

    2024-07-23 07:22:02       35 阅读
  2. 力扣 102题 二叉树的层次遍历 记录

    2024-07-23 07:22:02       28 阅读
  3. 【通俗理解】对数边缘似然:公式与应用

    2024-07-23 07:22:02       32 阅读
  4. mariadb安装centos再次踩坑

    2024-07-23 07:22:02       35 阅读
  5. PostgreSQL 8.4 ROW_NUMBER()函数

    2024-07-23 07:22:02       29 阅读
  6. 通过队列名寻找某队列-linux

    2024-07-23 07:22:02       26 阅读
  7. springboot业务逻辑写在controller层吗

    2024-07-23 07:22:02       29 阅读
  8. linux本地互传文件

    2024-07-23 07:22:02       27 阅读
  9. 异步TCP服务器;异步TCP客户端

    2024-07-23 07:22:02       29 阅读
  10. 【摸鱼笔记】了解itertools,优雅处理list

    2024-07-23 07:22:02       29 阅读
  11. Windows图形界面(GUI)-DLG-C/C++ - 滑动条(Trackbar)

    2024-07-23 07:22:02       33 阅读
  12. 【ffmpeg命令入门】再论ffmpeg通用选项

    2024-07-23 07:22:02       27 阅读
  13. windows启动不打开窗口命令

    2024-07-23 07:22:02       31 阅读