>
> x=1:6
> is.vector(x)
[1] TRUE
> is.array(x)
[1] FALSE
> x=c(1:6)
> is.array(x)
[1] FALSE
> is.vector(x)
[1] TRUE
> dim(x)<-c(2,3)
> is.vector(x)
[1] FALSE
> is.array(x)
[1] TRUE
> is.matrix(x)
[1] TRUE
> dim(y)<-c(2,3)
错误于dim(y) <- c(2, 3) : dims [product 6]与对象长度[2]不匹配
> y=c(2,3)
> y
[1] 2 3
>
>
>
>
>
>
>
>
>
>
>
> x1=1:10*2
> x1
[1] 2 4 6 8 10 12 14 16 18 20
> x1=1:10*5
> x1=1:10*2
> x1
[1] 2 4 6 8 10 12 14 16 18 20
> x2=1:10*5
> x=data.frame(x1,x2)
> x
x1 x2
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> x=data.frame(‘重量’=x1,‘运费’=x2)
> x
x1 x2
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> (x=data.frame(‘重量’=x1,‘运费’=x2))
> (x=data.frame(‘重量’=x1,‘运费’=x2))
> x
x1 x2
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> (x=data.frame(‘重量’=x1,‘运费’=x2))
> x
x1 x2
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> x=data.frame(‘重量’=x1,‘运费’=x2)
> x
x1 x2
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> x=data.frame('重量'=x1,'运费'=x2)
> x
重量 运费
1 2 5
2 4 10
3 6 15
4 8 20
5 10 25
6 12 30
7 14 35
8 16 40
9 18 45
10 20 50
> plot(x)
> x=read.table("abc.txt")
警告信息:
In read.table("abc.txt") :
readTableHeader在读取'abc.txt'时遇到了不完全的最后一行
> x
V1 V2
1 1 2
2 3 4
3 5 5
4 6 7
5 9 12
> x=read.table("c:\\abc.txt")
错误于file(file, "rt") : 无法打开链结
此外: 警告信息:
In file(file, "rt") : 无法打开文件'c:\abc.txt': No such file or directory
> y=read.table("c:\\abc.txt")
警告信息:
In read.table("c:\\abc.txt") :
readTableHeader在读取'c:\abc.txt'时遇到了不完全的最后一行
> c
[,1] [,2] [,3]
[1,] 166 188 210
[2,] 188 214 240
[3,] 210 240 270
> y
V1 V2
1 1 2
2 3 4
3 5 5
4 6 7
5 9 12
> y<-read.table("clipboard",header=F)
错误于file(file, "rt") : 无法打开链结
此外: 警告信息:
In file(file, "rt") : 打不开裁剪板,或是裁剪板不含文字
>
>
>
> y<-read.table("clipboard",header=F)
> y
V1 V2
1 1 2
2 3 4
3 5 5
4 6 7
5 9 12
6 1 6
> y<-read.table("clipboard",header=T)
> y
X1 X2
1 3 4
2 5 5
3 6 7
4 9 12
5 1 6
> z=read.table("aaa.prn",header=T);
警告信息:
In read.table("aaa.prn", header = T) :
readTableHeader在读取'aaa.prn'时遇到了不完全的最后一行
> z
PK...
1 P圱\xd2\005汥Q4锝鵩扉|[檇\003\001党9\033g
> utils:::menuInstallPkgs()
--- 在此連線階段时请选用CRAN的鏡子 ---
试开URL’http://cran.dataguru.cn/bin/windows/contrib/2.15/RODBC_1.3-6.zip'
Content type 'application/zip' length 759666 bytes (741 Kb)
打开了URL
downloaded 741 Kb
程序包‘RODBC’打开成功,MD5和检查也通过
下载的二进制程序包在
C:\Users\Administrator\AppData\Local\Temp\RtmpQv2Ebi\downloaded_packages里
> z=odbcConnectExcel("good.xlsx")
错误: 没有"odbcConnectExcel"这个函数
> library(RODBC)
> z=odbcConnectExcel("good.xlsx")
> W=sqlFetch(z,"Sheet1");
> W
F1 F2 F3
1 2 3 5
2 3 4 6
3 4 5 7
4 5 6 8
5 6 7 9
6 7 8 10
7 8 9 11
8 9 10 12
9 10 11 13
10 11 12 14
11 12 13 15
12 13 14 16
13 14 15 17
> for(i in 1:20){a[i]=i*2+3}
> a
[1] 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43
> for(i in 1:20){a[i]=i*2+3;b[i]=2}
> b
[1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
> for(i in 1:20){a[i]=i*2+3;b[i]=i+2}
> b
[1] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
> a[1]=5
> i=1
> while(a[i]<50){i=i+1;a[i]=a[i-1]+2}
> a
[1] 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51
>
>
>
>
>
>
>
>
>
> source("a.r")
[1] 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51
> source("a.r")
[1] 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 37 39 41 43 45 47 49 51
>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27573546/viewspace-743201/
,如需转载,请注明出处,否则将追究法律责任。