library(tidyverse) # for the map() command
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(psych)
##
## Attaching package: 'psych'
##
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library(naniar)
library(expss)
## Loading required package: maditr
##
## To drop variable use NULL: let(mtcars, am = NULL) %>% head()
##
##
## Attaching package: 'maditr'
##
## The following objects are masked from 'package:dplyr':
##
## between, coalesce, first, last
##
## The following object is masked from 'package:purrr':
##
## transpose
##
## The following object is masked from 'package:readr':
##
## cols
##
##
## Attaching package: 'expss'
##
## The following object is masked from 'package:naniar':
##
## is_na
##
## The following objects are masked from 'package:stringr':
##
## fixed, regex
##
## The following objects are masked from 'package:dplyr':
##
## compute, contains, na_if, recode, vars, where
##
## The following objects are masked from 'package:purrr':
##
## keep, modify, modify_if, when
##
## The following objects are masked from 'package:tidyr':
##
## contains, nest
##
## The following object is masked from 'package:ggplot2':
##
## vars
# use the read.csv() command to import your downloaded CSV file
df <- read.csv(file="data/EAMMi2-Data1.2.csv", header=T)
# use the names() command to view the list of columns or variables in your dataframe
names(df)
## [1] "StartDate" "EndDate" "Status"
## [4] "Progress" "Duration..in.seconds." "Finished"
## [7] "RecordedDate" "ResponseId" "RecipientLastName"
## [10] "RecipientFirstName" "RecipientEmail" "ExternalReference"
## [13] "DistributionChannel" "informedconsent" "moa1.1_1"
## [16] "moa1.1_2" "moa1.1_3" "moa1.1_4"
## [19] "moa1.1_5" "moa1.1_6" "moa1.1_7"
## [22] "moa1.1_8" "moa1.1_9" "moa1.1_10"
## [25] "moa1.2_1" "moa1.2_2" "moa1.2_3"
## [28] "moa1.2_4" "moa1.2_5" "moa1.2_6"
## [31] "moa1.2_7" "moa1.2_8" "moa1.2_9"
## [34] "moa1.2_10" "moa2.1_1" "moa2.1_2"
## [37] "moa2.1_3" "moa2.1_4" "moa2.1_5"
## [40] "moa2.1_6" "moa2.1_7" "moa2.1_8"
## [43] "moa2.1_9" "moa2.1_10" "moa2.2_1"
## [46] "moa2.2_2" "moa2.2_3" "moa2.2_4"
## [49] "moa2.2_5" "moa2.2_6" "moa2.2_7"
## [52] "moa2.2_8" "moa2.2_9" "moa2.2_10"
## [55] "adult_Q" "MOA_IMP_biascheck" "MOA_ach_biascheck"
## [58] "MOA_IMP_dummy" "MOA.ACH_dummy" "Q65_First.Click"
## [61] "Q65_Last.Click" "Q65_Page.Submit" "Q65_Click.Count"
## [64] "IDEA_1" "IDEA_2" "IDEA_3"
## [67] "IDEA_4" "IDEA_5" "IDEA_6"
## [70] "IDEA_7" "IDEA_8" "IDEA.biascheck"
## [73] "IDEA.bias.dummy" "Q66_First.Click" "Q66_Last.Click"
## [76] "Q66_Page.Submit" "Q66_Click.Count" "politics"
## [79] "party" "president" "Q74_First.Click"
## [82] "Q74_Last.Click" "Q74_Page.Submit" "Q74_Click.Count"
## [85] "swb_1" "swb_2" "swb_3"
## [88] "swb_4" "swb_5" "swb_6"
## [91] "Q67_First.Click" "Q67_Last.Click" "Q67_Page.Submit"
## [94] "Q67_Click.Count" "mindful_1" "mindful_2"
## [97] "mindful_3" "mindful_4" "mindful_5"
## [100] "mindful_6" "mindful_7" "mindful_8"
## [103] "mindful_9" "mindful_10" "mindful_11"
## [106] "mindful_12" "mindful_13" "mindful_14"
## [109] "mindful_15" "mindful_biascheck" "mindful_bias_dummy"
## [112] "Q68_First.Click" "Q68_Last.Click" "Q68_Page.Submit"
## [115] "Q68_Click.Count" "belong_1" "belong_2"
## [118] "belong_3" "belong_4" "belong_5"
## [121] "belong_6" "belong_7" "belong_8"
## [124] "belong_9" "belong_10" "belnow"
## [127] "belong_biascheck" "belong_bias_dummy" "Q72_First.Click"
## [130] "Q72_Last.Click" "Q72_Page.Submit" "Q72_Click.Count"
## [133] "efficacy_1" "efficacy_2" "efficacy_3"
## [136] "efficacy_4" "efficacy_5" "efficacy_6"
## [139] "efficacy_7" "efficacy_8" "efficacy_9"
## [142] "efficacy_10" "efficacy_biascheck" "efficacy_bias_dummy"
## [145] "Q77_First.Click" "Q77_Last.Click" "Q77_Page.Submit"
## [148] "Q77_Click.Count" "support_1" "support_2"
## [151] "support_3" "support_4" "support_5"
## [154] "support_6" "support_7" "support_8"
## [157] "support_9" "support_10" "support_11"
## [160] "support_12" "support_biascheck" "support_bias_dummy"
## [163] "Q96_First.Click" "Q96_Last.Click" "Q96_Page.Submit"
## [166] "Q96_Click.Count" "SocMedia_1" "SocMedia_2"
## [169] "SocMedia_3" "SocMedia_4" "SocMedia_5"
## [172] "SocMedia_6" "SocMedia_7" "SocMedia_8"
## [175] "SocMedia_9" "SocMedia_10" "SocMedia_11"
## [178] "SocMedia_biascheck" "SocMedia_bias_dummy" "Q80_First.Click"
## [181] "Q80_Last.Click" "Q80_Page.Submit" "Q80_Click.Count"
## [184] "usdream_1" "usdream_2" "usdream_3"
## [187] "Q73_First.Click" "Q73_Last.Click" "Q73_Page.Submit"
## [190] "Q73_Click.Count" "freq" "transgres"
## [193] "relation" "relation_10_TEXT" "fault"
## [196] "feel" "common" "attenion2"
## [199] "Q78_First.Click" "Q78_Last.Click" "Q78_Page.Submit"
## [202] "Q78_Click.Count" "transgres_1" "transgres_2"
## [205] "transgres_3" "transgres_4" "Q79_First.Click"
## [208] "Q79_Last.Click" "Q79_Page.Submit" "Q79_Click.Count"
## [211] "NPI1" "NPI2" "NPI3"
## [214] "NPI4" "NPI5" "NPI6"
## [217] "NPI7" "NPI8" "NPI9"
## [220] "NPI10" "NPI11" "NPI12"
## [223] "NPI13" "exploit_1" "exploit_2"
## [226] "exploit_3" "NPI_biascheck" "NPI_bias_dummy"
## [229] "Q76_First.Click" "Q76_Last.Click" "Q76_Page.Submit"
## [232] "Q76_Click.Count" "Q11" "Q14_1"
## [235] "Q14_2" "Q14_3" "Q14_4"
## [238] "Q14_5" "Q14_6" "Q14_6_TEXT"
## [241] "Q10_1" "Q10_2" "Q10_3"
## [244] "Q10_4" "Q10_5" "Q10_6"
## [247] "Q10_7" "Q10_8" "Q10_9"
## [250] "Q10_10" "Q10_11" "Q10_12"
## [253] "Q10_13" "Q10_14" "Q10_15"
## [256] "Q71_First.Click" "Q71_Last.Click" "Q71_Page.Submit"
## [259] "Q71_Click.Count" "physSx_1" "physSx_2"
## [262] "physSx_3" "physSx_4" "physSx_5"
## [265] "physSx_6" "physSx_7" "physSx_8"
## [268] "physSx_9" "physSx_10" "physSx_11"
## [271] "physSx_12" "physSx_13" "phys_sx_biaschec"
## [274] "phys_sym_bias_dummy." "Q70_First.Click" "Q70_Last.Click"
## [277] "Q70_Page.Submit" "Q70_Click.Count" "stress_1"
## [280] "stress_2" "stress_3" "stress_4"
## [283] "stress_5" "stress_6" "stress_7"
## [286] "stress_8" "stress_9" "stress_10"
## [289] "stress_biascheck" "stress_bias_dummy" "Q69_First.Click"
## [292] "Q69_Last.Click" "Q69_Page.Submit" "Q69_Click.Count"
## [295] "marriage1_1" "marriage1_2" "marriage1_3"
## [298] "marriage1_4" "marriage2" "marriage3"
## [301] "marriage4" "marriage5" "Q75_First.Click"
## [304] "Q75_Last.Click" "Q75_Page.Submit" "Q75_Click.Count"
## [307] "school" "sex" "age"
## [310] "edu" "sibling" "race"
## [313] "race_6_TEXT" "Q82" "Q83"
## [316] "income" "place2" "Q80"
## [319] "place" "Q81" "Q81_First.Click"
## [322] "Q81_Last.Click" "Q81_Page.Submit" "Q81_Click.Count"
## [325] "comments" "affiliation" "response_bias_SUM"
## [328] "school_coded"
# use the head() command to view the first few lines of your dataframe
head(df)
## StartDate EndDate Status Progress Duration..in.seconds. Finished
## 1 12/02/16 12/02/16 0 100 1839 1
## 2 11/16/16 11/16/16 0 100 1467 1
## 3 11/09/16 11/09/16 0 99 2185 0
## 4 11/07/16 11/07/16 0 100 2904 1
## 5 11/18/16 11/18/16 0 100 1229 1
## 6 11/07/16 11/07/16 0 100 2068 1
## RecordedDate ResponseId RecipientLastName RecipientFirstName
## 1 12/2/2016 5:38 R_BJN3bQqi1zUMid3 NA NA
## 2 11/16/2016 11:53 R_2TGbiBXmAtxywsD NA NA
## 3 11/16/2016 1:22 R_12G7bIqN2wB2N65 NA NA
## 4 11/7/2016 4:54 R_39pldNoon8CePfP NA NA
## 5 11/18/2016 0:30 R_1QiKb2LdJo1Bhvv NA NA
## 6 11/7/2016 14:42 R_pmwDTZyCyCycXwB NA NA
## RecipientEmail ExternalReference DistributionChannel informedconsent moa1.1_1
## 1 NA NA anonymous 1 4
## 2 NA NA anonymous 1 4
## 3 NA NA anonymous 1 4
## 4 NA NA anonymous 1 4
## 5 NA NA anonymous 1 4
## 6 NA NA anonymous 1 4
## moa1.1_2 moa1.1_3 moa1.1_4 moa1.1_5 moa1.1_6 moa1.1_7 moa1.1_8 moa1.1_9
## 1 4 3 2 2 3 2 1 4
## 2 4 4 2 3 3 4 3 3
## 3 4 4 1 1 4 2 3 4
## 4 3 3 1 1 2 1 1 1
## 5 4 4 1 1 3 1 1 4
## 6 3 4 2 3 4 2 1 3
## moa1.1_10 moa1.2_1 moa1.2_2 moa1.2_3 moa1.2_4 moa1.2_5 moa1.2_6 moa1.2_7
## 1 3 2 1 2 1 1 1 2
## 2 3 1 1 2 2 1 1 1
## 3 3 2 1 1 1 1 1 2
## 4 1 1 1 1 1 1 1 2
## 5 3 2 1 2 1 3 3 1
## 6 4 1 1 1 1 1 1 1
## moa1.2_8 moa1.2_9 moa1.2_10 moa2.1_1 moa2.1_2 moa2.1_3 moa2.1_4 moa2.1_5
## 1 3 3 2 4 4 4 4 3
## 2 1 2 3 3 4 2 4 4
## 3 3 3 3 4 2 2 4 3
## 4 3 2 3 4 2 2 4 3
## 5 1 3 2 4 4 3 4 4
## 6 1 1 3 4 4 4 4 2
## moa2.1_6 moa2.1_7 moa2.1_8 moa2.1_9 moa2.1_10 moa2.2_1 moa2.2_2 moa2.2_3
## 1 4 4 4 3 2 2 1 1
## 2 3 2 4 2 1 3 1 2
## 3 3 4 4 3 2 2 1 1
## 4 2 4 2 3 2 2 1 1
## 5 3 4 4 3 3 3 3 3
## 6 4 3 4 4 4 2 1 1
## moa2.2_4 moa2.2_5 moa2.2_6 moa2.2_7 moa2.2_8 moa2.2_9 moa2.2_10 adult_Q
## 1 3 2 3 3 2 2 1 1
## 2 2 1 2 2 2 2 1 1
## 3 2 1 2 3 1 1 1 1
## 4 2 1 2 2 2 2 1 1
## 5 3 3 2 3 3 2 3 1
## 6 2 1 2 2 1 2 1 1
## MOA_IMP_biascheck MOA_ach_biascheck MOA_IMP_dummy MOA.ACH_dummy
## 1 64 38 0 0
## 2 62 33 0 0
## 3 61 33 0 0
## 4 46 32 0 0
## 5 62 47 0 0
## 6 67 27 0 0
## Q65_First.Click Q65_Last.Click Q65_Page.Submit Q65_Click.Count IDEA_1 IDEA_2
## 1 37.139 307.731 308.890 45 3 4
## 2 120.026 336.428 338.177 58 4 4
## 3 27.705 154.447 155.544 47 4 4
## 4 19.656 297.285 298.509 43 4 4
## 5 12.867 121.932 122.254 46 4 4
## 6 15.652 223.372 225.431 50 3 4
## IDEA_3 IDEA_4 IDEA_5 IDEA_6 IDEA_7 IDEA_8 IDEA.biascheck IDEA.bias.dummy
## 1 4 3 4 4 4 4 30 0
## 2 4 4 3 4 4 4 31 0
## 3 4 4 4 4 3 3 30 0
## 4 3 3 4 4 4 4 30 0
## 5 3 4 3 3 3 4 28 0
## 6 3 3 4 4 3 2 26 0
## Q66_First.Click Q66_Last.Click Q66_Page.Submit Q66_Click.Count politics party
## 1 44.705 86.585 87.514 11 2 3
## 2 19.927 65.200 67.162 13 1 4
## 3 23.170 51.401 52.408 11 2 8
## 4 27.467 172.797 174.119 9 8 8
## 5 23.952 52.176 53.355 9 1 8
## 6 9.475 72.935 73.937 13 8 8
## president
## 1
## 2 None, but I was a US Citizen and had a gun next to my head, I would vote for Trump
## 3 Hillary Clinton
## 4 Hillary Clinton
## 5 Sanders
## 6 No one.
## Q74_First.Click Q74_Last.Click Q74_Page.Submit Q74_Click.Count swb_1 swb_2
## 1 13.052 40.445 46.399 2 4 6
## 2 4.899 28.125 55.107 6 3 4
## 3 34.868 48.402 56.371 4 1 2
## 4 66.886 119.219 135.295 4 5 6
## 5 23.614 32.221 35.338 4 2 5
## 6 12.314 41.232 54.436 6 4 4
## swb_3 swb_4 swb_5 swb_6 Q67_First.Click Q67_Last.Click Q67_Page.Submit
## 1 5 5 3 3 9.627 40.388 41.198
## 2 5 5 4 4 8.607 29.115 29.955
## 3 2 2 2 2 37.656 53.240 54.603
## 4 6 5 6 3 13.587 55.197 56.150
## 5 5 3 2 5 6.798 22.246 23.138
## 6 6 5 1 4 7.927 44.108 48.227
## Q67_Click.Count mindful_1 mindful_2 mindful_3 mindful_4 mindful_5 mindful_6
## 1 7 4 2 2 2 4 1
## 2 7 2 2 2 1 3 1
## 3 9 2 3 1 2 3 1
## 4 7 2 2 1 2 2 1
## 5 7 4 5 3 2 4 1
## 6 7 1 4 3 3 5 1
## mindful_7 mindful_8 mindful_9 mindful_10 mindful_11 mindful_12 mindful_13
## 1 2 2 2 2 2 4 1
## 2 1 1 2 2 1 2 1
## 3 2 2 5 3 2 1 1
## 4 2 2 3 2 2 3 3
## 5 4 2 1 2 2 6 5
## 6 5 6 3 5 1 3 2
## mindful_14 mindful_15 mindful_biascheck mindful_bias_dummy Q68_First.Click
## 1 2 4 36 0 32.692
## 2 1 5 27 0 13.184
## 3 1 4 33 0 48.022
## 4 2 4 33 0 110.432
## 5 2 5 48 0 81.124
## 6 4 5 51 0 33.458
## Q68_Last.Click Q68_Page.Submit Q68_Click.Count belong_1 belong_2 belong_3
## 1 154.123 157.391 15 4 2 4
## 2 76.856 77.629 22 2 3 1
## 3 142.665 143.398 20 4 4 2
## 4 255.734 257.134 17 3 4 1
## 5 134.499 135.848 16 4 3 3
## 6 212.770 213.511 25 2 3 2
## belong_4 belong_5 belong_6 belong_7 belong_8 belong_9 belong_10 belnow
## 1 4 4 2 5 2 4 3 4
## 2 5 4 4 2 4 5 4 4
## 3 5 4 4 2 3 4 4 2
## 4 5 4 5 2 4 4 4 4
## 5 4 4 5 1 3 2 3 4
## 6 5 4 5 1 4 4 4 3
## belong_biascheck belong_bias_dummy Q72_First.Click Q72_Last.Click
## 1 38 0 8.221 80.460
## 2 38 0 6.774 65.987
## 3 38 0 5.697 71.192
## 4 40 0 6.096 86.373
## 5 36 0 58.613 121.436
## 6 37 0 6.124 70.638
## Q72_Page.Submit Q72_Click.Count efficacy_1 efficacy_2 efficacy_3 efficacy_4
## 1 82.781 13 4 3 4 3
## 2 67.158 18 3 3 3 4
## 3 72.176 13 3 3 1 2
## 4 87.231 14 4 1 2 3
## 5 122.620 11 3 3 2 3
## 6 72.503 15 3 2 3 2
## efficacy_5 efficacy_6 efficacy_7 efficacy_8 efficacy_9 efficacy_10
## 1 3 4 3 3 4 3
## 2 4 4 3 3 3 4
## 3 2 3 1 3 2 2
## 4 2 4 2 3 4 3
## 5 3 3 3 3 4 3
## 6 1 3 2 3 3 2
## efficacy_biascheck efficacy_bias_dummy Q77_First.Click Q77_Last.Click
## 1 34 0 15.372 104.315
## 2 34 0 11.711 74.768
## 3 22 0 38.964 179.667
## 4 28 0 16.050 168.886
## 5 30 0 32.150 59.030
## 6 24 0 6.259 69.817
## Q77_Page.Submit Q77_Click.Count support_1 support_2 support_3 support_4
## 1 105.195 11 7 4 6 5
## 2 75.558 21 7 7 7 6
## 3 182.727 13 6 6 5 2
## 4 170.530 10 6 6 7 3
## 5 60.273 11 6 6 5 5
## 6 70.970 13 7 7 6 6
## support_5 support_6 support_7 support_8 support_9 support_10 support_11
## 1 6 6 7 7 7 4 6
## 2 7 6 6 7 7 7 7
## 3 7 5 5 3 6 6 5
## 4 7 6 5 4 6 6 6
## 5 6 6 7 6 6 6 7
## 6 7 2 2 1 1 7 6
## support_12 support_biascheck support_bias_dummy Q96_First.Click
## 1 7 72 0 12.241
## 2 7 81 0 7.482
## 3 6 62 0 18.845
## 4 5 67 0 30.307
## 5 6 72 0 13.096
## 6 2 54 0 24.841
## Q96_Last.Click Q96_Page.Submit Q96_Click.Count SocMedia_1 SocMedia_2
## 1 91.497 92.381 17 4 2
## 2 34.247 35.467 19 3 2
## 3 74.388 76.037 14 3 3
## 4 150.285 151.869 18 4 2
## 5 43.727 45.041 12 3 3
## 6 110.942 111.636 18 1 1
## SocMedia_3 SocMedia_4 SocMedia_5 SocMedia_6 SocMedia_7 SocMedia_8 SocMedia_9
## 1 5 3 5 5 5 4 5
## 2 4 2 1 1 1 1 2
## 3 4 2 3 4 4 2 3
## 4 5 2 2 4 4 1 3
## 5 5 2 2 4 4 2 4
## 6 2 1 1 1 2 1 1
## SocMedia_10 SocMedia_11 SocMedia_biascheck SocMedia_bias_dummy
## 1 5 4 47 0
## 2 4 2 23 0
## 3 3 3 34 0
## 4 4 4 35 0
## 5 4 4 37 0
## 6 1 1 13 0
## Q80_First.Click Q80_Last.Click Q80_Page.Submit Q80_Click.Count usdream_1
## 1 17.470 59.573 60.431 11 4
## 2 10.768 45.340 47.007 15 4
## 3 30.059 66.498 68.018 12 2
## 4 112.432 161.455 163.036 11 1
## 5 22.246 53.406 55.275 12 3
## 6 5.361 89.568 90.785 15 1
## usdream_2 usdream_3 Q73_First.Click Q73_Last.Click Q73_Page.Submit
## 1 4 1 14.144 24.073 27.558
## 2 4 1 5.240 27.206 36.973
## 3 2 1 5.671 16.751 19.891
## 4 3 1 71.153 82.926 98.687
## 5 4 1 21.293 32.533 35.448
## 6 1 2 6.771 37.203 45.268
## Q73_Click.Count freq
## 1 3 3
## 2 5 4
## 3 3 6
## 4 3 3
## 5 3 4
## 6 4 2
## transgres
## 1 told my friend that something he did was wrong and hurtful to somebody else.
## 2 got very passive
## 3 you don't want to see me
## 4 I tried to excuse myself and said I was sorry
## 5 Got angry.
## 6 why didn't you tell him?
## relation relation_10_TEXT fault feel common attenion2 Q78_First.Click
## 1 4 6 3 3 7 22.366
## 2 7 2 1,4,5,6,7,8 4 7 6.174
## 3 5 3 6 5 7 9.705
## 4 4 3 10,4,6 2 7 58.517
## 5 7 2 5,6 3 NA 5.647
## 6 6 3 1 4 7 15.862
## Q78_Last.Click Q78_Page.Submit Q78_Click.Count transgres_1 transgres_2
## 1 148.934 153.134 12 3 1
## 2 72.626 74.609 22 4 3
## 3 109.167 111.847 10 3 1
## 4 195.290 199.227 14 4 2
## 5 61.894 65.304 13 4 2
## 6 174.894 177.914 21 1 3
## transgres_3 transgres_4 Q79_First.Click Q79_Last.Click Q79_Page.Submit
## 1 1 1 16.239 27.208 28.488
## 2 2 1 20.400 31.697 32.941
## 3 4 1 57.079 77.311 82.171
## 4 1 1 23.005 49.246 50.303
## 5 2 1 11.727 23.987 25.130
## 6 1 1 14.701 35.077 40.711
## Q79_Click.Count NPI1 NPI2 NPI3 NPI4 NPI5 NPI6 NPI7 NPI8 NPI9 NPI10 NPI11
## 1 4 1 1 1 2 1 2 2 1 2 2 1
## 2 4 2 2 1 2 1 2 1 1 1 1 2
## 3 5 2 1 1 2 1 2 1 1 1 2 2
## 4 5 2 2 1 2 1 2 2 1 1 2 1
## 5 8 1 2 1 2 1 2 2 2 1 2 1
## 6 6 2 2 2 1 2 2 2 2 1 2 1
## NPI12 NPI13 exploit_1 exploit_2 exploit_3 NPI_biascheck NPI_bias_dummy
## 1 2 1 2 2 2 19 0
## 2 1 1 4 4 3 18 0
## 3 2 1 5 5 3 19 0
## 4 2 1 2 1 2 20 0
## 5 2 2 5 4 3 21 0
## 6 2 2 1 1 2 23 0
## Q76_First.Click Q76_Last.Click Q76_Page.Submit Q76_Click.Count Q11 Q14_1
## 1 25.575 141.688 142.668 16 2 2
## 2 10.473 103.989 105.050 35 2 2
## 3 29.957 129.786 132.515 22 2 2
## 4 49.912 222.748 223.703 18 2 2
## 5 5.315 108.076 109.093 25 2 2
## 6 5.353 94.716 98.083 25 2 2
## Q14_2 Q14_3 Q14_4 Q14_5 Q14_6 Q14_6_TEXT Q10_1 Q10_2 Q10_3 Q10_4 Q10_5 Q10_6
## 1 2 2 2 2 2 NA NA NA NA NA NA
## 2 2 2 2 2 NA NA NA NA NA NA NA
## 3 2 2 1 2 2 4 3 4 2 4 5
## 4 2 2 2 2 2 NA NA NA NA NA NA
## 5 2 2 2 2 NA NA NA NA NA NA NA
## 6 2 2 2 2 2 NA NA NA NA NA NA
## Q10_7 Q10_8 Q10_9 Q10_10 Q10_11 Q10_12 Q10_13 Q10_14 Q10_15 Q71_First.Click
## 1 NA NA NA NA NA NA NA NA NA 5.199
## 2 NA NA NA NA NA NA NA NA NA 6.497
## 3 3 1 4 1 3 1 4 2 2 4.533
## 4 NA NA NA NA NA NA NA NA NA 7.430
## 5 NA NA NA NA NA NA NA NA NA 5.020
## 6 NA NA NA NA NA NA NA NA NA 15.872
## Q71_Last.Click Q71_Page.Submit Q71_Click.Count physSx_1 physSx_2 physSx_3
## 1 28.239 28.669 7 3 1 1
## 2 23.457 24.600 8 2 2 1
## 3 115.299 116.410 21 3 1 1
## 4 122.984 128.490 12 2 3 2
## 5 7.996 17.581 6 1 1 1
## 6 32.719 33.562 7 1 2 2
## physSx_4 physSx_5 physSx_6 physSx_7 physSx_8 physSx_9 physSx_10 physSx_11
## 1 2 1 2 1 2 2 2 2
## 2 1 3 1 1 3 2 1 1
## 3 3 2 2 1 3 2 1 2
## 4 3 1 2 1 2 1 1 2
## 5 2 1 1 1 1 2 1 1
## 6 1 2 2 1 3 1 2 2
## physSx_12 physSx_13 phys_sx_biaschec phys_sym_bias_dummy. Q70_First.Click
## 1 3 2 24 0 13.703
## 2 3 3 24 0 5.209
## 3 3 3 27 0 36.694
## 4 3 2 25 0 47.764
## 5 2 1 16 0 4.561
## 6 3 2 24 0 10.062
## Q70_Last.Click Q70_Page.Submit Q70_Click.Count stress_1 stress_2 stress_3
## 1 54.318 60.887 16 2 4 5
## 2 27.841 28.982 17 4 5 5
## 3 79.053 80.519 18 4 4 5
## 4 77.308 79.068 13 2 4 4
## 5 18.707 20.343 14 4 3 3
## 6 80.372 82.827 18 3 3 5
## stress_4 stress_5 stress_6 stress_7 stress_8 stress_9 stress_10
## 1 3 3 3 4 3 3 3
## 2 4 3 3 2 2 4 4
## 3 2 1 5 2 2 4 4
## 4 3 4 5 4 2 2 2
## 5 4 3 4 3 3 4 4
## 6 2 3 5 2 1 3 2
## stress_biascheck stress_bias_dummy Q69_First.Click Q69_Last.Click
## 1 33 0 10.383 100.428
## 2 36 0 9.729 43.281
## 3 33 0 42.213 89.329
## 4 32 0 43.206 180.767
## 5 35 0 63.797 76.765
## 6 29 0 16.412 94.543
## Q69_Page.Submit Q69_Click.Count marriage1_1 marriage1_2 marriage1_3
## 1 101.287 14 10 25 30
## 2 44.423 13 10 25 35
## 3 91.194 12 1 1 59
## 4 182.932 12 0 0 60
## 5 77.998 13 25 25 25
## 6 95.709 15 13 33 21
## marriage1_4 marriage2 marriage3 marriage4 marriage5 Q75_First.Click
## 1 35 2 20 1 2 20.229
## 2 30 3 19 1 1 11.100
## 3 39 2 19 1 1 40.807
## 4 40 1 16 1 1 74.778
## 5 25 2 14 3 1 21.347
## 6 33 3 17 1 1 19.366
## Q75_Last.Click Q75_Page.Submit Q75_Click.Count school sex
## 1 164.560 165.870 32 ACG 2
## 2 60.223 61.354 17 ACG,Deree 1
## 3 160.366 165.459 23 American College of Greece 1
## 4 155.971 156.974 13 American College of Greece 2
## 5 48.802 49.742 11 American College of Greece 1
## 6 181.747 183.288 25 American College of Greece 2
## age edu sibling race race_6_TEXT Q82 Q83 income place2 Q80 place Q81
## 1 20 2 2 1 3 NA 3 2 NA NA Greece
## 2 23 5 2 1 3 NA 3 2 NA NA Greece
## 3 23 2 5 1 3 NA 1 2 NA NA Greece
## 4 22 2 3,5,7 6 Greek 3 NA 1 2 NA NA Greece
## 5 18 2 3,5,7 1 3 NA 6 2 NA NA Greece
## 6 23 2 2,4 1 3 NA 1 2 NA NA Greece
## Q81_First.Click Q81_Last.Click Q81_Page.Submit Q81_Click.Count
## 1 0.000 0.000 5.781 0
## 2 2.424 2.424 6.621 1
## 3 0.000 0.000 9.294 0
## 4 2.679 2.679 5.803 1
## 5 1.632 1.632 5.500 1
## 6 2.766 2.766 6.995 1
## comments
## 1 I have completed this survey
## 2 i have completed this survey
## 3 Didn't know my household income.\nI have completed the last question about disability wrong. I read "not" the moment I pressed ">>"
## 4 I have completed this survey
## 5 i have completed this survey
## 6 The question saying "Select" was funny.
## affiliation response_bias_SUM school_coded
## 1 acgreece 0 acgreece
## 2 acgreece 0 acgreece
## 3 acgreece 0 acgreece
## 4 acgreece 0 acgreece
## 5 acgreece 0 acgreece
## 6 acgreece 0 acgreece
# use the str() command to see what kinds of variables are in your dataframe
str(df)
## 'data.frame': 3182 obs. of 328 variables:
## $ StartDate : chr "12/02/16" "11/16/16" "11/09/16" "11/07/16" ...
## $ EndDate : chr "12/02/16" "11/16/16" "11/09/16" "11/07/16" ...
## $ Status : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Progress : int 100 100 99 100 100 100 99 99 100 100 ...
## $ Duration..in.seconds.: int 1839 1467 2185 2904 1229 2068 1656 1839 1160 2134 ...
## $ Finished : int 1 1 0 1 1 1 0 0 1 1 ...
## $ RecordedDate : chr "12/2/2016 5:38" "11/16/2016 11:53" "11/16/2016 1:22" "11/7/2016 4:54" ...
## $ ResponseId : chr "R_BJN3bQqi1zUMid3" "R_2TGbiBXmAtxywsD" "R_12G7bIqN2wB2N65" "R_39pldNoon8CePfP" ...
## $ RecipientLastName : logi NA NA NA NA NA NA ...
## $ RecipientFirstName : logi NA NA NA NA NA NA ...
## $ RecipientEmail : logi NA NA NA NA NA NA ...
## $ ExternalReference : logi NA NA NA NA NA NA ...
## $ DistributionChannel : chr "anonymous" "anonymous" "anonymous" "anonymous" ...
## $ informedconsent : int 1 1 1 1 1 1 1 1 1 1 ...
## $ moa1.1_1 : int 4 4 4 4 4 4 4 4 4 3 ...
## $ moa1.1_2 : int 4 4 4 3 4 3 4 4 4 2 ...
## $ moa1.1_3 : int 3 4 4 3 4 4 4 4 4 3 ...
## $ moa1.1_4 : int 2 2 1 1 1 2 3 3 4 1 ...
## $ moa1.1_5 : int 2 3 1 1 1 3 3 3 4 1 ...
## $ moa1.1_6 : int 3 3 4 2 3 4 4 4 4 2 ...
## $ moa1.1_7 : int 2 4 2 1 1 2 4 3 1 3 ...
## $ moa1.1_8 : int 1 3 3 1 1 1 4 3 2 3 ...
## $ moa1.1_9 : int 4 3 4 1 4 3 4 4 4 4 ...
## $ moa1.1_10 : int 3 3 3 1 3 4 3 3 4 3 ...
## $ moa1.2_1 : int 2 1 2 1 2 1 1 2 2 2 ...
## $ moa1.2_2 : int 1 1 1 1 1 1 1 2 2 2 ...
## $ moa1.2_3 : int 2 2 1 1 2 1 2 2 2 2 ...
## $ moa1.2_4 : int 1 2 1 1 1 1 1 1 1 1 ...
## $ moa1.2_5 : int 1 1 1 1 3 1 1 1 1 1 ...
## $ moa1.2_6 : int 1 1 1 1 3 1 1 1 2 2 ...
## $ moa1.2_7 : int 2 1 2 2 1 1 3 3 1 3 ...
## $ moa1.2_8 : int 3 1 3 3 1 1 3 3 3 3 ...
## $ moa1.2_9 : int 3 2 3 2 3 1 3 3 3 3 ...
## $ moa1.2_10 : int 2 3 3 3 2 3 3 3 1 3 ...
## $ moa2.1_1 : int 4 3 4 4 4 4 4 4 4 3 ...
## $ moa2.1_2 : int 4 4 2 2 4 4 4 4 4 3 ...
## $ moa2.1_3 : int 4 2 2 2 3 4 3 4 4 3 ...
## $ moa2.1_4 : int 4 4 4 4 4 4 4 4 4 4 ...
## $ moa2.1_5 : int 3 4 3 3 4 2 4 4 4 3 ...
## $ moa2.1_6 : int 4 3 3 2 3 4 4 3 4 4 ...
## $ moa2.1_7 : int 4 2 4 4 4 3 4 4 2 4 ...
## $ moa2.1_8 : int 4 4 4 2 4 4 3 4 4 4 ...
## $ moa2.1_9 : int 3 2 3 3 3 4 4 4 4 4 ...
## $ moa2.1_10 : int 2 1 2 2 3 4 2 4 2 2 ...
## $ moa2.2_1 : int 2 3 2 2 3 2 2 2 3 3 ...
## $ moa2.2_2 : int 1 1 1 1 3 1 1 1 1 2 ...
## $ moa2.2_3 : int 1 2 1 1 3 1 1 1 3 3 ...
## $ moa2.2_4 : int 3 2 2 2 3 2 2 3 3 3 ...
## $ moa2.2_5 : int 2 1 1 1 3 1 1 1 2 2 ...
## $ moa2.2_6 : int 3 2 2 2 2 2 2 2 3 3 ...
## $ moa2.2_7 : int 3 2 3 2 3 2 1 2 1 3 ...
## $ moa2.2_8 : int 2 2 1 2 3 1 2 3 2 2 ...
## $ moa2.2_9 : int 2 2 1 2 2 2 2 2 3 3 ...
## $ moa2.2_10 : int 1 1 1 1 3 1 1 1 1 2 ...
## $ adult_Q : int 1 1 1 1 1 1 1 1 1 2 ...
## $ MOA_IMP_biascheck : int 64 62 61 46 62 67 73 74 71 59 ...
## $ MOA_ach_biascheck : int 38 33 33 32 47 27 34 39 40 48 ...
## $ MOA_IMP_dummy : int 0 0 0 0 0 0 0 0 0 0 ...
## $ MOA.ACH_dummy : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Q65_First.Click : num 37.1 120 27.7 19.7 12.9 ...
## $ Q65_Last.Click : num 308 336 154 297 122 ...
## $ Q65_Page.Submit : num 309 338 156 299 122 ...
## $ Q65_Click.Count : int 45 58 47 43 46 50 45 42 47 47 ...
## $ IDEA_1 : int 3 4 4 4 4 3 4 4 4 4 ...
## $ IDEA_2 : int 4 4 4 4 4 4 3 3 4 4 ...
## $ IDEA_3 : int 4 4 4 3 3 3 4 3 3 2 ...
## $ IDEA_4 : int 3 4 4 3 4 3 4 4 2 2 ...
## $ IDEA_5 : int 4 3 4 4 3 4 3 3 4 4 ...
## $ IDEA_6 : int 4 4 4 4 3 4 4 2 4 4 ...
## $ IDEA_7 : int 4 4 3 4 3 3 3 2 3 3 ...
## $ IDEA_8 : int 4 4 3 4 4 2 3 3 3 4 ...
## $ IDEA.biascheck : int 30 31 30 30 28 26 28 24 27 27 ...
## $ IDEA.bias.dummy : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Q66_First.Click : num 44.7 19.9 23.2 27.5 24 ...
## $ Q66_Last.Click : num 86.6 65.2 51.4 172.8 52.2 ...
## $ Q66_Page.Submit : num 87.5 67.2 52.4 174.1 53.4 ...
## $ Q66_Click.Count : int 11 13 11 9 9 13 9 8 8 9 ...
## $ politics : int 2 1 2 8 1 8 4 2 8 4 ...
## $ party : int 3 4 8 8 8 8 4 1 3 8 ...
## $ president : chr "" "None, but I was a US Citizen and had a gun next to my head, I would vote for Trump" "Hillary Clinton" "Hillary Clinton" ...
## $ Q74_First.Click : num 13.1 4.9 34.9 66.9 23.6 ...
## $ Q74_Last.Click : num 40.4 28.1 48.4 119.2 32.2 ...
## $ Q74_Page.Submit : num 46.4 55.1 56.4 135.3 35.3 ...
## $ Q74_Click.Count : int 2 6 4 4 4 6 3 3 3 3 ...
## $ swb_1 : int 4 3 1 5 2 4 4 5 5 5 ...
## $ swb_2 : int 6 4 2 6 5 4 4 5 5 4 ...
## $ swb_3 : int 5 5 2 6 5 6 5 6 5 6 ...
## $ swb_4 : int 5 5 2 5 3 5 4 5 5 4 ...
## $ swb_5 : int 3 4 2 6 2 1 1 6 5 6 ...
## $ swb_6 : int 3 4 2 3 5 4 4 6 5 4 ...
## $ Q67_First.Click : num 9.63 8.61 37.66 13.59 6.8 ...
## $ Q67_Last.Click : num 40.4 29.1 53.2 55.2 22.2 ...
## $ Q67_Page.Submit : num 41.2 30 54.6 56.1 23.1 ...
## $ Q67_Click.Count : int 7 7 9 7 7 7 7 7 6 13 ...
## $ mindful_1 : int 4 2 2 2 4 1 5 3 3 5 ...
## $ mindful_2 : int 2 2 3 2 5 4 6 2 3 6 ...
## $ mindful_3 : int 2 2 1 1 3 3 5 4 4 4 ...
## $ mindful_4 : int 2 1 2 2 2 3 4 2 3 5 ...
## $ mindful_5 : int 4 3 3 2 4 5 6 2 3 6 ...
## [list output truncated]
# use the subset() command to select which columns to keep in your dataframe
# this is the code you'll need for the lab. for the homework assignment, you'll need to customize the code so that the variables are the ones you've chosen.
d <- subset(df, select=c(sex,
race,
stress_1, stress_2, stress_3, stress_4, stress_5, stress_6, stress_7, stress_8, stress_9, stress_10,
efficacy_1, efficacy_2, efficacy_3, efficacy_4, efficacy_5, efficacy_6, efficacy_7, efficacy_8, efficacy_9, efficacy_10,
mindful_1, mindful_2, mindful_3, mindful_4, mindful_5, mindful_6, mindful_7, mindful_8, mindful_9, mindful_10, mindful_11, mindful_12, mindful_13, mindful_14, mindful_15,
swb_1, swb_2, swb_3, swb_4, swb_5, swb_6))
head(d)
## sex race stress_1 stress_2 stress_3 stress_4 stress_5 stress_6 stress_7
## 1 2 1 2 4 5 3 3 3 4
## 2 1 1 4 5 5 4 3 3 2
## 3 1 1 4 4 5 2 1 5 2
## 4 2 6 2 4 4 3 4 5 4
## 5 1 1 4 3 3 4 3 4 3
## 6 2 1 3 3 5 2 3 5 2
## stress_8 stress_9 stress_10 efficacy_1 efficacy_2 efficacy_3 efficacy_4
## 1 3 3 3 4 3 4 3
## 2 2 4 4 3 3 3 4
## 3 2 4 4 3 3 1 2
## 4 2 2 2 4 1 2 3
## 5 3 4 4 3 3 2 3
## 6 1 3 2 3 2 3 2
## efficacy_5 efficacy_6 efficacy_7 efficacy_8 efficacy_9 efficacy_10 mindful_1
## 1 3 4 3 3 4 3 4
## 2 4 4 3 3 3 4 2
## 3 2 3 1 3 2 2 2
## 4 2 4 2 3 4 3 2
## 5 3 3 3 3 4 3 4
## 6 1 3 2 3 3 2 1
## mindful_2 mindful_3 mindful_4 mindful_5 mindful_6 mindful_7 mindful_8
## 1 2 2 2 4 1 2 2
## 2 2 2 1 3 1 1 1
## 3 3 1 2 3 1 2 2
## 4 2 1 2 2 1 2 2
## 5 5 3 2 4 1 4 2
## 6 4 3 3 5 1 5 6
## mindful_9 mindful_10 mindful_11 mindful_12 mindful_13 mindful_14 mindful_15
## 1 2 2 2 4 1 2 4
## 2 2 2 1 2 1 1 5
## 3 5 3 2 1 1 1 4
## 4 3 2 2 3 3 2 4
## 5 1 2 2 6 5 2 5
## 6 3 5 1 3 2 4 5
## swb_1 swb_2 swb_3 swb_4 swb_5 swb_6
## 1 4 6 5 5 3 3
## 2 3 4 5 5 4 4
## 3 1 2 2 2 2 2
## 4 5 6 6 5 6 3
## 5 2 5 5 3 2 5
## 6 4 4 6 5 1 4
str(d)
## 'data.frame': 3182 obs. of 43 variables:
## $ sex : int 2 1 1 2 1 2 2 2 2 2 ...
## $ race : chr "1" "1" "1" "6" ...
## $ stress_1 : int 2 4 4 2 4 3 3 3 3 2 ...
## $ stress_2 : int 4 5 4 4 3 3 4 2 3 3 ...
## $ stress_3 : int 5 5 5 4 3 5 5 3 3 3 ...
## $ stress_4 : int 3 4 2 3 4 2 3 4 3 4 ...
## $ stress_5 : int 3 3 1 4 3 3 3 4 3 3 ...
## $ stress_6 : int 3 3 5 5 4 5 4 3 3 4 ...
## $ stress_7 : int 4 2 2 4 3 2 3 4 3 4 ...
## $ stress_8 : int 3 2 2 2 3 1 2 4 3 4 ...
## $ stress_9 : int 3 4 4 2 4 3 3 2 3 2 ...
## $ stress_10 : int 3 4 4 2 4 2 2 1 2 3 ...
## $ efficacy_1 : int 4 3 3 4 3 3 3 3 3 4 ...
## $ efficacy_2 : int 3 3 3 1 3 2 3 3 3 3 ...
## $ efficacy_3 : int 4 3 1 2 2 3 2 3 3 4 ...
## $ efficacy_4 : int 3 4 2 3 3 2 1 3 3 4 ...
## $ efficacy_5 : int 3 4 2 2 3 1 2 3 3 4 ...
## $ efficacy_6 : int 4 4 3 4 3 3 3 3 3 4 ...
## $ efficacy_7 : int 3 3 1 2 3 2 2 3 3 3 ...
## $ efficacy_8 : int 3 3 3 3 3 3 2 3 3 4 ...
## $ efficacy_9 : int 4 3 2 4 4 3 2 3 3 4 ...
## $ efficacy_10: int 3 4 2 3 3 2 3 3 3 3 ...
## $ mindful_1 : int 4 2 2 2 4 1 5 3 3 5 ...
## $ mindful_2 : int 2 2 3 2 5 4 6 2 3 6 ...
## $ mindful_3 : int 2 2 1 1 3 3 5 4 4 4 ...
## $ mindful_4 : int 2 1 2 2 2 3 4 2 3 5 ...
## $ mindful_5 : int 4 3 3 2 4 5 6 2 3 6 ...
## $ mindful_6 : int 1 1 1 1 1 1 1 5 3 5 ...
## $ mindful_7 : int 2 1 2 2 4 5 4 4 4 3 ...
## $ mindful_8 : int 2 1 2 2 2 6 4 4 4 5 ...
## $ mindful_9 : int 2 2 5 3 1 3 4 3 4 4 ...
## $ mindful_10 : int 2 2 3 2 2 5 4 5 4 5 ...
## $ mindful_11 : int 2 1 2 2 2 1 3 2 4 4 ...
## $ mindful_12 : int 4 2 1 3 6 3 4 1 3 6 ...
## $ mindful_13 : int 1 1 1 3 5 2 2 1 3 3 ...
## $ mindful_14 : int 2 1 1 2 2 4 4 2 3 6 ...
## $ mindful_15 : int 4 5 4 4 5 5 6 5 3 6 ...
## $ swb_1 : int 4 3 1 5 2 4 4 5 5 5 ...
## $ swb_2 : int 6 4 2 6 5 4 4 5 5 4 ...
## $ swb_3 : int 5 5 2 6 5 6 5 6 5 6 ...
## $ swb_4 : int 5 5 2 5 3 5 4 5 5 4 ...
## $ swb_5 : int 3 4 2 6 2 1 1 6 5 6 ...
## $ swb_6 : int 3 4 2 3 5 4 4 6 5 4 ...
# use the map() command to view tables for all of your columns/variables at once
d %>%
map(table, useNA = "always")
## $sex
##
## 1 2 3 <NA>
## 792 2332 54 4
##
## $race
##
## 1 1,2 1,2,3 1,2,3,4,5 1,2,3,5 1,2,4 1,2,4,5
## 9 2026 26 2 1 3 4 3
## 1,2,5 1,2,6 1,3 1,3,4 1,3,5 1,4 1,4,5 1,5
## 4 2 98 6 8 39 2 35
## 1,6 2 2,3 2,3,4 2,3,4,5 2,3,5 2,3,6 2,4
## 15 249 5 1 1 1 1 6
## 2,5 2,5,6 2,6 3 3,4 3,4,5 3,5 4
## 5 1 6 286 9 1 5 210
## 4,6 5 6 <NA>
## 3 12 97 0
##
## $stress_1
##
## 1 2 3 4 5 <NA>
## 147 656 1331 775 268 5
##
## $stress_2
##
## 1 2 3 4 5 <NA>
## 209 665 1074 786 443 5
##
## $stress_3
##
## 1 2 3 4 5 <NA>
## 31 128 639 1037 1342 5
##
## $stress_4
##
## 1 2 3 4 5 <NA>
## 68 359 1217 1098 434 6
##
## $stress_5
##
## 1 2 3 4 5 <NA>
## 119 523 1482 857 196 5
##
## $stress_6
##
## 1 2 3 4 5 <NA>
## 221 826 1164 662 304 5
##
## $stress_7
##
## 1 2 3 4 5 <NA>
## 99 461 1395 1007 215 5
##
## $stress_8
##
## 1 2 3 4 5 <NA>
## 135 572 1340 948 181 6
##
## $stress_9
##
## 1 2 3 4 5 <NA>
## 175 646 1123 846 387 5
##
## $stress_10
##
## 1 2 3 4 5 <NA>
## 295 763 1037 660 422 5
##
## $efficacy_1
##
## 1 2 3 4 <NA>
## 26 219 1789 1145 3
##
## $efficacy_2
##
## 1 2 3 4 <NA>
## 89 802 1841 448 2
##
## $efficacy_3
##
## 1 2 3 4 <NA>
## 62 536 1790 792 2
##
## $efficacy_4
##
## 1 2 3 4 <NA>
## 69 446 1849 815 3
##
## $efficacy_5
##
## 1 2 3 4 <NA>
## 54 455 1928 742 3
##
## $efficacy_6
##
## 1 2 3 4 <NA>
## 11 122 1551 1495 3
##
## $efficacy_7
##
## 1 2 3 4 <NA>
## 126 580 1647 826 3
##
## $efficacy_8
##
## 1 2 3 4 <NA>
## 29 388 1949 812 4
##
## $efficacy_9
##
## 1 2 3 4 <NA>
## 17 195 1963 1005 2
##
## $efficacy_10
##
## 1 2 3 4 <NA>
## 39 273 1909 958 3
##
## $mindful_1
##
## 1 2 3 4 5 6 <NA>
## 84 390 1034 754 578 336 6
##
## $mindful_2
##
## 1 2 3 4 5 6 <NA>
## 60 230 577 592 917 801 5
##
## $mindful_3
##
## 1 2 3 4 5 6 <NA>
## 143 408 833 762 706 324 6
##
## $mindful_4
##
## 1 2 3 4 5 6 <NA>
## 310 667 893 593 486 228 5
##
## $mindful_5
##
## 1 2 3 4 5 6 <NA>
## 179 375 620 714 837 452 5
##
## $mindful_6
##
## 1 2 3 4 5 6 <NA>
## 493 629 627 555 536 337 5
##
## $mindful_7
##
## 1 2 3 4 5 6 <NA>
## 187 442 826 778 632 312 5
##
## $mindful_8
##
## 1 2 3 4 5 6 <NA>
## 109 359 758 881 745 325 5
##
## $mindful_9
##
## 1 2 3 4 5 6 <NA>
## 201 432 775 834 669 266 5
##
## $mindful_10
##
## 1 2 3 4 5 6 <NA>
## 140 400 823 842 683 287 7
##
## $mindful_11
##
## 1 2 3 4 5 6 <NA>
## 262 741 937 569 472 195 6
##
## $mindful_12
##
## 1 2 3 4 5 6 <NA>
## 168 310 482 504 699 1013 6
##
## $mindful_13
##
## 1 2 3 4 5 6 <NA>
## 571 906 818 461 270 151 5
##
## $mindful_14
##
## 1 2 3 4 5 6 <NA>
## 199 521 912 715 549 281 5
##
## $mindful_15
##
## 1 2 3 4 5 6 <NA>
## 198 348 513 558 693 867 5
##
## $swb_1
##
## 1 2 3 4 5 6 7 <NA>
## 234 408 449 467 788 617 215 4
##
## $swb_2
##
## 1 2 3 4 5 6 7 <NA>
## 108 243 382 458 782 812 394 3
##
## $swb_3
##
## 1 2 3 4 5 6 7 <NA>
## 125 200 332 375 767 993 386 4
##
## $swb_4
##
## 1 2 3 4 5 6 7 <NA>
## 137 285 351 416 847 805 337 4
##
## $swb_5
##
## 1 2 3 4 5 6 7 <NA>
## 374 489 597 318 506 567 327 4
##
## $swb_6
##
## 1 2 3 4 5 6 7 <NA>
## 255 394 407 416 730 678 298 4
table(d$sex, useNA = "always")
##
## 1 2 3 <NA>
## 792 2332 54 4
d$gender[d$sex == "1"] <- "m"
d$gender[d$sex == "2"] <- "f"
d$gender[d$sex == "3"] <- "nb"
table(d$gender, useNA = "always")
##
## f m nb <NA>
## 2332 792 54 4
table(d$race, useNA = "always")
##
## 1 1,2 1,2,3 1,2,3,4,5 1,2,3,5 1,2,4 1,2,4,5
## 9 2026 26 2 1 3 4 3
## 1,2,5 1,2,6 1,3 1,3,4 1,3,5 1,4 1,4,5 1,5
## 4 2 98 6 8 39 2 35
## 1,6 2 2,3 2,3,4 2,3,4,5 2,3,5 2,3,6 2,4
## 15 249 5 1 1 1 1 6
## 2,5 2,5,6 2,6 3 3,4 3,4,5 3,5 4
## 5 1 6 286 9 1 5 210
## 4,6 5 6 <NA>
## 3 12 97 0
d$race_rc <- NA
d$race_rc[df$race == 1] <- "white"
d$race_rc[df$race == 2] <- "black"
d$race_rc[df$race == 3] <- "hispanic"
d$race_rc[df$race == 4] <- "asian"
d$race_rc[df$race == 5] <- "nativeamer"
d$race_rc[df$race == 6] <- "other"
d$race_rc[grep(",", d$race)] <- "multiracial"
table(d$race_rc, useNA = "always")
##
## asian black hispanic multiracial nativeamer other
## 210 249 286 293 12 97
## white <NA>
## 2026 9
table(d$mindful_1, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 84 390 1034 754 578 336 6
d$mindful_1_rc[d$mindful_1 == 1] <- 8
d$mindful_1_rc[d$mindful_1 == 2] <- 7
d$mindful_1_rc[d$mindful_1 == 3] <- 6
d$mindful_1_rc[d$mindful_1 == 4] <- 5
d$mindful_1_rc[d$mindful_1 == 5] <- 4
d$mindful_1_rc[d$mindful_1 == 6] <- 3
d$mindful_1_rc[d$mindful_1 == 7] <- 2
d$mindful_1_rc[d$mindful_1 == 8] <- 1
table(d$mindful_1_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 336 578 754 1034 390 84 6
table(d$mindful_2, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 60 230 577 592 917 801 5
d$mindful_2_rc[d$mindful_2 == 1] <- 8
d$mindful_2_rc[d$mindful_2 == 2] <- 7
d$mindful_2_rc[d$mindful_2 == 3] <- 6
d$mindful_2_rc[d$mindful_2 == 4] <- 5
d$mindful_2_rc[d$mindful_2 == 5] <- 4
d$mindful_2_rc[d$mindful_2 == 6] <- 3
d$mindful_2_rc[d$mindful_2 == 7] <- 2
d$mindful_2_rc[d$mindful_2 == 8] <- 1
table(d$mindful_2_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 801 917 592 577 230 60 5
table(d$mindful_3, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 143 408 833 762 706 324 6
d$mindful_3_rc[d$mindful_3 == 1] <- 8
d$mindful_3_rc[d$mindful_3 == 2] <- 7
d$mindful_3_rc[d$mindful_3 == 3] <- 6
d$mindful_3_rc[d$mindful_3 == 4] <- 5
d$mindful_3_rc[d$mindful_3 == 5] <- 4
d$mindful_3_rc[d$mindful_3 == 6] <- 3
d$mindful_3_rc[d$mindful_3 == 7] <- 2
d$mindful_3_rc[d$mindful_3 == 8] <- 1
table(d$mindful_3_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 324 706 762 833 408 143 6
table(d$mindful_4, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 310 667 893 593 486 228 5
d$mindful_4_rc[d$mindful_4 == 1] <- 8
d$mindful_4_rc[d$mindful_4 == 2] <- 7
d$mindful_4_rc[d$mindful_4 == 3] <- 6
d$mindful_4_rc[d$mindful_4 == 4] <- 5
d$mindful_4_rc[d$mindful_4 == 5] <- 4
d$mindful_4_rc[d$mindful_4 == 6] <- 3
d$mindful_4_rc[d$mindful_4 == 7] <- 2
d$mindful_4_rc[d$mindful_4 == 8] <- 1
table(d$mindful_4_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 228 486 593 893 667 310 5
table(d$mindful_5, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 179 375 620 714 837 452 5
d$mindful_5_rc[d$mindful_5 == 1] <- 8
d$mindful_5_rc[d$mindful_5 == 2] <- 7
d$mindful_5_rc[d$mindful_5 == 3] <- 6
d$mindful_5_rc[d$mindful_5 == 4] <- 5
d$mindful_5_rc[d$mindful_5 == 5] <- 4
d$mindful_5_rc[d$mindful_5 == 6] <- 3
d$mindful_5_rc[d$mindful_5 == 7] <- 2
d$mindful_5_rc[d$mindful_5 == 8] <- 1
table(d$mindful_5_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 452 837 714 620 375 179 5
table(d$mindful_6, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 493 629 627 555 536 337 5
d$mindful_6_rc[d$mindful_6 == 1] <- 8
d$mindful_6_rc[d$mindful_6 == 2] <- 7
d$mindful_6_rc[d$mindful_6 == 3] <- 6
d$mindful_6_rc[d$mindful_6 == 4] <- 5
d$mindful_6_rc[d$mindful_6 == 5] <- 4
d$mindful_6_rc[d$mindful_6 == 6] <- 3
d$mindful_6_rc[d$mindful_6 == 7] <- 2
d$mindful_6_rc[d$mindful_6 == 8] <- 1
table(d$mindful_6_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 337 536 555 627 629 493 5
table(d$mindful_7, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 187 442 826 778 632 312 5
d$mindful_7_rc[d$mindful_7 == 1] <- 8
d$mindful_7_rc[d$mindful_7 == 2] <- 7
d$mindful_7_rc[d$mindful_7 == 3] <- 6
d$mindful_7_rc[d$mindful_7 == 4] <- 5
d$mindful_7_rc[d$mindful_7 == 5] <- 4
d$mindful_7_rc[d$mindful_7 == 6] <- 3
d$mindful_7_rc[d$mindful_7 == 7] <- 2
d$mindful_7_rc[d$mindful_7 == 8] <- 1
table(d$mindful_7_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 312 632 778 826 442 187 5
table(d$mindful_8, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 109 359 758 881 745 325 5
d$mindful_8_rc[d$mindful_8 == 1] <- 8
d$mindful_8_rc[d$mindful_8 == 2] <- 7
d$mindful_8_rc[d$mindful_8 == 3] <- 6
d$mindful_8_rc[d$mindful_8 == 4] <- 5
d$mindful_8_rc[d$mindful_8 == 5] <- 4
d$mindful_8_rc[d$mindful_8 == 6] <- 3
d$mindful_8_rc[d$mindful_8 == 7] <- 2
d$mindful_8_rc[d$mindful_8 == 8] <- 1
table(d$mindful_8_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 325 745 881 758 359 109 5
table(d$mindful_9, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 201 432 775 834 669 266 5
d$mindful_9_rc[d$mindful_9 == 1] <- 8
d$mindful_9_rc[d$mindful_9 == 2] <- 7
d$mindful_9_rc[d$mindful_9 == 3] <- 6
d$mindful_9_rc[d$mindful_9 == 4] <- 5
d$mindful_9_rc[d$mindful_9 == 5] <- 4
d$mindful_9_rc[d$mindful_9 == 6] <- 3
d$mindful_9_rc[d$mindful_9 == 7] <- 2
d$mindful_9_rc[d$mindful_9 == 8] <- 1
table(d$mindful_9_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 266 669 834 775 432 201 5
table(d$mindful_10, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 140 400 823 842 683 287 7
d$mindful_10_rc[d$mindful_10 == 1] <- 8
d$mindful_10_rc[d$mindful_10 == 2] <- 7
d$mindful_10_rc[d$mindful_10 == 3] <- 6
d$mindful_10_rc[d$mindful_10 == 4] <- 5
d$mindful_10_rc[d$mindful_10 == 5] <- 4
d$mindful_10_rc[d$mindful_10 == 6] <- 3
d$mindful_10_rc[d$mindful_10 == 7] <- 2
d$mindful_10_rc[d$mindful_10 == 8] <- 1
table(d$mindful_10_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 287 683 842 823 400 140 7
table(d$mindful_11, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 262 741 937 569 472 195 6
d$mindful_11_rc[d$mindful_11 == 1] <- 8
d$mindful_11_rc[d$mindful_11 == 2] <- 7
d$mindful_11_rc[d$mindful_11 == 3] <- 6
d$mindful_11_rc[d$mindful_11 == 4] <- 5
d$mindful_11_rc[d$mindful_11 == 5] <- 4
d$mindful_11_rc[d$mindful_11 == 6] <- 3
d$mindful_11_rc[d$mindful_11 == 7] <- 2
d$mindful_11_rc[d$mindful_11 == 8] <- 1
table(d$mindful_11_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 195 472 569 937 741 262 6
table(d$mindful_12, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 168 310 482 504 699 1013 6
d$mindful_12_rc[d$mindful_12 == 1] <- 8
d$mindful_12_rc[d$mindful_12 == 2] <- 7
d$mindful_12_rc[d$mindful_12 == 3] <- 6
d$mindful_12_rc[d$mindful_12 == 4] <- 5
d$mindful_12_rc[d$mindful_12 == 5] <- 4
d$mindful_12_rc[d$mindful_12 == 6] <- 3
d$mindful_12_rc[d$mindful_12 == 7] <- 2
d$mindful_12_rc[d$mindful_12 == 8] <- 1
table(d$mindful_12_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 1013 699 504 482 310 168 6
table(d$mindful_13, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 571 906 818 461 270 151 5
d$mindful_13_rc[d$mindful_13 == 1] <- 8
d$mindful_13_rc[d$mindful_13 == 2] <- 7
d$mindful_13_rc[d$mindful_13 == 3] <- 6
d$mindful_13_rc[d$mindful_13 == 4] <- 5
d$mindful_13_rc[d$mindful_13 == 5] <- 4
d$mindful_13_rc[d$mindful_13 == 6] <- 3
d$mindful_13_rc[d$mindful_13 == 7] <- 2
d$mindful_13_rc[d$mindful_13 == 8] <- 1
table(d$mindful_13_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 151 270 461 818 906 571 5
table(d$mindful_14, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 199 521 912 715 549 281 5
d$mindful_14_rc[d$mindful_14 == 1] <- 8
d$mindful_14_rc[d$mindful_14 == 2] <- 7
d$mindful_14_rc[d$mindful_14 == 3] <- 6
d$mindful_14_rc[d$mindful_14 == 4] <- 5
d$mindful_14_rc[d$mindful_14 == 5] <- 4
d$mindful_14_rc[d$mindful_14 == 6] <- 3
d$mindful_14_rc[d$mindful_14 == 7] <- 2
d$mindful_14_rc[d$mindful_14 == 8] <- 1
table(d$mindful_14_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 281 549 715 912 521 199 5
table(d$mindful_15, useNA = "always")
##
## 1 2 3 4 5 6 <NA>
## 198 348 513 558 693 867 5
d$mindful_15_rc[d$mindful_15 == 1] <- 8
d$mindful_15_rc[d$mindful_15 == 2] <- 7
d$mindful_15_rc[d$mindful_15 == 3] <- 6
d$mindful_15_rc[d$mindful_15 == 4] <- 5
d$mindful_15_rc[d$mindful_15 == 5] <- 4
d$mindful_15_rc[d$mindful_15 == 6] <- 3
d$mindful_15_rc[d$mindful_15 == 7] <- 2
d$mindful_15_rc[d$mindful_15 == 8] <- 1
table(d$mindful_15_rc, useNA = "always")
##
## 3 4 5 6 7 8 <NA>
## 867 693 558 513 348 198 5
d$mindful_1_rc <- as.integer(d$mindful_1_rc)
d$mindful_2_rc <- as.integer(d$mindful_2_rc)
d$mindful_3_rc <- as.integer(d$mindful_3_rc)
d$mindful_4_rc <- as.integer(d$mindful_4_rc)
d$mindful_5_rc <- as.integer(d$mindful_5_rc)
d$mindful_6_rc <- as.integer(d$mindful_6_rc)
d$mindful_7_rc <- as.integer(d$mindful_7_rc)
d$mindful_8_rc <- as.integer(d$mindful_8_rc)
d$mindful_9_rc <- as.integer(d$mindful_9_rc)
d$mindful_10_rc <- as.integer(d$mindful_10_rc)
d$mindful_11_rc <- as.integer(d$mindful_11_rc)
d$mindful_12_rc <- as.integer(d$mindful_12_rc)
d$mindful_13_rc <- as.integer(d$mindful_13_rc)
d$mindful_14_rc <- as.integer(d$mindful_14_rc)
d$mindful_15_rc <- as.integer(d$mindful_15_rc)
d$swb <- (d$swb_1 + d$swb_2 + d$swb_3 + d$swb_4 + d$swb_5 + d$swb_6)/6
d$stress <- (d$stress_1 + d$stress_2 + d$stress_3 + d$stress_4 + d$stress_5 + d$stress_6 + d$stress_7 + d$stress_8 + d$stress_9 + d$stress_10)/10
d$efficacy <- (d$efficacy_1 + d$efficacy_2 + d$efficacy_3 + d$efficacy_4 + d$efficacy_5 + d$efficacy_6 + d$efficacy_7 + d$efficacy_8 + d$efficacy_9 + d$efficacy_10)/10
d$mindful <- (d$mindful_1_rc + d$mindful_2_rc + d$mindful_3_rc + d$mindful_4_rc + d$mindful_5_rc + d$mindful_6_rc + d$mindful_7_rc + d$mindful_8_rc + d$mindful_9_rc + d$mindful_10_rc + d$mindful_11_rc + d$mindful_12_rc + d$mindful_13_rc + d$mindful_14_rc + d$mindful_15_rc)/15
d2 <- subset(d, select=c(race_rc, gender, stress, swb, efficacy, mindful))
# use the write.csv() command to export your finalized dataframe
write.csv(d2, file="EAMMi2_final.csv", row.names = F)
library(psych) # for the describe() command
library(naniar) # for the gg_miss-upset() command
library(expss) # for the cross_cases() command
d2 <- read.csv(file="data/EAMMi2_final.csv", header=T) # import the file you created in last lab
head(d2)
## race_rc gender stress swb efficacy mindful
## 1 white f 3.3 4.333333 3.4 6.6
## 2 white m 3.6 4.166667 3.4 7.2
## 3 white m 3.3 1.833333 2.2 6.8
## 4 other f 3.2 5.166667 2.8 6.8
## 5 white m 3.5 3.666667 3.0 5.8
## 6 white f 2.9 4.000000 2.4 5.6
str(d2)
## 'data.frame': 3182 obs. of 6 variables:
## $ race_rc : chr "white" "white" "white" "other" ...
## $ gender : chr "f" "m" "m" "f" ...
## $ stress : num 3.3 3.6 3.3 3.2 3.5 2.9 3.2 3 2.9 3.2 ...
## $ swb : num 4.33 4.17 1.83 5.17 3.67 ...
## $ efficacy: num 3.4 3.4 2.2 2.8 3 2.4 2.3 3 3 3.7 ...
## $ mindful : num 6.6 7.2 6.8 6.8 5.8 ...
# use as.factor() command to make sure your categorical variables are recognized as such
d2$race_rc <- as.factor(d2$race_rc)
d2$gender <- as.factor(d2$gender)
describe(d2)
## vars n mean sd median trimmed mad min max range skew kurtosis
## race_rc* 1 3173 5.53 2.13 7.00 5.88 0.00 1 7.00 6.00 -0.98 -0.68
## gender* 2 3178 1.28 0.49 1.00 1.21 0.00 1 3.00 2.00 1.40 0.88
## stress 3 3175 3.27 0.41 3.30 3.26 0.44 1 5.00 4.00 -0.16 2.67
## swb 4 3178 4.47 1.32 4.67 4.53 1.48 1 7.00 6.00 -0.36 -0.46
## efficacy 5 3176 3.13 0.45 3.10 3.13 0.44 1 4.00 3.00 -0.29 0.63
## mindful 6 3173 5.29 0.84 5.27 5.29 0.79 3 7.87 4.87 0.06 -0.13
## se
## race_rc* 0.04
## gender* 0.01
## stress 0.01
## swb 0.02
## efficacy 0.01
## mindful 0.01
# use the hist() command to create a histogram for your continuous variables
hist(d2$swb)
hist(d2$stress)
hist(d2$efficacy)
hist(d2$mindful)
# use the table() command to create a table for your categorical variables (other than your ID variable)
table(d2$race_rc, useNA = "always")
##
## asian black hispanic multiracial nativeamer other
## 210 249 286 293 12 97
## white <NA>
## 2026 9
table(d2$gender, useNA = "always")
##
## f m nb <NA>
## 2332 792 54 4
# use the gg_miss_upset() command to visualize your missing data
gg_miss_upset(d2, nsets = "6")
# create a new dataframe with only your complete cases/observations
d3 <- na.omit(d2)
# use the cross_cases() command to create a crosstab of your categorical variables
cross_cases(d3, race_rc, gender)
|  gender | |||
|---|---|---|---|
|  f |  m |  nb | |
|  race_rc | |||
|    asian | 150 | 57 | 1 |
|    black | 181 | 63 | 2 |
|    hispanic | 206 | 76 | 2 |
|    multiracial | 220 | 61 | 10 |
|    nativeamer | 11 | 1 | |
|    other | 72 | 24 | 1 |
|    white | 1475 | 508 | 37 |
|    #Total cases | 2315 | 790 | 53 |
# use the plot() command to create scatterplots of your continuous variables
plot(d3$mindful, d3$swb,
main="Scatterplot of Mindfulness and Subjective Well-Being",
xlab = "Mindfulness",
ylab = "SWB")
plot(d3$mindful, d3$efficacy,
main="Scatterplot of Mindfulness and Efficacy",
xlab = "Mindfulness",
ylab = "Efficacy")
plot(d3$mindful, d3$stress,
main="Scatterplot of Mindfulness and Stress",
xlab = "Mindfulness",
ylab = "Stress")
# use the boxplot() command to create boxplots of your continuous and categorical variables
boxplot(data=d3, mindful~race_rc,
main="Boxplot of Mindfulness and Participant Race",
xlab = "Participant Race",
ylab = "Mindfulness")
boxplot(data=d3, swb~race_rc,
main="Boxplot of Subjective Well-Being and Participant Race",
xlab = "Participant Race",
ylab = "SWB")
boxplot(data=d3, stress~race_rc,
main="Boxplot of Stress and Participant Race",
xlab = "Participant Race",
ylab = "Stress")
boxplot(data=d3, efficacy~race_rc,
main="Boxplot of Efficacy and Participant Race",
xlab = "Participant Race",
ylab = "Efficacy")
boxplot(data=d3, mindful~gender,
main="Boxplot of Mindfulness and Gender",
xlab = "Gender",
ylab = "Mindfulness")
boxplot(data=d3, swb~gender,
main="Boxplot of Subjective Well-Being and Gender",
xlab = "Gender",
ylab = "SWB")
boxplot(data=d3, stress~gender,
main="Boxplot of Stress and Gender",
xlab = "Gender",
ylab = "Stress")
boxplot(data=d3, efficacy~gender,
main="Boxplot of Efficacy and Gender",
xlab = "Gender",
ylab = "Efficacy")
Do your continuous variables meet the criteria for univariate normality? Three of my continous variables meet criteria for univariate normality, but one of them do not. Mindfulness: skew: 0.06, kurtosis: -0.13 SWB: skew: -0.36, kurtosis: -0.46 Efficacy: skew: -0.29, kurtosis: 0.63 Stress: skew: -0.16, kurtosis: 2.67 The continous variable where kurtosis is displayed is the Stress variable. I think that outliers are more likely because there is high kurtosis.
Do you have any missing data? Once you have removed the cases/participants with missing data, what is your total sample size? Please discuss how much data is missing and whether it’s due to survey design or individual non-response. I do have some missing data. 24 participants skipped some of the questions selected for analysis (individual non-response). Originally, there were a total of 3182 participants, but after filtering out those who did not respond, there were a total of 3158. Only 1% of participants skipped some of the questions, which falls below the 5% cutoff.