读取R中的txt数据

问题描述 投票:0回答:1

嗨,我想简单地在R中读取此数据。但是,当使用read.table和read.delim时,我收到了一堆警告消息,并且该数据被读取为1 * 1变量。请帮助我。

Warning messages:
1: In read.table("tut9_Data.txt", header = TRUE) :
  line 1 appears to contain embedded nulls
2: In read.table("tut9_Data.txt", header = TRUE) :
  line 2 appears to contain embedded nulls
3: In read.table("tut9_Data.txt", header = TRUE) :
  line 3 appears to contain embedded nulls
4: In read.table("tut9_Data.txt", header = TRUE) :
  incomplete final line found by readTableHeader on 'tut9_Data.txt'

enter image description here

r read.table
1个回答
0
投票

我已经尝试在rstudio中复制相同的内容。我没有发现任何错误。请看看我的代码

df <- read.table("tut9_Data.txt",header = TRUE)

dput(df)

df <- structure(list(fledged = c(10L, 5L, 9L, 3L, 5L, 4L, 4L, 5L, 5L, 
4L, 3L, 5L, 4L, 10L, 9L, 4L, 2L, 4L, 5L), age = c(3L, 5L, 4L, 
5L, 5L, 2L, 4L, 4L, 1L, 1L, 0L, 2L, 1L, 3L, 5L, 3L, 1L, 5L, 5L
)), class = "data.frame", row.names = c(NA, -19L))

如果仍然发现错误,请对数据进行dput()并提供可重现的示例

© www.soinside.com 2019 - 2024. All rights reserved.