(A<-c(1,2,3))
(B<-"abcD")
(C<-TRUE)
is.vector(B)
is.logical(C)
(a<-rep(1:3,each=2))
(b<-rep(1:3,times=2))
(c<-seq(from=1,to=10,by=2))
(d<-seq(from=1,to=10,length=3))
e<-scan()
(f<-vector(length=10))
f[1]<-1
f[2:3]<-c(2,3)
temp<-seq(from=4,to=9,by=1)
f[c(4:9,10)]<-c(temp,10)
b<-(2:4)
f[b]
b<-c(TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)
f[b]
f[-1]
f[-(2:4)]
f[-c(1:5,10)]
b<-(2:4)
f[-b]
ls()
age<-c(22,23,24,25)
name<-c("aa","bb","cc","dd")
cm<-cbind(name,age)
dim(cm)
str(cm)
rm<-rbind(name,age)
dim(rm)
str(rm)
a<-(1:30)
dim1<-c("r1","r2","r3","r4","r5")
dim2<-c("c1","c2","c3","c4","c5","c6")
claim<-matrix(a,nrow=5,ncol = 6,byrow = FALSE,dimnames = list(dim1,dim2))
claim[2,3]
claim[1:3,1:3]
a<-c(1:3)
claim[a,c(1,3)]
head(claim,2)
tail(claim,2)
claim[2,]
claim[c(1,3),]
a<-c(TRUE,TRUE,FALSE,FALSE,TRUE)
claim[a,]
claim[,1:3]
a<-matrix(nrow = 5,ncol = 2)
a[,1]=seq(from=1,to=10,by=2)
a[,2]=seq(from=10,to=1,by=-2)
fix(claim)
claimfrm<-data.frame(fage=age,fname=name)
names(claimfrm)
str(claimfrm)
is.data.frame(claimfrm)
a<-data.frame(x1=numeric(0),x2=character(0),x3=logical(0))
str(a)
claimfrm$fage
claimfrm[["fage"]]
claimfrm[[1]]
attach(claimfrm)
fname
detach(claimfrm)
with(claimfrm,{
age<-fage+1
print(age)
})
claimfrm<-within(claimfrm,{
salary<-fage*10
})
a<-c(1:60)
dim1<-c("r1","r2","r3","r4")
dim2<-c("c1","c2","c3","c4","c5")
dim3<-c("t1","t2","t3")
a<-array(a,c(4,5,3),dimnames=list(dim1,dim2,dim3))
a[1:3,c(1,3),1]
a<-c(1,2,3)
b<-matrix(nrow = 5,ncol = 2)
b[,1]=seq(from=1,to=10,by=2)
b[,2]=seq(from=10,to=1,by=-2)
c<-array(1:7,c(4,5,3))
d<-list(L1=a,L2=b,L3=c)
names(d)
d$L1
d[["L2"]]
d[[3]]
a<-12.3
typeof(a)
is.numeric(a)
is.integer(a)
is.double(a)
is.character(a)
is.logical(a)
(a<-as.integer(a))
(a<-as.character(a))
a<-c(1:10)
as.matrix(a)
b<-matrix(a,nrow = 5,ncol = 2,byrow = FALSE)
as.vector(a)
a<-c("poor","improves","excellent","poor")
b<-as.factor(a)
b<-factor(a,order=TRUE,levels = c("poor","improves","excellent"))
b<-factor(a,order=FALSE,levels = c("poor","improves","excellent"))
b<-factor(a,order=FALSE,levels = c("poor","improves","excellent"),labels=c("C","B","A"))
gl(5,4)
as.vector(b)