Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R线';m';没有';n';读取表中的元素_R - Fatal编程技术网

R线';m';没有';n';读取表中的元素

R线';m';没有';n';读取表中的元素,r,R,所以我在做一些数据的可读表- salaries.data = read.table(someUrl, header=FALSE, sep=' ', na.strings="?", comment.char='') plot(salaries.data) 我得到这个错误- ## Error: line 2 did not have 22 elements 这就是我在RStudio的控制台中打印数据时的样子 V1 1 Y

所以我在做一些数据的可读表-

salaries.data = read.table(someUrl, header=FALSE, sep=' ', na.strings="?", comment.char='')
plot(salaries.data)
我得到这个错误-

## Error: line 2 did not have 22 elements
这就是我在RStudio的控制台中打印数据时的样子

                             V1
1     Y       X1    X2      X3 
2     33.2    3.5    9.0    6.1
3     40.3    5.3   20.0    6.4
4     38.7    5.1   18.0    7.4
5     46.8    5.8   33.0    6.7
6     41.4    4.2   31.0    7.5
7     37.5    6.0   13.0    5.9
8     39.0    6.8   25.0    6.0
9     40.7    5.5   30.0    4.0
10    30.1    3.1    5.0    5.8
11    52.9    7.2   47.0    8.3
12    38.2    4.5   25.0    5.0
13    31.8    4.9   11.0    6.4
14    43.3    8.0   23.0    7.6
15    44.1    6.5   35.0    7.0
16    42.8    6.6   39.0    5.0
17    33.6    3.7   21.0    4.4
18    34.2    6.2    7.0    5.5
19    48.0    7.0   40.0    7.0
20    38.0    4.0   35.0    6.0
21    35.9    4.5   23.0    3.5
22    40.4    5.9   33.0    4.9
23    36.8    5.6   27.0    4.3
24    45.2    4.8   34.0    8.0
25    35.1    3.9   15.0    5.0
这张桌子看起来很整齐,怎么了

#根据OP的评论,来自URL的数据
# data from a URL, as per OP's comment
someUrl <- "http://sites.stat.psu.edu/~lsimon/stat501/sp04/data/mathsalaries.txt‌"
salaries.data <- read.table(someUrl, header=TRUE)
plot(salaries.data)

除了格式不好之外,还有一些URL。什么是V1?你没有表头吗?当我访问从中获取的url时,V1不在表中…所以我不确定它是如何存在的?我能强迫R跳过那一行吗?什么
s
someUrl
?这里
s数据格式良好:
salaries.data=read.table(“http://sites.stat.psu.edu/~lsimon/stat501/sp04/data/mathSalivers.txt”,header=TRUE,sep=“\t”)