toy's People
toy's Issues
dd
KICCE 2019 Project
install.packages('foreign')
install.packages('read_sav')
install.packages('haven')
install.packages('tidyr')
install.packages('broom')
install.packages('purrr')
library(tidyr)
library(broom)
library(purrr)
library(haven)
setwd('C:/Users/gallup/Desktop/업무/이재화 선임님')
data <- read_spss('DATA_한국아동 성장 발달 종단연구 2018_제출_19.04.04.sav')
View(data)
colnames(data)
dim(data) # 2150 1458
str(data)
attach(data)
tail(data)
"gender" Ch18dmg01 1: Male 2: Female (아동 성별)
unique(Ch18dmg01)
ftable(Ch18dmg01)
round(730/(730+704),2) # male
round(704/(730+704),2) # female
m <- subset(data, data$Ch18dmg01 ==1)
f <- subset(data, data$Ch18dmg01 ==2)
data$gender <- data$Ch18dmg01
data$gender[data$Ch18dmg01 == 1] <- "male"
data$gender[data$Ch18dmg01 == 2] <- "female"
"bor" Birth Order (D11-2). ○○(이)의 출생순위)
총 자녀 수 Hu18dmg19_k(D11-2). "가구" 가구원 수: 자녀[ 총 ( )명])
sort(unique(Ch18dmg02)) ; sort (unique(Hu18dmg19_k))
Needs to be checked
length(which(data$Hu18dmg19_k==6))
length(which(data$Ch18dmg02== 5))
str(Ch18dmg02)
str(Hu18dmg19_k)
length(which(data$Ch18dmg02 == 1)) #667
length(which(data$Hu18dmg19_k==1)) #150
one <- subset(data, data$Ch18dmg02 == 1 & data$Hu18dmg19_k == 1) #149
first <- subset(data, data$Ch18dmg02 == 1 & data$Hu18dmg19_k > 1) #518
dim(only) ; dim(first)
View(data)
data$bor <- data$Ch18dmg02
data$bor[data$Ch18dmg02 == 1& data$Hu18dmg19_k==1] <- "1_only"
data$bor[data$Ch18dmg02 == 1& data$Hu18dmg19_k > 1] <- "1"
data$bor[data$Ch18dmg02 >= 2]<- ">=2"
data$bor <- factor(data$bor, levels = c("1_only","1",">=2"))
data$bor
summary(data$bor)
round(149/1434, 2) #0.10
round(518/1434, 2) #0.36
round(767/1434, 2) # 0.53
"age_month" Month Age
library(stringr)
library(qdapRegex)
data$Ch18dmg06a
data$L18int03 # 조사월11월로 통일
birth_month <- "\d"
str_extract_all("0414","[0-9]{2}")[[1]][1]
birth_info <- str_extract_all(data$Ch18dmg06a,"[0-9]{2}")
birth_info[[1]]
#for (i in 1:nrow(data))
#{print(birth_info[[i]][1])}
birth_month <- {}
for (i in 1:nrow(data)) {
birth_month[i] <- birth_info[[i]][1]
}
birth_month
length(birth_month)
data$Ch18_mob <- birth_month
data$Ch18_mob <- as.numeric(data$Ch18_mob)
for (i in 1:nrow(data)) {
data$age_month[i] <- (132 + data$Ch18_mob[i])
}
data$age_month
round(mean(data$age_month, na.rm = T),2) #137.27
round(sd(data$age_month, na.rm = T),2) # 0.94
"workingmom" Working Mom (Mt18jcg03)
Mt18jcg03
sort(unique(Mt18jcg03))
data$workingmom <- data$Mt18jcg03
data$workingmom[data$Mt18jcg03 == 1 | data$Mt18jcg03 == 3] <- "working"
data$workingmom[data$Mt18jcg03 == 2 | data$Mt18jcg03 == 4] <- "non-working"
ftable(data$Mt18jcg03)
ftable(data$workingmom)
"income" Hu18ses06
data$income <- data$Hu18ses06
data$income[data$Hu18ses06 <= 340] <- 1
data$income[data$Hu18ses06 > 340 & data$Hu18ses06 <= 400] <- 2
data$income[data$Hu18ses06 > 400 & data$Hu18ses06 <= 530] <- 3
data$income[data$Hu18ses06 > 530] <- 4
ftable(data$income)
"mtedu" Mt18dmg14
data$mtedu <- data$Mt18dmg14
data$mtedu[data$Mt18dmg14 <=4] <- 1
data$mtedu[data$Mt18dmg14 == 5] <- 2
data$mtedu[data$Mt18dmg14 >=6] <- 3
ftable(data$mtedu)
"ftedu" Ft18dmg14
data$ftedu <- data$Ft18dmg14
data$ftedu[data$Ft18dmg14 <=4] <- 1
data$ftedu[data$Ft18dmg14 == 5] <- 2
data$ftedu[data$Ft18dmg14 >=6] <- 3
ftable(data$ftedu)
"mtincome" Mt18ses08
data$mtincome <- data$Mt18ses08
data$mtincome[data$Mt18ses08 <= 340] <- 1
data$mtincome[data$Mt18ses08 > 340 & data$Mt18ses08 <= 400] <- 2
data$mtincome[data$Mt18ses08 > 400 & data$Mt18ses08 <= 530] <- 3
data$mtincome[data$Mt18ses08 > 530] <- 4
"region" Hu18cmm02
Hu18cmm02
data$region <- data$Hu18cmm02
data$region[data$Hu18cmm02]
#Ch18dmg01
tab3.2.3 <- table(Ch18dmg01, Ch18eat01)
margin.table(tab3.2.3,1)
prop.table(tab3.2.3)
#-----------------------------------------------------------------#
7p table 3-2-6
chisq.test(male$Ch18eat01, female$Ch18eat01, equal = F)
chisq.test(data$Ch18eat01)
daily life characteristics
Eating Behavior
#Ch18eat26 ~ Ch18eat35
data$Ch18eat26 <- as.integer(Ch18eat26)
data$gender <- as.factor(data$gender)
t.test(male$Ch18eat26[male$Ch18eat26<100], female$Ch18eat26[female$Ch18eat26<100])
male <- subset(data, data$gender == "male")
female <- subset(data, data$gender == "female")
library(dplyr)
group_by(data, gender) %>%
summarise(
count = n(),
mean = mean(Ch18eat26[Ch18eat26<100], na.rm = TRUE),
sd = sd(Ch18eat26[Ch18eat26<100], na.rm = TRUE)
)
unique(data$Ch18eat26)
data$Ch18eat26
Ch18eat26r <- data$Ch18eat26[Ch18eat26<100]
length(Ch18eat26r)
Ch18eat26r <- 4-Ch18eat26r
head(Ch18eat26r)
head(Ch18eat26)
library(dplyr)
group_by(data, gender) %>%
summarise(
count = n(),
mean = mean(Ch18eat26r[Ch18eat26r<100], na.rm = TRUE),
sd = sd(Ch18eat26r[Ch18eat26r<100], na.rm = TRUE)
)
install.packages("ggpubr")
library("ggpubr")
ggboxplot(my_data, x = "gender", y = "Ch18eat26",
color = "gender", palette = c("#00AFBB", "#E7B800"),
ylab = "eating behavior", xlab = "gender")
data$Ch18eat26
#----------------------------------------------#
summary(Ch18dmg06, na.omit = TRUE)
View(Ch18dmg06)
unique(complete.cases(Ch18dmg06))
data$Ch18eat01
chisq.test(Ch18dmg01, Ch18eat01, correct = F ) # turn off Yates’ continuity correction.
t1 <- t.test(m$Ch18eat01, f$Ch18eat01, alter = 'two.sided', conf.int = TRUE, conf.level = 0.95)
t2 <- t.test(only$Ch18eat01, first$Ch18eat01, )
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.