study 03/20

This commit is contained in:
2026-03-20 17:04:54 +09:00
parent 35d1cd223e
commit ae3913bf3d
6 changed files with 82 additions and 516 deletions
+63 -512
View File
@@ -1,512 +1,63 @@
str(x3) View(BMI)
str(x7) str(BMI)
x7 = 'FLASE' BMI$religion <- factor(BMI$religion,
str(x7) levels=c("Bu", "C1", "C2","No"),
x6 = 'false' # character labels=c("불교", "개신교", "가톨릭", "없음"))
str(x7) # 범주형 관측항목 추가
x8 = 8.8 BMI$종교 <- factor(BMI$religion,
x8 = 8.8 levels=c("Bu", "C1", "C2","No"),
str(x8) labels=c("불교", "개신교", "가톨릭", "없음"))
xx1 <- c(1:100) # 범주형 관측항목 추가
xx1 BMI$종교 <- factor(BMI$religion,
xx1 <- c(1:100) levels=c("Bu", "C1", "C2","No"),
xx1 labels=c("불교", "개신교", "가톨릭", "없음"))
is.na() BMI$종교 <- factor(BMI$religion,
is.na(xx1) levels=c("Bu", "C1", "C2","No"),
table(is.na(xx1)) labels=c("불교", "개신교", "가톨릭", "없음"))
x1 = c(1,'love',TRUE,2+3i) # 범주형 관측항목 추가
x1 BMI$종교_1 <- factor(BMI$종교,
install.packages('ggplot2') levels=c("Bu", "C1", "C2","No"),
install.packages('dplyr') labels=c("불교", "개신교", "가톨릭", "없음"))
v1 = c(27,35,47,41) str(BMI)
mode(v1) # 범주형 관측항목 추가
is.numeric(v1) BMI$종교_1 <- factor(BMI$종교,
is.na(v1) levels=c("Bu", "C1", "C2","No"),
table(is.na(v1)) labels=c("불교", "개신교", "가톨릭", "없음"))
xx1 <- c(1:100) str(BMI)
v2 = c(27,35,47,NA,55) # 범주형 관측항목 추가
mode(v2) BMI$종교_1 <- factor(BMI$종교,
is.numeric(v2) levels=c("Bu", "C1", "C2","No"),
is.na(v2) labels=c("불교", "개신교", "가톨릭", "없음"))
table(is.na(v1)) str(BMI)
table(is.na(v1)) # 범주형 관측항목 추가
table(is.na(v1)) BMI$종교_1 <- factor(BMI$종교,
table(is.na(v2)) levels=c("Bu", "C1", "C2","No"),
length(vw) labels=c("불교", "개신교", "가톨릭", "없음"))
length(v1) str(BMI)
length(v2) # 범주형 관측항목 추가
names(v1) BMI$종교_1 <- factor(BMI$종교,
names(v1) = c('kim','lee','park','choi') levels=c("Bu", "C1", "C2","No"),
names(v1) labels=c("불교", "개신교", "가톨릭", "없음"))
v1 str(BMI)
v1[0] # 범주형 관측항목 추가
## 기초 명령어 실습 ## BMI$종교_1 <- factor(BMI$종교,
1+1 levels=c("Bu", "C1", "C2","No"),
1:10 labels=c("불교", "개신교", "가톨릭", "없음"))
dd = c(1:10) str(BMI)
## c() -> 같은 종류의 요소(numeric, int, float등)만 있을때 table(BMI$종교)
## list() -> 다양한 종류의 요소가 들어올때 table(BMI$종교_1)
dd[-10] barplot(table(BMI$종교_1), col=1:4)
## 기본유형 ## barplot(table(BMI$종교_1), col=1:4, main='종교대이터의 인원수')
x1 = 3 # numeric barplot(table(BMI$종교_1), col=1:4, main='종교대이터의 인원수',ylab = ;'명',xlab='종교', sub='본그래프는 종교의 인원수를 나타내는 그래프_전북대학교_2026_평생교육유ㅗㄴ')
x2 = "Love is choice" # character barplot(table(BMI$종교_1), col=1:4, main='종교대이터의 인원수',ylab = '명',xlab='종교', sub='본그래프는 종교의 인원수를 나타내는 그래프_전북대학교_2026_평생교육원')
x3 = FALSE # logical View(m3)
x4 = 3-2i # complex # 시각화
x5 = '123' # character par(family = "AppleGothic")
x6 = 'false' # character barplot(table(BMI$종교_1), col=1:4, main='종교대이터의 인원수',ylab = '명',xlab='종교', sub='본그래프는 종교의 인원수를 나타내는 그래프_전북대학교_2026_평생교육원')
x7 = 'FLASE' # character BMI$판정 <- ordered(BMI$등급,
str(x1) levels=seq(1,5),
### 문자 - 정수 - 논리 labels=c("저체중", "정상", "과체중", "초기비만", "비만"))
### 결측값은 95%까지 table(BMI$판정)
### 정규분포는 30번이상한것으로 해야한다 barplot(table(BMI$판정), col=1:5,
xx1 <- c(1:100) main='BMI 판정',ylab = '명',xlab='등급',
xx1 sub='본그래프는 BMI의 인원수를 나타내는 그래프_전북대학교_2026_평생교육원')
is.na(xx1)
table(is.na(xx1))
x1 = c(1,'love',TRUE,2+3i)
x1
v1 = c(27,35,47,41)
mode(v1)
is.numeric(v1)
is.na(v1)
table(is.na(v1))
v2 = c(27,35,47,NA,55)
mode(v2)
is.numeric(v2)
is.na(v2)
table(is.na(v2))
length(v1)
length(v2)
names(v1)
names(v1) = c('kim','lee','park','choi')
names(v1)
## indexing ## 대괄호 == [ ] => 추출해라
v1
v1[1]
v1[1:3]
v1[-1]
v1[:-1]
v1[1:-1]
v1[-1]
v1[1:3]
v1[-4]
v1[1,3]
v1[3:-1]
v1[c(2,4)]
v1[-4]
v1 = 1:3
v2 = 4:6
v3 = v1+v2
v3 = v1+v2
v1 = 1:3
v2 = 1:6
v3 = v1+v2
v3
gender = c('m','f','f','m','f','f')
gender_facotr = factor(gender)
levels(gender_facotr)
gender = c('m','f','f','m','f','f')
gender_facotr = factor(gender)
levels(gender_facotr)
gender_factor2 = factor(gender, levels = c('m','f'), labels = c('남자','여자'))
gender_factor2
install.packages(c("cluster", "lattice", "viridisLite"))
gender_factor3
gender_factor3 = factor(gender,ordered = TRUE)
gender_factor3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = m2 cbind(v1,v2)
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = m2 cbind(v1,v2)
1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 =
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = cbind(v1,v2)
m2
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = cbind(v1,v2)
m1
m2
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = cbind(v1,v2)
v1
v2
m1
m2
m1[2,1]
m1[2,1] == 8
m1
[2,1] == 8
m1
m1
m1[2,1] == 8
m1[2,1] = 8
m1
m1[,3]
is.na(m1)
table(is.na(m1))
m1[1,1] = NA
m1
table(is.na(m1))
m1[2,3] = NA
table(is.na(m1))
str(m1)
m3 = matrix(1:4, nrow = 2,ncol = 2)
m3
m4 = matrix(1:4, nrow = 2,ncol = 2,byrow = TRUE)
m4
m3
m4
m4[2,1] = NA
a1 = array(1:10, dim=10)
a2 = array(1:10, dim=c(2, 5))
a3 = array(1:10, dim=c(3, 3, 4))
a1
a2
a3
a3[,,2][3,3]
a3[,,2][3,3] = 100
a3
id = 1:5
age = c(29, 32, 47, 35, 23)
gender = c('f','m','m','f','f')
height = c(163, 177, 172, 157, 169)
DF1 = data.frame(id, age, gender, height)
DF2 = data.frame(id, age, gender, height, stringsAsFactors=FALSE)
DF1
DF2
View(DF1)
str(DF1)
DF3 = data.frame(id, age, gender, height, stringsAsFactors=TRUE)
DF3
View(DF2)
View(DF3)
str(DF2)
str(DF3)
DF4 = DF3[-1]
DF4
View(DF4)
str(DF4)
install.packages('psych')
library(psych)
describe(DF4)
## 기초 명령어 실습 ##
1+1
1:10
dd = c(1:10)
## c() -> 같은 종류의 요소(numeric, int, float등)만 있을때
## list() -> 다양한 종류의 요소가 들어올때
dd[-10]
## 기본유형 ##
x1 = 3 # numeric
x2 = "Love is choice" # character
x3 = FALSE # logical
x4 = 3-2i # complex
x5 = '123' # character
x6 = 'false' # character
x7 = 'FLASE' # character
str(x1)
### 문자 - 정수 - 논리
### 결측값은 95%까지
### 정규분포는 30번이상한것으로 해야한다
xx1 <- c(1:100)
xx1
is.na(xx1)
table(is.na(xx1))
x1 = c(1,'love',TRUE,2+3i)
x1
v1 = c(27,35,47,41)
mode(v1)
is.numeric(v1)
is.na(v1)
table(is.na(v1))
v2 = c(27,35,47,NA,55)
mode(v2)
is.numeric(v2)
is.na(v2)
table(is.na(v2))
length(v1)
length(v2)
names(v1)
names(v1) = c('kim','lee','park','choi')
names(v1)
## Indexing ## 대괄호 == [ ] => 추출해라
v1
v1[1]
v1[1:3]
v1[-4]
v1[c(2,4)]
v1 = 1:3
v2 = 4:6
v3 = v1+v2 # can add list
v1 = 1:3
v2 = 1:6
v3 = v1+v2 # reusable add
v3
### 데이터거래사
## Factor, ordered Factor (등급을 정할 수 있는)
gender = c('m','f','f','m','f','f')
gender_factor = factor(gender)
levels(gender_factor)
gender_factor2 = factor(gender, levels = c('m','f'), labels = c('남자','여자'))
gender_factor2
gender_factor3 = factor(gender,ordered = TRUE)
gender_factor3
## Matrix ##
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = cbind(v1,v2)
v1
v2
m1
m2
m1[2,1] == 8
m1[2,1] = 8
m1[,3]
is.na(m1)
table(is.na(m1))
m1[1,1] = NA
m1[2,3] = NA
table(is.na(m1))
str(m1)
m3 = matrix(1:4, nrow = 2, ncol = 2)
m4 = matrix(1:4, nrow = 2, ncol = 2, byrow = TRUE)
m3
m4[2,1] = NA
## array ##
a1 = array(1:10, dim=10)
a2 = array(1:10, dim=c(2, 5))
a3 = array(1:10, dim=c(3, 3, 4))
a1
a2
a3[,,2][3,3] = 100
a3
## DataFrame ##
id = 1:5
age = c(29, 32, 47, 35, 23)
gender = c('f','m','m','f','f')
height = c(163, 177, 172, 157, 169)
DF1 = data.frame(id, age, gender, height)
DF2 = data.frame(id, age, gender, height, stringsAsFactors=FALSE)
DF3 = data.frame(id, age, gender, height, stringsAsFactors=TRUE)
DF1
DF2
DF3
View(DF3)
str(DF3)
DF4 = DF3[-1]
DF4
View(DF4)
str(DF4)
## 기술통계량 ##
library('psych')
describe(DF4)
rownames(DF1)
colnames(DF1)
rownames(DF1) = paste('R',1:5,sep='')
rownames(DF1)
rownames(DF1) = paste('Edge',1:5,sep='')
rownames(DF1)
rownames(DF1) = paste('Edge',1:5,sep='_')
rownames(DF1)
View(DF1)
colnames(DF1) = paste(c('id','나이','성별','키'))
colnames(DF1)
colnames(DF1) = paste('id','나이','성별','키')
colnames(DF1)
colnames(DF1) = paste(c('id','나이','성별','키'))
colnames(DF1) = paste(c('아이디','나이','성별','키'))
colnames(DF1)
str(DF1)
str(DF4)
dim(DF1)
install.packages("caret")
## 기술통계량 ##
library(psych)
describe(DF4)
search()
searchpaths()
## read text data ##
k200 = read.csv(file = './data/k100.csv',header = TRUE)
k200
## 기초 명령어 실습 ##
1+1
1:10
dd = c(1:10)
## c() -> 같은 종류의 요소(numeric, int, float등)만 있을때
## list() -> 다양한 종류의 요소가 들어올때
dd[-10]
## 기본유형 ##
x1 = 3 # numeric
x2 = "Love is choice" # character
x3 = FALSE # logical
x4 = 3-2i # complex
x5 = '123' # character
x6 = 'false' # character
x7 = 'FLASE' # character
str(x1)
### 문자 - 정수 - 논리
### 결측값은 95%까지
### 정규분포는 30번이상한것으로 해야한다
xx1 <- c(1:100)
xx1
is.na(xx1)
table(is.na(xx1))
x1 = c(1,'love',TRUE,2+3i)
x1
v1 = c(27,35,47,41)
mode(v1)
is.numeric(v1)
is.na(v1)
table(is.na(v1))
v2 = c(27,35,47,NA,55)
mode(v2)
is.numeric(v2)
is.na(v2)
table(is.na(v2))
length(v1)
length(v2)
names(v1)
names(v1) = c('kim','lee','park','choi')
names(v1)
## Indexing ## 대괄호 == [ ] => 추출해라
v1
v1[1]
v1[1:3]
v1[-4]
v1[c(2,4)]
v1 = 1:3
v2 = 4:6
v3 = v1+v2 # can add list
v1 = 1:3
v2 = 1:6
v3 = v1+v2 # reusable add
v3
### 데이터거래사
## Factor, ordered Factor (등급을 정할 수 있는)
gender = c('m','f','f','m','f','f')
gender_factor = factor(gender)
levels(gender_factor)
gender_factor2 = factor(gender, levels = c('m','f'), labels = c('남자','여자'))
gender_factor2
gender_factor3 = factor(gender,ordered = TRUE)
gender_factor3
## Matrix ##
v1 = 1:3
v2 = 4:6
m1 = rbind(v1,v2)
m2 = cbind(v1,v2)
v1
v2
m1
m2
m1[2,1] == 8
m1[2,1] = 8
m1[,3]
is.na(m1)
table(is.na(m1))
m1[1,1] = NA
m1[2,3] = NA
table(is.na(m1))
str(m1)
m3 = matrix(1:4, nrow = 2, ncol = 2)
m4 = matrix(1:4, nrow = 2, ncol = 2, byrow = TRUE)
m3
m4[2,1] = NA
## array ##
a1 = array(1:10, dim=10)
a2 = array(1:10, dim=c(2, 5))
a3 = array(1:10, dim=c(3, 3, 4))
a1
a2
a3[,,2][3,3] = 100
a3
## DataFrame ##
id = 1:5
age = c(29, 32, 47, 35, 23)
gender = c('f','m','m','f','f')
height = c(163, 177, 172, 157, 169)
DF1 = data.frame(id, age, gender, height)
DF2 = data.frame(id, age, gender, height, stringsAsFactors=FALSE)
DF3 = data.frame(id, age, gender, height, stringsAsFactors=TRUE)
DF1
DF2
DF3
View(DF3)
str(DF3)
DF4 = DF3[-1]
DF4
View(DF4)
str(DF4)
## 기술통계량 ##
library(psych)
describe(DF4)
rownames(DF1) = paste('Edge',1:5,sep='_')
rownames(DF1)
colnames(DF1) = paste(c('아이디','나이','성별','키'))
colnames(DF1)
dim(DF1)
searchpaths()
## read text data ##
k200 = read.csv(file = './data/k100.csv',header = TRUE)
k200
View(k200)
k300 = read.csv(file = './data/ebook.csv',header = TRUE)
View(k300)
tsv100 = read.table(file = './data/survey_tab.txt', header = TRUE, encoding = 'CP949')
tsv100 = read.table(file = './data/survey_tab.txt', header = TRUE, fileEncoding = 'CP949')
View(tsv100)
## data handling ##
library(ggplot2)
head(diamonds)
head(Titanic)
View(diamonds)
View(Titanic)
## data structure ##
str(diamonds)
str(Titanic)
View(diamonds)
head(diamonds)
## indexing ##
diamonds[ , 2]
diamonds[ , 2, drop=FALSE]
diamonds[ , c(2, 3, 7)]
diamonds[ , 7:10]
diamonds[ , seq(from=2, to=10, by=2)]
xx=diamonds[ , c(2, 3, 7)]
View(xx)
xx
ss = diamonds[,7]
describe(ss)
describe(diamonds)
diamonds[ , c('cut', 'price'
diamonds[ , 'cut']
diamonds[ , 'cut']
diamonds[ , c('cut', 'price')]
diamonds[diamonds$cut == 'Fair', ]
diamonds[diamonds$price >= 18000, ]
a
a = diamonds[diamonds$cut == 'Fair', ]
a
table(a)
= diamonds[diamonds$price >= 18000, ]
b
b = diamonds[diamonds$price >= 18000, ]
b
'Fair') & (diamonds$price >= 18000), ]
c = diamonds[(diamonds$cut == 'Fair') & (diamonds$price >= 18000), ]
d = diamonds[(diamonds$cut == 'Fair') | (diamonds$price >= 18000), ]
View(c)
View(d)
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"TabSet1": 0, "TabSet1": 0,
"TabSet2": 2, "TabSet2": 1,
"Sidebar": -1, "Sidebar": -1,
"TabZoom": {} "TabZoom": {}
} }
+2 -2
View File
@@ -2,6 +2,6 @@
"tempName": "Untitled1", "tempName": "Untitled1",
"source_window_id": "", "source_window_id": "",
"Source": "Source", "Source": "Source",
"cursorPosition": "185,54", "cursorPosition": "215,0",
"scrollLine": "172" "scrollLine": "201"
} }
+1
View File
@@ -3,6 +3,7 @@
~%2FR%20project%2Fr_study%2F%EA%B8%B0%EC%B4%88%20%EB%AA%85%EB%A0%B9%EC%96%B4%20%EC%8B%A4%EC%8A%B5.R="0CB164D0" ~%2FR%20project%2Fr_study%2F%EA%B8%B0%EC%B4%88%20%EB%AA%85%EB%A0%B9%EC%96%B4%20%EC%8B%A4%EC%8A%B5.R="0CB164D0"
~%2FR%20project%2Fr_study%2Fadvance.R="11E47905" ~%2FR%20project%2Fr_study%2Fadvance.R="11E47905"
~%2FR%20project%2Fr_study%2Fbasic.R="B0F755B1" ~%2FR%20project%2Fr_study%2Fbasic.R="B0F755B1"
~%2FR%20project%2Fr_study%2Fbmi.R="23FFD201"
~%2FR%20project%2Fr_study%2Fdata%2F%E1%84%8B%E1%85%B5%E1%86%AB%E1%84%80%E1%85%AE%E1%84%8C%E1%85%AE%E1%84%90%E1%85%A2%E1%86%A8%E1%84%8E%E1%85%A9%E1%86%BC%E1%84%8C%E1%85%A9%E1%84%89%E1%85%A12015.csv="F4F2A450" ~%2FR%20project%2Fr_study%2Fdata%2F%E1%84%8B%E1%85%B5%E1%86%AB%E1%84%80%E1%85%AE%E1%84%8C%E1%85%AE%E1%84%90%E1%85%A2%E1%86%A8%E1%84%8E%E1%85%A9%E1%86%BC%E1%84%8C%E1%85%A9%E1%84%89%E1%85%A12015.csv="F4F2A450"
~%2FR%20project%2Fr_study%2Fdata%2Febook.csv="B032A455" ~%2FR%20project%2Fr_study%2Fdata%2Febook.csv="B032A455"
~%2FR%20project%2Fr_study%2Fdata%2Fsurvey_blank.txt="36BC293B" ~%2FR%20project%2Fr_study%2Fdata%2Fsurvey_blank.txt="36BC293B"
+1 -1
View File
@@ -1,8 +1,8 @@
/Users/dh/R project/r_study/basic.R="38F7B9A1" /Users/dh/R project/r_study/basic.R="38F7B9A1"
/Users/dh/R project/r_study/bmi.R="FEED5E2B"
/Users/dh/R project/r_study/data/ebook.csv="D6CC5A14" /Users/dh/R project/r_study/data/ebook.csv="D6CC5A14"
/Users/dh/R project/r_study/data/survey_blank.txt="38B1159C" /Users/dh/R project/r_study/data/survey_blank.txt="38B1159C"
/Users/dh/R project/r_study/data/survey_comma.txt="F11DD8B3" /Users/dh/R project/r_study/data/survey_comma.txt="F11DD8B3"
/Users/dh/R project/r_study/data/survey_tab.txt="2B3FFD48" /Users/dh/R project/r_study/data/survey_tab.txt="2B3FFD48"
/Users/dh/R project/r_study/data/인구주택총조사2015.csv="034CDF16"
/Users/dh/R project/r_study/기초 실습 II.R="83772E57" /Users/dh/R project/r_study/기초 실습 II.R="83772E57"
/Users/dh/R project/r_study/기초 명령어 실습.R="CF8199EA" /Users/dh/R project/r_study/기초 명령어 실습.R="CF8199EA"
+14
View File
@@ -173,8 +173,10 @@ library(ggplot2)
head(diamonds) head(diamonds)
View(diamonds) View(diamonds)
tail(diamonds)
head(Titanic) head(Titanic)
View(Titanic) View(Titanic)
tail(Titanic)
## data structure ## ## data structure ##
str(diamonds) str(diamonds)
@@ -199,3 +201,15 @@ b = diamonds[diamonds$price >= 18000, ] # 다이아몬드의 가격을 기준
b b
c = diamonds[(diamonds$cut == 'Fair') & (diamonds$price >= 18000), ] c = diamonds[(diamonds$cut == 'Fair') & (diamonds$price >= 18000), ]
d = diamonds[(diamonds$cut == 'Fair') | (diamonds$price >= 18000), ] d = diamonds[(diamonds$cut == 'Fair') | (diamonds$price >= 18000), ]
diamonds$xyz = diamonds$x + diamonds$y + diamonds$z
View(diamonds)
diamonds$means = diamonds$xyz/3
kkk = diamonds[-c(10,20,30),]
str(kkk)
kkk1 = diamonds[-c(100:200),]
str(kkk1)
kkk2 = diamonds[-seq(from=1, to=length(diamonds), by=10),]
str(kkk2)