> x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
+ x1
+
+ l
+ l
+ x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
错误: unexpected string constant in:
"l
x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),""
> x1<-list(seq(from=-4,to=4,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
+ x1
+ x2<-seq(from=-4,to=4,length=20)
+ x2
+ fffef\
+ ejeweuiodweoieh
+ 2*6
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ q()
+ x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
错误: unexpected string constant in:
"q()
x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),""
> x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),nrow=3,ncol=3),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
+ x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
错误: unexpected string constant in:
" x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),nrow=3,ncol=3),"'don'' ''qulxote",factor(x=c("LOW","MED","MED",HIGH")))
x1<-list(seq(from=-4,to=40,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),dim=c(3,3)),""
> x1<-list(seq(from=-4,to=4,length=20),matrix(data=c(F,T,T,T,F,T,T,F,F),nrow=3,ncol=3),"donqulxote",factor(x=c("LOW","MED","MED","HIGH")))
> x1
[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368 -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789 1.0526316 1.4736842 1.8947368 2.3157895
[17] 2.7368421 3.1578947 3.5789474 4.0000000
[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
[[3]]
[1] "donqulxote"
[[4]]
[1] LOW MED MED HIGH
Levels: HIGH LOW MED
> x1[[2]][c(2,1),c(2,3)]
[,1] [,2]
[1,] FALSE FALSE
[2,] TRUE TRUE
> sub(pattern="Qulxote",replacement="qulxote",x=x1[[3]])
[1] "donqulxote"
> sub(pattern="Qulxote",replacement="qulxote",x=x1[3])
[1] "donqulxote"
> sub(pattern="Qulxote",replacement="qulxote",x=x1)
[1] "c(-4, -3.57894736842105, -3.15789473684211, -2.73684210526316, -2.31578947368421, -1.89473684210526, -1.47368421052632, -1.05263157894737, -0.631578947368421, -0.210526315789474, 0.210526315789473, 0.631578947368421, 1.05263157894737, 1.47368421052632, 1.89473684210526, 2.31578947368421, 2.73684210526316, 3.1578947368421, 3.57894736842105, 4)"
[2] "c(FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE)"
[3] "donqulxote"
[4] "c(2, 3, 3, 1)"
> sub(pattern="Qulxote",replacement="qulxote",x=x1[[3]])
[1] "donqulxote"
> sub(pattern="Qulxote",replacement="qulxote",x=(x1[[3]]))
[1] "donqulxote"
> install(sub)
Error in install(sub) : 没有"install"这个函数
> install.packages(sub)
将程序包安装入‘C:/Users/dell/Documents/R/win-library/3.6’
(因为‘lib’没有被指定)
Error in endsWith(pkgs, ".zip") : non-character object(s)
> install.packages("sub")
将程序包安装入‘C:/Users/dell/Documents/R/win-library/3.6’
(因为‘lib’没有被指定)
--- 在此連線階段时请选用CRAN的鏡子 ---
Warning message:
package ‘sub’ is not available (for R version 3.6.2)
> x1<-list(seq(from=-4,to=4,length=20),matrix(c(F,T,T,T,F,T,T,F,F),nrow=3,ncol=3),c("don","quixote"),factor(x=c("LOW","MED","LOW","MED","MED","HIGH")))
> x1
[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368 -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789 1.0526316 1.4736842 1.8947368 2.3157895
[17] 2.7368421 3.1578947 3.5789474 4.0000000
[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
[[3]]
[1] "don" "quixote"
[[4]]
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
> sub(pattern="Qulxote",replacement="qulxote",x=(x1[[3]]))
[1] "don" "quixote"
> x1
[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
[[3]]
[1] "don" "quixote"
[[4]]
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
> sub(pattern="Quixote",replacement="quixote",x=(x1[[3]]))
[1] "don" "quixote"
> sub(pattern="d",replacement="D",x=foo[[3]][1])
Error in foo[[3]] : 下标出界
> sub(pattern="d",replacement="D",x=x1[[3]][1])
[1] "Don"
> sub(pattern="q",replacement="Q",x=x1[[3]][2])
[1] "Quixote"
> sub(pattern="Quixote",replacement="quixote",x=(x1[[3]][2]))
[1] "quixote"
> sub(pattern="Q",replacement="q",x=(x1[[3]][2]))
[1] "quixote"
> sub(pattern="quixote",replacement="Quixote",x=(x1[[3]]))
[1] "don" "Quixote"
> x1<-sub(pattern="d",replacement="D",x=x1[[3]][1])
> x1
[1] "Don"
> x1<-list(seq(from=-4,to=4,length=20),matrix(c(F,T,T,T,F,T,T,F,F),nrow=3,ncol=3),c("don","quixote"),factor(x=c("LOW","MED","LOW","MED","MED","HIGH")))
> x1[[3]][1]<-sub(pattern="d",replacement="D",x=x1[[3]][1])
> x1
[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
[[3]]
[1] "Don" "quixote"
[[4]]
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
> x1[[3]][2]<-sub(pattern="q",replacement="Q",x=x1[[3]][2])
> x1
[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
[[3]]
[1] "Don" "Quixote"
[[4]]
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
> cat("\"Windmills! ATTACK!\"\n\t-\\",foo[[3]][1]," ",foo[[3]][2],"/-",sep="")
Error in foo[[3]] : 下标出界
> cat("\"Windmills! ATTACK!\"\n\t-\\",x1[[3]][1]," ",x1[[3]][2],"/-",sep="")
"Windmills! ATTACK!"
-\Don Quixote/->
> bar <- list(facs=foo[[4]],nums=c(3,2.1,3.3,4,1.5,4.9),oldlist=foo[1:3])
Error in foo[[4]] : 下标出界
> bar <- list(facs=x1[[4]],nums=c(3,2.1,3.3,4,1.5,4.9),oldlist=x1[1:3])
> [bar$nums>=3]
错误: 意外的'[' in "["
> bar$nums>=3
[1] TRUE FALSE TRUE TRUE FALSE TRUE
> bar$facs[TRUE FALSE TRUE TRUE FALSE TRUE]
错误: unexpected numeric constant in "bar$facs[TRUE FALSE"
> bar$facs[bar$nums>=3]
[1] LOW LOW MED HIGH
Levels: HIGH LOW MED
> x1[[1]]>1
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[13] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> c(x1[[1]]>1)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[13] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> x2<-(x[[1]]>1)
> x2
[1] TRUE
> x2<-(x[[1]][1:20]>1)
> x2
[1] TRUE NA NA NA NA NA NA NA NA NA NA NA NA NA
[15] NA NA NA NA NA NA
> x2<-(x[[1]][which(x[[1]]>1)))
错误: 意外的')' in "x2<-(x[[1]][which(x[[1]]>1))"
> x2<-x[[1]][which(x[[1]]>1))]
错误: 意外的')' in "x2<-x[[1]][which(x[[1]]>1))"
> x2<-x[[1]][which(x[[1]]>1)]
> x2
[1] "23.3"
> x1[[1]][x1[[1]]>1]
[1] 1.052632 1.473684 1.894737 2.315789 2.736842 3.157895 3.578947 4.000000
> which(x1[[4]]=="MED)
+ which(x1[[4]]=="MED")
错误: unexpected symbol in:
"which(x1[[4]]=="MED)
which(x1[[4]]=="MED"
> which(x1[[4]]=="MED")
[1] 2 4 5
> LIEBIAO<-list(facs=x1[[4]],nums=c(3,2.1,3.3,4,1.5,4.9),oldlist=x1[[c(1,2,3)]])
Error in x1[[c(1, 2, 3)]] : 递回索引在2层失败
> LIEBIAO<-list(facs=x1[[4]],nums=c(3,2.1,3.3,4,1.5,4.9),oldlist=x1[c(1,2,3)])
> LIEBIAO
$facs
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
$nums
[1] 3.0 2.1 3.3 4.0 1.5 4.9
$oldlist
$oldlist[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
$oldlist[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
$oldlist[[3]]
[1] "Don" "Quixote"
> LIEBIAO$facs[LIEBIAO$nums>=3]
[1] LOW LOW MED HIGH
Levels: HIGH LOW MED
> LIEBIAO$flags<-c(rep(LIEBIAO$oldlist[[2]][,3],times=2))
> LIEBIAO
$facs
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
$nums
[1] 3.0 2.1 3.3 4.0 1.5 4.9
$oldlist
$oldlist[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
$oldlist[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
$oldlist[[3]]
[1] "Don" "Quixote"
$flags
[1] TRUE FALSE FALSE TRUE FALSE FALSE
> LIEBIAO$num[!LIEBIAO$flags[[1,3]]]
Error in LIEBIAO$flags[[1, 3]] : 下标数目不对
> LIEBIAO$num[LIEBIAO$flags[[1,3]]!=T]
Error in LIEBIAO$flags[[1, 3]] : 下标数目不对
> LIEBIAO$num[LIEBIAO$flags[1,3]!=T]
Error in LIEBIAO$flags[1, 3] : 量度数目不对
> LIEBIAO$num[LIEBIAO$flags[1,3]!=TRUE]
Error in LIEBIAO$flags[1, 3] : 量度数目不对
> LIEBIAO$nums[LIEBIAO$flags[1,3]!=TRUE]
Error in LIEBIAO$flags[1, 3] : 量度数目不对
> LIEBIAO$nums[LIEBIAO$flags!=TRUE]
[1] 2.1 3.3 1.5 4.9
>
> LIEBIAO$nums[!LIEBIAO$flags]
[1] 2.1 3.3 1.5 4.9
> LIEBIAO$oldlist[[3]]<-"Don Quixote"
> LIEBIAO
$facs
[1] LOW MED LOW MED MED HIGH
Levels: HIGH LOW MED
$nums
[1] 3.0 2.1 3.3 4.0 1.5 4.9
$oldlist
$oldlist[[1]]
[1] -4.0000000 -3.5789474 -3.1578947 -2.7368421 -2.3157895 -1.8947368
[7] -1.4736842 -1.0526316 -0.6315789 -0.2105263 0.2105263 0.6315789
[13] 1.0526316 1.4736842 1.8947368 2.3157895 2.7368421 3.1578947
[19] 3.5789474 4.0000000
$oldlist[[2]]
[,1] [,2] [,3]
[1,] FALSE TRUE TRUE
[2,] TRUE FALSE FALSE
[3,] TRUE TRUE FALSE
$oldlist[[3]]
[1] "Don Quixote"
$flags
[1] TRUE FALSE FALSE TRUE FALSE FALSE
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=c("M","F","M","M","F","M"),funny=c("High","Med","Low","High","Med","Med"))
> dframe
person sex funny
1 Stan M High
2 Francine F Med
3 Steve M Low
4 Roger M High
5 Haylay F Med
6 Klause M Med
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M"),levels=("F","M")),funny=factor(x=c("High","Med","Low","High","Med","Med"),levels=("Low","Med","High")))
错误: 意外的',' in "dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M"),levels=("F","
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(x=c("M","F","M","M","F","M"),levels=("F","M")),funny=factor(x=c("High","Med","Low","High","Med","Med"),levels=("Low","Med","High")))
错误: 意外的',' in "dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(x=c("M","F","M","M","F","M"),levels=("F","
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(x=c("M","F","M","M","F","M"),levels=("F","M")),funny=factor(x=c("High","Med","Low","High","Med","Med"),levels=("Low","Med","High")))
错误: 意外的',' in "dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(x=c("M","F","M","M","F","M"),levels=("F","
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M")),funny=factor(x=c("High","Med","Low","High","Med","Med"),levels=("Low","Med","High")))
错误: 意外的',' in "dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M")),funny=factor(x=c("High","Med","Low","High","Med","Med"),levels=("Low","
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M")),funny=factor(c("High","Med","Low","High","Med","Med")))
> dframe
person sex funny
1 Stan M High
2 Francine F Med
3 Steve M Low
4 Roger M High
5 Haylay F Med
6 Klause M Med
> dframe$sex
[1] M F M M F M
Levels: F M
> dframe$funny
[1] High Med Low High Med Med
Levels: High Low Med
> dframe$person
[1] Stan Francine Steve Roger Haylay Klause
Levels: Francine Haylay Klause Roger Stan Steve
> dframe<-data.frame(person=c("Stan","Francine","Steve","Roger","Haylay","Klause"),sex=factor(c("M","F","M","M","F","M")),funny=factor(c("High","Med","Low","High","Med","Med")),stringsAsFactors=FALSE)
> dframe$person
[1] "Stan" "Francine" "Steve" "Roger" "Haylay" "Klause"
> dframe$age<-c(41,41,15,1600,21,60)
> dframe
person sex funny age
1 Stan M High 41
2 Francine F Med 41
3 Steve M Low 15
4 Roger M High 1600
5 Haylay F Med 21
6 Klause M Med 60
> dframe$age
[1] 41 41 15 1600 21 60
> y<-data.frame(dframe$person,dframe$age,dframe$sex,dframe$funny)
> y
dframe.person dframe.age dframe.sex dframe.funny
1 Stan 41 M High
2 Francine 41 F Med
3 Steve 15 M Low
4 Roger 1600 M High
5 Haylay 21 F Med
6 Klause 60 M Med
> y<-data.frame(person=dframe$person,age=dframe$age,sex=dframe$sex,funny=dframe$funny)
> y
person age sex funny
1 Stan 41 M High
2 Francine 41 F Med
3 Steve 15 M Low
4 Roger 1600 M High
5 Haylay 21 F Med
6 Klause 60 M Med
> y2<-y[-y$funny]
Error in `[.data.frame`(y, -y$funny) : undefined columns selected
此外: Warning message:
In Ops.factor(y$funny) : ‘-’ not meaningful for factors
> y2<-y[-4]
> y2
person age sex
1 Stan 41 M
2 Francine 41 F
3 Steve 15 M
4 Roger 1600 M
5 Haylay 21 F
6 Klause 60 M
> mydataframe<-cbind(y2,y)
> mydataframe
person age sex person age sex funny
1 Stan 41 M Stan 41 M High
2 Francine 41 F Francine 41 F Med
3 Steve 15 M Steve 15 M Low
4 Roger 1600 M Roger 1600 M High
5 Haylay 21 F Haylay 21 F Med
6 Klause 60 M Klause 60 M Med
> mydataframe<-rbind(y2,y)
Error in rbind(deparse.level, ...) : 变量的列数不对
> mydataframe<-rbind(dframe,y)
> mydatafarme[funny=Med|funny=High,1:2]
错误: 意外的'=' in "mydatafarme[funny=Med|funny="
> mydatafarme[(funny=Med|funny=High),1:2]
错误: 找不到对象'mydatafarme'
> mydataframe[(funny=Med|funny=High),1:2]
Error in `[.data.frame`(mydataframe, (funny = Med | funny = High), 1:2) :
找不到对象'High'
> mydataframe[(funny="Med"|funny="High"),1:2]
Error in "Med" | funny = "High" : 赋值目标擴充到非语言对象
> mydataframe[(funny=="Med"|funny=="High"),1:2]
Error in `[.data.frame`(mydataframe, (funny == "Med" | funny == "High"), :
找不到对象'funny'
> mydataframe[(mydatafram$funny=="Med"|mydataframe$funny=="High"),1:2]
Error in `[.data.frame`(mydataframe, (mydatafram$funny == "Med" | mydataframe$funny == :
找不到对象'mydatafram'
> mydataframe[(mydataframe$funny=="Med"|mydataframe$funny=="High"),1:2]
person sex
1 Stan M
2 Francine F
4 Roger M
5 Haylay F
6 Klause M
7 Stan M
8 Francine F
10 Roger M
11 Haylay F
12 Klause M
>
今日的学习感悟
学习一种语言,便是专心投入并积极主动的使用。无法静心使我不能分析所面对的事物,切记!