library(car)
library(vcdExtra)
## Loading required package: vcd
## Loading required package: grid
## Loading required package: gnm
##
## Attaching package: 'vcdExtra'
## The following object is masked from 'package:car':
##
## Burt
library(FactoMineR)
library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
## recode(): dplyr, car
## some(): purrr, car
## summarise(): dplyr, vcdExtra
data("Womenlf")
Womenlf %>% tbl_df()
## # A tibble: 263 x 4
## partic hincome children region
## * <fctr> <int> <fctr> <fctr>
## 1 not.work 15 present Ontario
## 2 not.work 13 present Ontario
## 3 not.work 45 present Ontario
## 4 not.work 23 present Ontario
## 5 not.work 19 present Ontario
## 6 not.work 7 present Ontario
## 7 not.work 15 present Ontario
## 8 fulltime 7 present Ontario
## 9 not.work 15 present Ontario
## 10 not.work 23 present Ontario
## # ... with 253 more rows
str(Womenlf)
## 'data.frame': 263 obs. of 4 variables:
## $ partic : Factor w/ 3 levels "fulltime","not.work",..: 2 2 2 2 2 2 2 1 2 2 ...
## $ hincome : int 15 13 45 23 19 7 15 7 15 23 ...
## $ children: Factor w/ 2 levels "absent","present": 2 2 2 2 2 2 2 2 2 2 ...
## $ region : Factor w/ 5 levels "Atlantic","BC",..: 3 3 3 3 3 3 3 3 3 3 ...
このデータは、263 行(ケース)、4 列(変数)のデータフレーム data の詳細は、
?Womenlf
である。
colnames(Womenlf)
## [1] "partic" "hincome" "children" "region"
partic (勤務形態:フルタイム、仕事してない、パートタイム Labour-Force Participation. A factor with levels (note: out of order): fulltime, Working full-time; not.work, Not working outside the home; parttime, Working part-time.
hincome 夫の収入 単位$1000 Husband’s income, $1000s.
children 子供:いない、いる Presence of children in the household. A factor with levels: absent, present.
region 居住地域: A factor with levels: Atlantic, Atlantic Canada; BC, British Columbia; Ontario; Prairie, Prairie provinces; Quebec.
table(Womenlf$partic,Womenlf$children)
##
## absent present
## fulltime 46 20
## not.work 26 129
## parttime 7 35
with(Womenlf, table(partic,children))
## children
## partic absent present
## fulltime 46 20
## not.work 26 129
## parttime 7 35
xtabs(~partic + children, data=Womenlf)
## children
## partic absent present
## fulltime 46 20
## not.work 26 129
## parttime 7 35
# カイ二乗検定を行う。chisq.test(