R 데이터 구조 정의
#
vec1 <-c(1,2,3,4,5)
vec1
#
tm <- matrix(1:20,nrow=5,ncol=4)
tm
cells <- c(1,26,24,68)
rnames<- c("R1","R2")
cnames<- c("C1","C2")
mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
mym
x<- matrix(1:10,nrow=2)
x
#
dim1<-c("A1","A2")
dim2<-c("B1","B2","B3")
dim3<-c("C1","C2","C3","C4")
z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
z
z[1,2,3]
#
pid<-c(1,2,3,4)
age<-c(25,34,28,52)
diabetes<-c("type1","type2","type1","type1")
status<-c("poor","improved","excellent","poor")
pdata<-data.frame(pid,age,diabetes,status)
pdata
pdata[1:2]
pdata[c("pid","age")]
pdata$age
str(pdata)
table(pdata$age,pdata$status)
attach(pdata)
table(age,status)
detach(pdata)
with(pdata,{table(age,status)})
# --- : : ( , , ); ( )
duafactor2<-c("type1","type2","type1","type1")
xx<-factor(duafactor2)
xx
status<-c("poor","improved","excellent","poor")
status<-factor(status,ordered=TRUE)
status
#
#mylist<- list(obj1,obj2.....)
g<-"my first list"
h<-c(1,2,3,4,5)
j<-matrix(1:10,nrow=5)
k<-c("one","two","three")
mylist<- list(title=g,ages=h,j,k)
mylist
mylist[[3]]
mylist[2]
mylist[["ages"]]
:
> #
> vec1 <-c(1,2,3,4,5)
> vec1
[1] 1 2 3 4 5
>
> #
> tm <- matrix(1:20,nrow=5,ncol=4)
> tm
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
>
> cells <- c(1,26,24,68)
> rnames<- c("R1","R2")
> cnames<- c("C1","C2")
> mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
> mym
C1 C2
R1 1 26
R2 24 68
>
> x<- matrix(1:10,nrow=2)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
>
> #
> dim1<-c("A1","A2")
> dim2<-c("B1","B2","B3")
> dim3<-c("C1","C2","C3","C4")
> z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
> z
, , C1
B1 B2 B3
A1 1 3 5
A2 2 4 6
, , C2
B1 B2 B3
A1 7 9 11
A2 8 10 12
, , C3
B1 B2 B3
A1 13 15 17
A2 14 16 18
, , C4
B1 B2 B3
A1 19 21 23
A2 20 22 24
> z[1,2,3]
[1] 15
>
> #
> pid<-c(1,2,3,4)
> age<-c(25,34,28,52)
> diabetes<-c("type1","type2","type1","type1")
> status<-c("poor","improved","excellent","poor")
> pdata<-data.frame(pid,age,diabetes,status)
> pdata
pid age diabetes status
1 1 25 type1 poor
2 2 34 type2 improved
3 3 28 type1 excellent
4 4 52 type1 poor
> pdata[1:2]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata[c("pid","age")]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata$age
[1] 25 34 28 52
>
> str(pdata)
'data.frame': 4 obs. of 4 variables:
$ pid : num 1 2 3 4
$ age : num 25 34 28 52
$ diabetes: Factor w/ 2 levels "type1","type2": 1 2 1 1
$ status : Factor w/ 3 levels "excellent","improved",..: 3 2 1 3
>
>
>
>
> table(pdata$age,pdata$status)
excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> attach(pdata)
_by_ .GlobalEnv:
age, diabetes, pid, status
> table(age,status)
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> detach(pdata)
>
> with(pdata,{table(age,status)})
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
>
> # --- : : ( , , ); ( )
> duafactor2<-c("type1","type2","type1","type1")
> xx<-factor(duafactor2)
> xx
[1] type1 type2 type1 type1
Levels: type1 type2
>
> status<-c("poor","improved","excellent","poor")
> status<-factor(status,ordered=TRUE)
> status
[1] poor improved excellent poor
Levels: excellent < improved < poor
>
> #
> #mylist<- list(obj1,obj2.....)
> g<-"my first list"
> h<-c(1,2,3,4,5)
> j<-matrix(1:10,nrow=5)
> k<-c("one","two","three")
> mylist<- list(title=g,ages=h,j,k)
> mylist
$title
[1] "my first list"
$ages
[1] 1 2 3 4 5
[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
[[4]]
[1] "one" "two" "three"
> mylist[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
> mylist[2]
$ages
[1] 1 2 3 4 5
> mylist[["ages"]]
[1] 1 2 3 4 5
> #
> vec1 <-c(1,2,3,4,5)
> vec1
[1] 1 2 3 4 5
>
> #
> tm <- matrix(1:20,nrow=5,ncol=4)
> tm
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
>
> cells <- c(1,26,24,68)
> rnames<- c("R1","R2")
> cnames<- c("C1","C2")
> mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
> mym
C1 C2
R1 1 26
R2 24 68
>
> x<- matrix(1:10,nrow=2)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
>
> #
> dim1<-c("A1","A2")
> dim2<-c("B1","B2","B3")
> dim3<-c("C1","C2","C3","C4")
> z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
> z
, , C1
B1 B2 B3
A1 1 3 5
A2 2 4 6
, , C2
B1 B2 B3
A1 7 9 11
A2 8 10 12
, , C3
B1 B2 B3
A1 13 15 17
A2 14 16 18
, , C4
B1 B2 B3
A1 19 21 23
A2 20 22 24
> z[1,2,3]
[1] 15
>
> #
> pid<-c(1,2,3,4)
> age<-c(25,34,28,52)
> diabetes<-c("type1","type2","type1","type1")
> status<-c("poor","improved","excellent","poor")
> pdata<-data.frame(pid,age,diabetes,status)
> pdata
pid age diabetes status
1 1 25 type1 poor
2 2 34 type2 improved
3 3 28 type1 excellent
4 4 52 type1 poor
> pdata[1:2]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata[c("pid","age")]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata$age
[1] 25 34 28 52
>
> str(pdata)
'data.frame': 4 obs. of 4 variables:
$ pid : num 1 2 3 4
$ age : num 25 34 28 52
$ diabetes: Factor w/ 2 levels "type1","type2": 1 2 1 1
$ status : Factor w/ 3 levels "excellent","improved",..: 3 2 1 3
>
>
>
>
> table(pdata$age,pdata$status)
excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> attach(pdata)
_by_ .GlobalEnv:
age, diabetes, pid, status
> table(age,status)
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> detach(pdata)
>
> with(pdata,{table(age,status)})
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
>
> # --- : : ( , , ); ( )
> duafactor2<-c("type1","type2","type1","type1")
> xx<-factor(duafactor2)
> xx
[1] type1 type2 type1 type1
Levels: type1 type2
>
> status<-c("poor","improved","excellent","poor")
> status<-factor(status,ordered=TRUE)
> status
[1] poor improved excellent poor
Levels: excellent < improved < poor
>
> #
> #mylist<- list(obj1,obj2.....)
> g<-"my first list"
> h<-c(1,2,3,4,5)
> j<-matrix(1:10,nrow=5)
> k<-c("one","two","three")
> mylist<- list(title=g,ages=h,j,k)
> mylist
$title
[1] "my first list"
$ages
[1] 1 2 3 4 5
[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
[[4]]
[1] "one" "two" "three"
> mylist[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
> mylist[2]
$ages
[1] 1 2 3 4 5
> mylist[["ages"]]
[1] 1 2 3 4 5
> #
> vec1 <-c(1,2,3,4,5)
> vec1
[1] 1 2 3 4 5
>
> #
> tm <- matrix(1:20,nrow=5,ncol=4)
> tm
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
>
> cells <- c(1,26,24,68)
> rnames<- c("R1","R2")
> cnames<- c("C1","C2")
> mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
> mym
C1 C2
R1 1 26
R2 24 68
>
> x<- matrix(1:10,nrow=2)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
>
> #
> dim1<-c("A1","A2")
> dim2<-c("B1","B2","B3")
> dim3<-c("C1","C2","C3","C4")
> z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
> z
, , C1
B1 B2 B3
A1 1 3 5
A2 2 4 6
, , C2
B1 B2 B3
A1 7 9 11
A2 8 10 12
, , C3
B1 B2 B3
A1 13 15 17
A2 14 16 18
, , C4
B1 B2 B3
A1 19 21 23
A2 20 22 24
> z[1,2,3]
[1] 15
>
> #
> pid<-c(1,2,3,4)
> age<-c(25,34,28,52)
> diabetes<-c("type1","type2","type1","type1")
> status<-c("poor","improved","excellent","poor")
> pdata<-data.frame(pid,age,diabetes,status)
> pdata
pid age diabetes status
1 1 25 type1 poor
2 2 34 type2 improved
3 3 28 type1 excellent
4 4 52 type1 poor
> pdata[1:2]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata[c("pid","age")]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata$age
[1] 25 34 28 52
>
> str(pdata)
'data.frame': 4 obs. of 4 variables:
$ pid : num 1 2 3 4
$ age : num 25 34 28 52
$ diabetes: Factor w/ 2 levels "type1","type2": 1 2 1 1
$ status : Factor w/ 3 levels "excellent","improved",..: 3 2 1 3
>
>
>
>
> table(pdata$age,pdata$status)
excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> attach(pdata)
_by_ .GlobalEnv:
age, diabetes, pid, status
> table(age,status)
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> detach(pdata)
>
> with(pdata,{table(age,status)})
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
>
> # --- : : ( , , ); ( )
> duafactor2<-c("type1","type2","type1","type1")
> xx<-factor(duafactor2)
> xx
[1] type1 type2 type1 type1
Levels: type1 type2
>
> status<-c("poor","improved","excellent","poor")
> status<-factor(status,ordered=TRUE)
> status
[1] poor improved excellent poor
Levels: excellent < improved < poor
>
> #
> #mylist<- list(obj1,obj2.....)
> g<-"my first list"
> h<-c(1,2,3,4,5)
> j<-matrix(1:10,nrow=5)
> k<-c("one","two","three")
> mylist<- list(title=g,ages=h,j,k)
> mylist
$title
[1] "my first list"
$ages
[1] 1 2 3 4 5
[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
[[4]]
[1] "one" "two" "three"
> mylist[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
> mylist[2]
$ages
[1] 1 2 3 4 5
> mylist[["ages"]]
[1] 1 2 3 4 5
> #
> vec1 <-c(1,2,3,4,5)
> vec1
[1] 1 2 3 4 5
>
> #
> tm <- matrix(1:20,nrow=5,ncol=4)
> tm
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
>
> cells <- c(1,26,24,68)
> rnames<- c("R1","R2")
> cnames<- c("C1","C2")
> mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
> mym
C1 C2
R1 1 26
R2 24 68
>
> x<- matrix(1:10,nrow=2)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
>
> #
> dim1<-c("A1","A2")
> dim2<-c("B1","B2","B3")
> dim3<-c("C1","C2","C3","C4")
> z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
> z
, , C1
B1 B2 B3
A1 1 3 5
A2 2 4 6
, , C2
B1 B2 B3
A1 7 9 11
A2 8 10 12
, , C3
B1 B2 B3
A1 13 15 17
A2 14 16 18
, , C4
B1 B2 B3
A1 19 21 23
A2 20 22 24
> z[1,2,3]
[1] 15
>
> #
> pid<-c(1,2,3,4)
> age<-c(25,34,28,52)
> diabetes<-c("type1","type2","type1","type1")
> status<-c("poor","improved","excellent","poor")
> pdata<-data.frame(pid,age,diabetes,status)
> pdata
pid age diabetes status
1 1 25 type1 poor
2 2 34 type2 improved
3 3 28 type1 excellent
4 4 52 type1 poor
> pdata[1:2]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata[c("pid","age")]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata$age
[1] 25 34 28 52
>
> str(pdata)
'data.frame': 4 obs. of 4 variables:
$ pid : num 1 2 3 4
$ age : num 25 34 28 52
$ diabetes: Factor w/ 2 levels "type1","type2": 1 2 1 1
$ status : Factor w/ 3 levels "excellent","improved",..: 3 2 1 3
>
>
>
>
> table(pdata$age,pdata$status)
excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> attach(pdata)
_by_ .GlobalEnv:
age, diabetes, pid, status
> table(age,status)
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> detach(pdata)
>
> with(pdata,{table(age,status)})
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
>
> # --- : : ( , , ); ( )
> duafactor2<-c("type1","type2","type1","type1")
> xx<-factor(duafactor2)
> xx
[1] type1 type2 type1 type1
Levels: type1 type2
>
> status<-c("poor","improved","excellent","poor")
> status<-factor(status,ordered=TRUE)
> status
[1] poor improved excellent poor
Levels: excellent < improved < poor
>
> #
> #mylist<- list(obj1,obj2.....)
> g<-"my first list"
> h<-c(1,2,3,4,5)
> j<-matrix(1:10,nrow=5)
> k<-c("one","two","three")
> mylist<- list(title=g,ages=h,j,k)
> mylist
$title
[1] "my first list"
$ages
[1] 1 2 3 4 5
[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
[[4]]
[1] "one" "two" "three"
> mylist[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
> mylist[2]
$ages
[1] 1 2 3 4 5
> mylist[["ages"]]
[1] 1 2 3 4 5
> #
> vec1 <-c(1,2,3,4,5)
> vec1
[1] 1 2 3 4 5
>
> #
> tm <- matrix(1:20,nrow=5,ncol=4)
> tm
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
>
> cells <- c(1,26,24,68)
> rnames<- c("R1","R2")
> cnames<- c("C1","C2")
> mym <-matrix(cells,nrow=2,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames))
> mym
C1 C2
R1 1 26
R2 24 68
>
> x<- matrix(1:10,nrow=2)
> x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
>
> #
> dim1<-c("A1","A2")
> dim2<-c("B1","B2","B3")
> dim3<-c("C1","C2","C3","C4")
> z<-array(1:24,c(2,3,4),dimnames=list(dim1,dim2,dim3))
> z
, , C1
B1 B2 B3
A1 1 3 5
A2 2 4 6
, , C2
B1 B2 B3
A1 7 9 11
A2 8 10 12
, , C3
B1 B2 B3
A1 13 15 17
A2 14 16 18
, , C4
B1 B2 B3
A1 19 21 23
A2 20 22 24
> z[1,2,3]
[1] 15
>
> #
> pid<-c(1,2,3,4)
> age<-c(25,34,28,52)
> diabetes<-c("type1","type2","type1","type1")
> status<-c("poor","improved","excellent","poor")
> pdata<-data.frame(pid,age,diabetes,status)
> pdata
pid age diabetes status
1 1 25 type1 poor
2 2 34 type2 improved
3 3 28 type1 excellent
4 4 52 type1 poor
> pdata[1:2]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata[c("pid","age")]
pid age
1 1 25
2 2 34
3 3 28
4 4 52
> pdata$age
[1] 25 34 28 52
>
> str(pdata)
'data.frame': 4 obs. of 4 variables:
$ pid : num 1 2 3 4
$ age : num 25 34 28 52
$ diabetes: Factor w/ 2 levels "type1","type2": 1 2 1 1
$ status : Factor w/ 3 levels "excellent","improved",..: 3 2 1 3
>
>
>
>
> table(pdata$age,pdata$status)
excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> attach(pdata)
_by_ .GlobalEnv:
age, diabetes, pid, status
> table(age,status)
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
> detach(pdata)
>
> with(pdata,{table(age,status)})
status
age excellent improved poor
25 0 0 1
28 1 0 0
34 0 1 0
52 0 0 1
>
> # --- : : ( , , ); ( )
> duafactor2<-c("type1","type2","type1","type1")
> xx<-factor(duafactor2)
> xx
[1] type1 type2 type1 type1
Levels: type1 type2
>
> status<-c("poor","improved","excellent","poor")
> status<-factor(status,ordered=TRUE)
> status
[1] poor improved excellent poor
Levels: excellent < improved < poor
>
> #
> #mylist<- list(obj1,obj2.....)
> g<-"my first list"
> h<-c(1,2,3,4,5)
> j<-matrix(1:10,nrow=5)
> k<-c("one","two","three")
> mylist<- list(title=g,ages=h,j,k)
> mylist
$title
[1] "my first list"
$ages
[1] 1 2 3 4 5
[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
[[4]]
[1] "one" "two" "three"
> mylist[[3]]
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
> mylist[2]
$ages
[1] 1 2 3 4 5
> mylist[["ages"]]
[1] 1 2 3 4 5
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.