mtcars%>%
group_by(am)%>%
summarize(mean=mean(mpg),SD=sd(mpg))
mtcars%>%
filter(am==0)%>%
group_by(am,gear)%>%
summarize(mean=mean(mpg),SD=sd(mpg))
## `summarise()` has grouped output by 'am'. You can override using the `.groups`
## argument.
excel_data <- read_excel("Data1.xlsx")
## New names:
## • `Relax3` -> `Relax3...40`
## • `Relax3` -> `Relax3...41`
## • `Education` -> `Education...50`
## • `` -> `...51`
## • `Income` -> `Income...52`
## • `` -> `...71`
## • `Education` -> `Education...72`
## • `` -> `...73`
## • `` -> `...74`
## • `` -> `...75`
## • `Income` -> `Income...76`
## • `` -> `...77`
## • `` -> `...79`
## • `` -> `...80`
## • `` -> `...81`
## • `` -> `...82`
excel_data
mean(excel_data$age)
## [1] 49.26897
Excel_data2 <- excel_data%>%
mutate(agecode=ifelse(age<=50, "at most 50 years old", "More than 50 years old"))
names(Excel_data2)
## [1] "No."
## [2] "Gender"
## [3] "age"
## [4] "Reappraisal1"
## [5] "Reappraisal2"
## [6] "Reappraisal3"
## [7] "Reappraisal4"
## [8] "Reappraisal5"
## [9] "ReappraisalMean"
## [10] "SocialSupport1"
## [11] "SocialSupport2"
## [12] "SocialSupport3"
## [13] "SocialSupportMean"
## [14] "ProbSolving1"
## [15] "ProbSolving2"
## [16] "ProbSolving3"
## [17] "ProbSolving4"
## [18] "ProbSolvingMean"
## [19] "Rel1"
## [20] "Rel2"
## [21] "Rel3"
## [22] "Rel4"
## [23] "RelMean"
## [24] "Tol1"
## [25] "Tol2"
## [26] "TolMean"
## [27] "Emo1"
## [28] "Emo2"
## [29] "Emo3"
## [30] "Emo4"
## [31] "Emomean"
## [32] "Overac1"
## [33] "Overac2"
## [34] "Overac3"
## [35] "Overac4"
## [36] "Overac5"
## [37] "OveracMean"
## [38] "Relax1"
## [39] "Relax2"
## [40] "Relax3...40"
## [41] "Relax3...41"
## [42] "Relax4"
## [43] "RelaxMean"
## [44] "Subs1"
## [45] "Subs2"
## [46] "Subs3"
## [47] "Subs4"
## [48] "Subs5"
## [49] "Subsmean"
## [50] "Education...50"
## [51] "...51"
## [52] "Income...52"
## [53] "DASS_1"
## [54] "DASS_2"
## [55] "DASS_4"
## [56] "DASS_6"
## [57] "DASS_7"
## [58] "DASS_8"
## [59] "DASS_9"
## [60] "DASS_11"
## [61] "DASS_12"
## [62] "DASS_14"
## [63] "DASS_15"
## [64] "DASS_18"
## [65] "DASS_19"
## [66] "DASS_20"
## [67] "StTotal"
## [68] "Stress"
## [69] "AnTotal"
## [70] "Anxiety"
## [71] "...71"
## [72] "Education...72"
## [73] "...73"
## [74] "...74"
## [75] "...75"
## [76] "Income...76"
## [77] "...77"
## [78] "Enter the score into D,A, S according to the question number from 1-21."
## [79] "...79"
## [80] "...80"
## [81] "...81"
## [82] "...82"
## [83] "agecode"
Excel_data2[,c("age","agecode")]