The INTErventions, Research, and Action in Cities Team (INTERACT) is a national research collaboration of scientists, urban planners, and engaged citizens uncovering how the design of our cities is shaping the health and wellbeing of Canadians (www.teaminteract.ca). INTERACT is conducting longitudinal, mixed-methods natural experiment studies in four Canadian cities, with the aim of providing evidence on the impacts of urban transformations on people’s physical activity, social participation, and wellbeing, and inequalities in these outcomes.

The Saskatoon study evaluates the impacts of a Bus Rapid Transit system (BRT) along three major roadways. Participants who rode the bus at least once in a typical month were eligible to participate. Exclusion criteria across all sites were being younger than 18 years old, not being able to read or write English (or English or French in Montreal) well enough to answer an online survey and any intention to move out of the region in the next two year. Specific recruitment efforts were made to recruit participants who lived within a postal code that was within 800 m of the proposed BRT lines, but anyone in the city could participate.

Recruitment ran from September 19th to December 27th, 2018 (100 days), using social media, partner networks, in-person recruitment at bus shelters, and media appearences. Participants received a $10 gift certificate upon completion of the Health Questionnaire.

In Saskatoon, 316 participants completed the Health Questionnaire.

Section 1: Transportation

Which Saskatoon Transit Go Pass do you own?

response_labels = c(
"Monthly adult pass",
"Eco Pass",
"UPass",
"Student Pass",
"Discounted Pass",
"Low Income Pass",
"I do not use a Go pass, I use a multi-use pass",
"I do not use a Go pass, I use cash",
"other"
)


ggplot(d, aes(x = factor(d$sask_bus_pass,
                         labels = response_labels))) + geom_bar(na.rm = TRUE, fill = 1:9, alpha = 0.65) + xlab("Pass type") + theme(axis.text.x = element_text(angle = 30, hjust = 1)) 

full_table <- table_maker(d,column_name = "sask_bus_pass", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left") 
Response N Percentage
Monthly adult pass 60 18.99
Eco Pass 22 6.96
UPass 99 31.33
Student Pass 50 15.82
Discounted Pass 7 2.22
Low Income Pass 6 1.90
I do not use a Go pass, I use a multi-use pass 44 13.92
I do not use a Go pass, I use cash 18 5.70
other 10 3.16

On a scale of 1 to 4, with 1 being ‘very safe and 4 being ’very unsafe’, overall, how safe do you think traveling by bus is in your city?

response_labels <- c(
    "Very Safe",
    "Somewhat Safe",
    "Somewhat Unsafe",
    "Very Unsafe"
  )

ggplot(d, aes(x = factor(
  x = d$bus_safe,
  labels = response_labels
))) + geom_bar(na.rm = TRUE, fill = 1:4) + xlab("Safety") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d,column_name = "bus_safe", response_labels)

kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very Safe 137 43.35
Somewhat Safe 152 48.10
Somewhat Unsafe 21 6.65
Very Unsafe 6 1.90

On a scale of 1 to 4, with 1 being ‘very reliable’ and 4 being ‘very unreliable’, overall, how reliable do you think traveling by bus is in your city?

response_labels <- c(
    "Very reliable",
    "Somewhat reliable",
    "Somewhat unreliable",
    "Very unreliable",
    "I don't know"
  )
ggplot(d, aes(x = factor(
  x = d$bus_reliable,
  labels = response_labels
))) + geom_bar(na.rm = TRUE, fill = 1:5) + xlab("Reliability") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d,column_name = "bus_reliable", response_labels)

kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very reliable 33 10.44
Somewhat reliable 165 52.22
Somewhat unreliable 93 29.43
Very unreliable 23 7.28
I don’t know 2 0.63

On a scale of 1 to 4, with 1 being ‘very convenient’ and 4 being very inconvenient’, overall, how convenient do you think traveling by bus is in your city?

response_labels <- c(
      "Very convenient",
      "Somewhat convenient",
      "Somewhat inconvenient",
      "Very inconvenient",
      "I don't know"
      )
ggplot(d, aes(x = factor(x = d$bus_convenient, labels = response_labels))) +
      geom_bar(na.rm = TRUE, fill = 1:5) + xlab("Convenience") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_reliable", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very convenient 33 10.44
Somewhat convenient 165 52.22
Somewhat inconvenient 93 29.43
Very inconvenient 23 7.28
I don’t know 2 0.63

How often do you typically travel by bus during each season?

Fall

ggplot(d, aes(x = d$bus_freq_a
)) + geom_histogram(na.rm = TRUE,bins = 10, fill = "#E5364D") + xlab("Days in Fall") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

summary(d$bus_freq_a)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   30.00   65.00   52.77   65.00   91.00

Winter

ggplot(d, aes(x = d$bus_freq_b
)) + geom_histogram(na.rm = TRUE,bins = 10, fill = "#1596FF") + xlab("Days in Winter") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

summary(d$bus_freq_b)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   39.00   65.00   55.65   65.00   91.00

Spring

ggplot(d, aes(x = d$bus_freq_c
)) + geom_histogram(na.rm = TRUE,bins = 10, fill = "#76D24A") + xlab("Days in Spring") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

summary(d$bus_freq_c)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   26.00   65.00   48.02   65.00   91.00

Summer

ggplot(d, aes(x = d$bus_freq_d
)) + geom_histogram(na.rm = TRUE,bins = 10, fill = "#FFD21F") + xlab("Days in Summer") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

summary(d$bus_freq_d)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0     0.0    24.0    33.1    65.0    91.0

Do you currently travel on any of the following streets when you travel by bus in Saskatoon?

a. 8th street

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_a,
         labels = response_labels))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 182 57.59
No 127 40.19
I don’t know 7 2.22

b. 22nd street

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_b,
         labels =response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 111 35.13
No 192 60.76
I don’t know 13 4.11

c. College Drive

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_c,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 226 71.52
No 81 25.63
I don’t know 9 2.85

d. Preston Avenue

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_d,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 165 52.22
No 142 44.94
I don’t know 9 2.85

e. Attridge Drive

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_e,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 66 20.89
No 225 71.20
I don’t know 25 7.91

f. Warman Rd

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_f,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_f", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 50 15.82
No 251 79.43
I don’t know 15 4.75

g. Idylwyld Dr N

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_g,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_g", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 90 28.48
No 208 65.82
I don’t know 18 5.70

h. 3rd Avenue N

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_h,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_h", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 132 41.77
No 161 50.95
I don’t know 23 7.28

i. Broadway Avenue

response_labels <- c("Yes",
                    "No",
                    "I don't know")
ggplot(d,
       aes(x = factor(
         x = d$saskroads_i,
         labels = response_labels ))) +
      geom_bar(na.rm = TRUE, fill =3:1) + xlab("Response") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "saskroads_i", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 151 47.78
No 156 49.37
I don’t know 9 2.85

How much would you agree with the following statement: “I would like to travel by bus in Saskatoon more than I do now”?

response_labels <- c(
           "Strongly agree",
           "Somewhat agree",
           "Somewhat disagree",
           "Strongly disagree",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$sask_bus_more,
         labels = response_labels))) +
      geom_bar(na.rm = TRUE, fill =1:5)+
      xlab("agreement")+
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "sask_bus_more", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Strongly agree 94 29.75
Somewhat agree 133 42.09
Somewhat disagree 53 16.77
Strongly disagree 25 7.91
I don’t know 11 3.48

How much more likely would you be to travel by bus more if?

a. the bus on the main part of your route ran every 10 minutes or less?

response_labels <- c(
           "Much more likely",
           "Somewhat more likely",
           "Not at all more likely",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$bus_moti_a,
         labels = response_labels))) + 
      geom_bar(na.rm = TRUE, fill =1:4) +
      xlab("Likelihood") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_moti_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Much more likely 233 73.73
Somewhat more likely 60 18.99
Not at all more likely 20 6.33
I don’t know 3 0.95

b. the bus route took you closer to your destination?

response_labels <- c(
           "Much more likely",
           "Somewhat more likely",
           "Not at all more likely",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$bus_moti_b,
         labels = response_labels))) + 
      geom_bar(na.rm = TRUE, fill =1:4) +
      xlab("Likelihood") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_moti_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Much more likely 184 58.23
Somewhat more likely 84 26.58
Not at all more likely 43 13.61
I don’t know 5 1.58

c. the bus and shelters were cleaner and in better condition?

response_labels <- c(
           "Much more likely",
           "Somewhat more likely",
           "Not at all more likely",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$bus_moti_c,
         labels = response_labels))) +
      geom_bar(na.rm = TRUE, fill =1:4) + 
      xlab("Likelihood") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_moti_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Much more likely 135 42.72
Somewhat more likely 99 31.33
Not at all more likely 68 21.52
I don’t know 14 4.43

d. the buses were on time and transfers were more reliable?

response_labels <- c(
           "Much more likely",
           "Somewhat more likely",
           "Not at all more likely",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$bus_moti_d,
         labels = response_labels ))) + geom_bar(na.rm = TRUE, fill =1:4) + xlab("Likelihood") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_moti_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Much more likely 241 76.27
Somewhat more likely 59 18.67
Not at all more likely 13 4.11
I don’t know 3 0.95

e. the cost of bus passes or fare was lower?

response_labels <- c(
           "Much more likely",
           "Somewhat more likely",
           "Not at all more likely",
           "I don't know"
         )
ggplot(d,
       aes(x = factor(
         x = d$bus_moti_e,
         labels = response_labels))) +
      geom_bar(na.rm = TRUE, fill =1:4) +
      xlab("Likelihood") +
      theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "bus_moti_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Much more likely 140 44.30
Somewhat more likely 88 27.85
Not at all more likely 71 22.47
I don’t know 17 5.38

Rank the following in order of how much they would influence your decision to use the bus.

a. the bus on the main part of your route ran every 10 minutes or less?

response_labels <-  c(
           "1",
           "2",
           "3",
           "4",
           "5",
           "6",
           "7"
         )
rank <- factor(
         x = d$bus_moti_rank_a,
         labels = response_labels)
ggplot(d,
       aes(x = rank 
       )) +
      geom_bar(na.rm = TRUE , fill =1:7 , alpha= 0.65) +
      xlab("Rank")

full_table <- table_maker(d, column_name = "bus_moti_rank_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1 106 33.54
2 50 15.82
3 42 13.29
4 23 7.28
5 33 10.44
6 11 3.48
7 51 16.14

b. the bus route took you closer to your destination?

response_labels <-  c(
           "1",
           "2",
           "3",
           "4",
           "5",
           "6",
           "7"
         )
rank <- factor(
         x = d$bus_moti_rank_b,
         labels = response_labels)
ggplot(d,
       aes(x = rank 
       )) + geom_bar(na.rm = TRUE , fill =1:7 , alpha= 0.65) + xlab("Rank")

full_table <- table_maker(d, column_name = "bus_moti_rank_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1 43 13.61
2 57 18.04
3 61 19.30
4 64 20.25
5 40 12.66
6 21 6.65
7 30 9.49

c. the bus and shelters were cleaner and in better condition?

response_labels <-  c(
           "1",
           "2",
           "3",
           "4",
           "5",
           "6",
           "7"
         )
rank <- factor(
         x = d$bus_moti_rank_c,
         labels = response_labels)
ggplot(d,
       aes(x = rank 
       )) + geom_bar(na.rm = TRUE , fill =1:7 , alpha= 0.65) + xlab("Rank")

full_table <- table_maker(d, column_name = "bus_moti_rank_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1 22 6.96
2 36 11.39
3 52 16.46
4 85 26.90
5 93 29.43
6 14 4.43
7 14 4.43

d. the buses were on time and transfers were more reliable?

response_labels <-  c(
           "1",
           "2",
           "3",
           "4",
           "5",
           "6",
           "7"
         )
rank <- factor(
         x = d$bus_moti_rank_d,
         labels = response_labels)
ggplot(d,
       aes(x = rank 
       )) + geom_bar(na.rm = TRUE , fill =1:7 , alpha= 0.65) + xlab("Rank")

full_table <- table_maker(d, column_name = "bus_moti_rank_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1 72 22.78
2 76 24.05
3 58 18.35
4 28 8.86
5 21 6.65
6 20 6.33
7 41 12.97

e. the cost of bus passes or fare was lower?

response_labels <-  c(
           "1",
           "2",
           "3",
           "4",
           "5",
           "6",
           "7"
         )
rank <- factor(
         x = d$bus_moti_rank_e,
         labels = response_labels)
ggplot(d,
       aes(x = rank 
       )) + geom_bar(na.rm = TRUE , fill =1:7 , alpha= 0.65) + xlab("Rank")

full_table <- table_maker(d, column_name = "bus_moti_rank_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1 57 18.04
2 36 11.39
3 41 12.97
4 63 19.94
5 75 23.73
6 18 5.70
7 26 8.23

Place the slider between the following features of a future bus system, based on how important they are to you, with the slider closer to the more important feature.

ggplot(d,
       aes(x = bus_moti_slider 
       )) + geom_histogram(na.rm = TRUE, bins = 15, fill= "#76D24A")  + xlab("Rank")

summary(d$bus_moti_slider)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   10.00   23.00   32.81   49.00  100.00

Do you think Saskatoon Transit Service today is:

a. Reliable

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_a,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Reliability")

full_table <- table_maker(d, column_name = "sask_bus_now_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 30 9.49
Moderately 158 50.00
Slightly 85 26.90
Not at all 41 12.97
I don’t know 2 0.63

b. Clean

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_b,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("cleanness")

full_table <- table_maker(d, column_name = "sask_bus_now_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 51 16.14
Moderately 172 54.43
Slightly 66 20.89
Not at all 23 7.28
I don’t know 4 1.27

c. Safe

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_c,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Safety")

full_table <- table_maker(d, column_name = "sask_bus_now_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 100 31.65
Moderately 160 50.63
Slightly 47 14.87
Not at all 7 2.22
I don’t know 2 0.63

d. Convenient

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_d,
  labels = response_labels )
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Convenience")

full_table <- table_maker(d, column_name = "sask_bus_now_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 28 8.86
Moderately 113 35.76
Slightly 116 36.71
Not at all 58 18.35
I don’t know 1 0.32

e. Too expensive

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_e,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Too expensive")

full_table <- table_maker(d, column_name = "sask_bus_now_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 55 17.41
Moderately 84 26.58
Slightly 93 29.43
Not at all 53 16.77
I don’t know 31 9.81

f. Too cheap

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all")
x <- factor(
  x = d$sask_bus_now_f,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:4 ,
                              alpha = 0.65) + xlab("Too cheap")

full_table <- table_maker(d, column_name = "sask_bus_now_f", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 8 2.53
Moderately 21 6.65
Slightly 241 76.27
Not at all 46 14.56

g. Professional

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_g,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Professional")

full_table <- table_maker(d, column_name = "sask_bus_now_g", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 45 14.24
Moderately 134 42.41
Slightly 102 32.28
Not at all 25 7.91
I don’t know 10 3.16

h. Environmentally friendly

response_labels <- c("Very",
             "Moderately",
             "Slightly",
             "Not at all",
             "I don't know")
x <- factor(
  x = d$sask_bus_now_h,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Environmentally friendly")

full_table <- table_maker(d, column_name = "sask_bus_now_h", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very 45 14.24
Moderately 131 41.46
Slightly 74 23.42
Not at all 26 8.23
I don’t know 40 12.66

Have you ever heard of the Bus Rapid Transit (BRT) Corridors in Saskatoon?

response_labels <- c("Yes",
             "No")
x <- factor(
  x = d$brt_familiarity,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 3:2 ,
                              alpha = 0.65) + xlab("Response")

full_table <- table_maker(d, column_name = "brt_familiarity", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 173 54.75
No 143 45.25

Do you think that the Bus Rapid Transit (BRT) corridors are a good or bad idea for Saskatoon? It is

response_labels <-c(
    "Very good idea",
    "Somewhat good idea",
    "Somewhat bad idea",
    "Very bad idea",
    "I don't know"
  )
x <- factor(
  x = d$brt_idea,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_idea", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good idea 184 58.23
Somewhat good idea 109 34.49
Somewhat bad idea 9 2.85
Very bad idea 3 0.95
I don’t know 11 3.48

Do you think the BRT will be good for:

a. The Environment

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_a,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 98 31.01
Somewhat good 147 46.52
Somewhat bad 22 6.96
Very bad 4 1.27
I don’t know 45 14.24

b. Increasing access to transportation

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_b,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 203 64.24
Somewhat good 93 29.43
Somewhat bad 8 2.53
Very bad 3 0.95
I don’t know 9 2.85

c. Making Saskatoon a vibrant city

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_c,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 126 39.87
Somewhat good 136 43.04
Somewhat bad 8 2.53
Very bad 6 1.90
I don’t know 40 12.66

d. Tourism

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_d,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 116 36.71
Somewhat good 127 40.19
Somewhat bad 14 4.43
Very bad 5 1.58
I don’t know 54 17.09

e. Reducing traffic congestion

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_e,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 152 48.10
Somewhat good 109 34.49
Somewhat bad 21 6.65
Very bad 8 2.53
I don’t know 26 8.23

f. Health

response_labels <-  c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_f,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_f", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 80 25.32
Somewhat good 138 43.67
Somewhat bad 14 4.43
Very bad 5 1.58
I don’t know 79 25.00

g. Local business

response_labels <- c(
    "Very good",
    "Somewhat good",
    "Somewhat bad",
    "Very bad",
    "I don't know"
  )
x <- factor(
  x = d$brt_good_g,
  labels =response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "brt_good_g", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Very good 101 31.96
Somewhat good 135 42.72
Somewhat bad 17 5.38
Very bad 7 2.22
I don’t know 56 17.72

Will you likely travel by bus more than you currently do once the Bus Rapid Transit (BRT) corridors are in place?

response_labels <- c("Yes",
                       "No")
x <- factor(
  x = d$brt_bus_more,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 3:2 ,
                              alpha = 0.65) + xlab("Response")

full_table <- table_maker(d, column_name = "brt_bus_more", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 254 80.38
No 62 19.62

Do you currently have a valid driver’s license?

response_labels <- c("Yes",
                       "No")
x <- factor(
  x = d$license,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 3:2 ,
                              alpha = 0.65) + xlab("Response")

full_table <- table_maker(d, column_name = "license", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 240 75.95
No 76 24.05

Do you have access to a car?

response_labels <- c("Yes",
                       "No")

x <- factor(x = d$car_access,
            labels =  response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 3:2 ,
                              alpha = 0.65) + xlab("Response")

full_table <- table_maker(d, column_name = "car_access", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 222 70.25
No 94 29.75

How do you most often access a vehicle?

Total

response_labels <- c(
    "Not applicable",
    "My household owns a vehicle",
    "I borrow a friend's or relative's vehicle",
    "I am a member of a car-sharing program (Saskatoon CarShare Co-op, etc)",
    "I access a vehicle another way (Please specify)"
  )
#Modify the data
d$cars_access_where <- d$cars_access_where %>%
      as.character() 
d$cars_access_where[which(d$cars_access_where == "[1, 2]")] <- "[1]"
x <- factor(
  x = d$cars_access_where,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:5 ,
                              alpha = 0.65) + xlab("Response") + 
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d,"cars_access_where",response_labels)

kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 94 29.75
My household owns a vehicle 196 62.03
I borrow a friend’s or relative’s vehicle 9 2.85
I am a member of a car-sharing program (Saskatoon CarShare Co-op, etc) 4 1.27
I access a vehicle another way (Please specify) 13 4.11

My household owns a vehicle

response_labels <-  c(
    "Not applicable",
    "False",
    "True"
  )
x <- factor(
  x = d$cars_access_where_1,
  labels = response_labels
)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:3 ,
                              alpha = 0.65) + xlab("Response") + 
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "cars_access_where_1", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 94 29.75
False 26 8.23
True 196 62.03

I borrow a friend’s or relative’s vehicle

response_labels <-  c(
    "Not applicable",
    "False",
    "True"
  )
x <- factor(
  x = d$cars_access_where_2,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:3 ,
                              alpha = 0.65) + xlab("Response") + 
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "cars_access_where_2", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 94 29.75
False 211 66.77
True 11 3.48

I am a member of a car-sharing program (Saskatoon CarShare Co-op, etc.)

response_labels <-  c(
    "Not applicable",
    "False",
    "True"
  )
x <- factor(
  x = d$cars_access_where_3,
  labels =  response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              fill = 1:3 ,
                              alpha = 0.65) + xlab("Response") + 
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "cars_access_where_3", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 94 29.75
False 218 68.99
True 4 1.27

How many cars, trucks, or vans are kept in your household?

response_labels <-  c("Not applicable",
             "0", "1", "2", "3", "4", "5", "6")
#set na values to 0
d$cars_household[which(is.na(d$cars_household))] <- 0
x <- factor(
  x = d$cars_household,
   labels= response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 , fill = 1:8) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "cars_household", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 120 37.97
0 4 1.27
1 82 25.95
2 69 21.84
3 22 6.96
4 15 4.75
5 3 0.95
6 1 0.32

How much do you enjoy using each transportation mode?

a. Walking

response_labels <- c("1.A lot", "2", "3", "4.Not at all ", "Not applicable")
x <- factor(
  x = d$preferred_mode_a,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:5) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_a", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1.A lot 139 43.99
2 86 27.22
3 69 21.84
4.Not at all 20 6.33
Not applicable 2 0.63

b. Biking

response_labels <- c("1.A lot", "2", "3", "4.Not at all ", "Not applicable")
x <- factor(
  x = d$preferred_mode_b,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:5) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_b", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1.A lot 89 28.16
2 73 23.10
3 45 14.24
4.Not at all 64 20.25
Not applicable 45 14.24

c. Public Transit

response_labels <- c("1.A lot", "2", "3", "4.Not at all ")
x <- factor(
  x = d$preferred_mode_c,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:4) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_c", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1.A lot 51 16.14
2 138 43.67
3 95 30.06
4.Not at all 32 10.13

d. Car

response_labels <- c("1.A lot", "2", "3", "4.Not at all ", "Not applicable")
x <- factor(
  x = d$preferred_mode_d,
  labels = response_labels
)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:5) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_d", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1.A lot 130 41.14
2 86 27.22
3 54 17.09
4.Not at all 14 4.43
Not applicable 32 10.13

e. Motorcycle or scooter

response_labels <- c("1.A lot", "2", "3", "4.Not at all ", "Not applicable")
x <- factor(
  x = d$preferred_mode_e,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:5) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_e", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
1.A lot 5 1.58
2 13 4.11
3 16 5.06
4.Not at all 68 21.52
Not applicable 214 67.72

f. Other (Please specify)

response_labels <- c( "Not applicable","1.A lot", "2", "3", "4.Not at all ")
x <- factor(
  x = d$preferred_mode_f,
  labels = response_labels)
ggplot(d,
       aes(x = x)) + geom_bar(na.rm = TRUE ,
                              alpha = 0.65 ,
                              fill = 1:5) + xlab("Response") +
  theme(axis.text.x = element_text(angle = 30, hjust = 1))

full_table <- table_maker(d, column_name = "preferred_mode_f", response_labels)
kable(full_table) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not applicable 5 1.58
1.A lot 1 0.32
2 1 0.32
3 1 0.32
4.Not at all 308 97.47

Section 2: Physical Activity

During the last 7 days, on how many days did you do vigorous physical activities like heavy lifting, digging, heavy construction, or climbing up stairs as part of your work? Think about only those physical activities that you did for at least 10 minutes at a time.

#work_vigpa

ggplot(d, aes(x = d$work_vigpa)) + geom_histogram(na.rm = TRUE, fill = "#1596FF") + xlab("N days vigorous job-related physical activity")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$work_vigpa)), Percentage = round(as.numeric(prop.table(table(d$work_vigpa)))*100,2))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 194 61.39
1 16 5.06
2 26 8.23
3 17 5.38
4 24 7.59
5 22 6.96
6 6 1.90
7 11 3.48

How much time did you usually spend on one of those days doing vigorous physical activities as part of your work?

#work_vigpa_freq

d$work_vigpa_freq[d$work_vigpa_freq==-7] <- NA

ggplot(d, aes(x = d$work_vigpa_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes vigorous job-related physical activity") 

summary(d$work_vigpa_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     0.0    60.0   120.0   136.1   180.0   960.0     194

Again, think about only those physical activities that you did for at least 10 minutes at a time. During the last 7 days, on how many days did you do moderate physical activities like carrying light loads as part of your work? Please do not include walking.

#work_modpa

ggplot(d, aes(x = d$work_modpa)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days moderate job-related physical activity")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$work_modpa)), Percentage = round(as.numeric(prop.table(table(d$work_modpa)))*100,2))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 142 44.94
1 30 9.49
2 34 10.76
3 25 7.91
4 23 7.28
5 39 12.34
6 3 0.95
7 20 6.33

How much time did you usually spend on one of those days doing moderate physical activities as part of your work?

#work_modpa_freq

d$work_modpa_freq[d$work_modpa_freq==-7] <- NA
ggplot(d, aes(x = d$work_modpa_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes moderate job-related physical activity") 

summary(d$work_modpa_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     0.0    30.0    60.0   121.2   180.0   480.0     142

During the last 7 days, on how many days did you travel in a motor vehicle like a train, bus, car, or metro?

#travel_motor

ggplot(d, aes(x = d$travel_motor)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$travel_motor)), Percentage = round(as.numeric(prop.table(table(d$travel_motor)))*100,2))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 4 1.27
1 4 1.27
2 10 3.16
3 21 6.65
4 23 7.28
5 49 15.51
6 60 18.99
7 145 45.89

How much time did you usually spend on one of those days travelling in a train, bus, car, metro, or other kind of motor vehicle?

#travel_motor_freq

d$travel_motor_freq[d$travel_motor_freq==-7] <- NA
ggplot(d, aes(x = d$travel_motor_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes travel time") 

summary(d$travel_motor_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    1.00   30.00   60.00   77.64  120.00  900.00       4

During the last 7 days, on how many days did you bicycle for at least 10 minutes at a time to go from place to place?

#travel_bike

ggplot(d, aes(x = d$travel_bike)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$travel_bike)), Percentage = round(as.numeric(prop.table(table(d$travel_bike)))*100,2))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 259 81.96
1 15 4.75
2 7 2.22
3 8 2.53
4 7 2.22
5 11 3.48
6 2 0.63
7 7 2.22

How much time did you usually spend on one of those days to bicycle from place to place?

#travel_bike_freq

d$travel_bike_freq[d$travel_bike_freq==-7] <- NA
ggplot(d, aes(x = d$travel_bike_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes travel time") 

summary(d$travel_bike_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    0.00   30.00   35.00   58.07   60.00  420.00     259

During the last 7 days, on how many days did you walk for at least 10 minutes at a time to go from place to place?

#travel_walk

ggplot(d, aes(x = d$travel_walk)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("# of days in the last 7 days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$travel_walk)), Percentage = round(as.numeric(prop.table(table(d$travel_walk)))*100,2))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 40 12.66
1 20 6.33
2 35 11.08
3 36 11.39
4 32 10.13
5 64 20.25
6 26 8.23
7 63 19.94

How much time did you usually spend on one of those days walking from place to place?

#travel_walk_freq

d$travel_walk_freq[d$travel_walk_freq==-7] <- NA

ggplot(d, aes(x = d$travel_walk_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes travel time") 

summary(d$travel_walk_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    1.00   20.00   30.00   43.85   60.00  420.00      40

Not counting any walking for transportation that you have already mentioned, during the last 7 days, on how many days did you walk for at least 10 minutes at a time in your leisure time?

#leisure_walk

ggplot(d, aes(x = d$leisure_walk)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$leisure_walk)), Percentage = round(as.numeric(prop.table(table(d$leisure_walk))*100,2)))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 116 37
1 31 10
2 50 16
3 47 15
4 24 8
5 19 6
6 7 2
7 22 7

How much time did you usually spend on one of those days walking in your leisure time?

#leisure_walk_freq

d$leisure_walk_freq[d$leisure_walk_freq==-7] <- NA

ggplot(d, aes(x = d$leisure_walk_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes leisure time") 

summary(d$leisure_walk_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    1.00   20.00   30.00   56.16   60.00  900.00     116

Think about only those physical activities that you did for at least 10 minutes at a time, not counting any activity for transportation or work that you have already mentioned. During the last 7 days, on how many days did you do vigorous physical activities like aerobics, running, fast bicycling, or fast swimming in your leisure time?

#leisure_vigpa

ggplot(d, aes(x = d$leisure_vigpa)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$leisure_vigpa)), Percentage = round(as.numeric(prop.table(table(d$leisure_vigpa))*100,2)))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 175 55
1 31 10
2 48 15
3 24 8
4 12 4
5 15 5
6 9 3
7 2 1

How much time did you usually spend on one of those days doing vigorous physical activities in your leisure time?

#leisure_vigpa_freq

d$leisure_vigpa_freq[d$leisure_vigpa_freq==-7] <- NA

ggplot(d, aes(x = d$leisure_vigpa_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes leisure time") 

summary(d$leisure_vigpa_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    5.00   40.00   60.00   63.89   60.00  420.00     175

During the last 7 days, on how many days did you do moderate physical activities like bicycling at a regular pace, swimming at a regular pace, or doubles tennis in your leisure time?

#leisure_modpa

ggplot(d, aes(x = d$leisure_modpa)) + geom_histogram(na.rm = TRUE, fill="#1596FF") + xlab("N days")

kable(data.frame(Days = 0:7, N = as.numeric(table(d$leisure_modpa)), Percentage = round(as.numeric(prop.table(table(d$leisure_modpa))*100,2)))) %>% kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Days N Percentage
0 205 65
1 35 11
2 32 10
3 16 5
4 19 6
5 6 2
6 1 0
7 2 1

How much time did you usually spend on one of those days doing moderate physical activities in your leisure time?

#leisure_modpa_freq

d$leisure_modpa_freq[d$leisure_modpa_freq==-7] <- NA

ggplot(d, aes(x = d$leisure_modpa_freq)) + geom_histogram(na.rm = TRUE, binwidth = 20, fill= "#35AAC2") + xlab("Minutes leisure time") 

summary(d$leisure_modpa_freq)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##     2.0    30.0    45.0    56.9    60.0   480.0     205

During the last 7 days, how much time did you usually spend sitting on a weekday?

#sit_weekday

ggplot(d, aes(x = d$sit_weekday/60)) + geom_histogram(na.rm = TRUE, binwidth = 1, fill= "#35AAC2") + xlab("Hours sitting, weekday") 

summary(d$sit_weekday)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0   240.0   360.0   394.1   540.0   960.0

During the last 7 days, how much time did you usually spend sitting on a weekend day?

#sit_weekend

ggplot(d, aes(x = d$sit_weekend/60)) + geom_histogram(na.rm = TRUE, binwidth = 1, fill= "#35AAC2") + xlab("Hours sitting, weekend") 

summary(d$sit_weekend)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     0.0   240.0   300.0   367.9   480.0   960.0

Section 3: General Health

How tall are you?

#height

#exclude outliers?

ggplot(d, aes(x = d$height)) + geom_histogram(na.rm = TRUE, binwidth = 2, fill="#1596FF") + xlab("Height (cm)") 

summary(d$height)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   100.0   163.0   168.0   168.4   175.0   224.0

How much do you weigh?

#weight

ggplot(d, aes(x = d$weight)) + geom_histogram(na.rm = TRUE, binwidth = 2, fill="#1596FF") + xlab("Weight (kg)") 

summary(d$weight)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   30.00   60.00   73.00   76.06   86.00  181.00

In general, would you say your health is:

#sf1

# Create proportional table
sf1 <- round(prop.table(table(d$sf1))*100,2)
sf1 <- as.data.frame(sf1)
sf1$group <- substring(rownames(sf1), 1)
# or use colnames(sf1)[1] <- "group" : 

# Change category values and transform in factor
## as.character(sf1$group) is because as.data.frame transform character into factor
sf1$group <- revalue(as.character(sf1$group), c("1" = "Excellent", "2" = "Very good", "3" = "Good", "4" = "Fair", "5" = "Poor"))

# Create plot
sf1$plot <- factor(sf1$group, sf1$group) ## Necessary to order x-axis in ggplot

sf1.plot <- ggplot(sf1, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTPalette3) +
      ylab("Percent of total") +
      xlab("")
      
sf1.plot + geom_histogram(aes(x = plot), data = sf1, stat = "identity")

# make a clean summary table 
## make a dataframe on count 
sf1.tb <- as.factor(d$sf1)
sf1.tb <- summary(sf1.tb)
sf1.tb <- as.data.frame(sf1.tb)
sf1.tb$Var1 <- substring(row.names(sf1.tb), 1)
sf1.tb$group <- revalue(as.character(sf1.tb$Var1), c("1" = "Excellent", "2" = "Very good", "3" = "Good", "4" = "Fair", "5" = "Poor"))


## merge with existing prop table data used for plot above 
## order doesn't work
plot.sf1.tb <- merge(sf1, sf1.tb, by = "group")
plot.sf1.tb <- plot.sf1.tb[-c(2, 4, 6)]
plot.sf1.tb <- setcolorder(plot.sf1.tb, c("group", "sf1.tb", "Freq"))

plot.sf1.tb$order <- c(1, 4, 3, 5, 2)
plot.sf1.tb <- plot.sf1.tb %>% arrange(order)
plot.sf1.tb <- plot.sf1.tb[-c(4)]
colnames(plot.sf1.tb) <- c("Response", "N", "Percentage")

kable(plot.sf1.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left") 
Response N Percentage
Excellent 28 8.86
Very good 119 37.66
Good 113 35.76
Fair 48 15.19
Poor 8 2.53

The following questions are about activities you might do during a typical day. Does your health now limit you in these activities? If so, how much?

a. Moderate activities such as moving a table, pushing a vacuum cleaner, bowling, or playing golf

sf2 <- round(prop.table(table(factor(d$sf2, levels = c("1", "2", "3")), exclude = NULL))*100,2)
sf2 <- as.data.frame(sf2)
sf2$group <- substring(row.names(sf2), 1)
sf2$group <- revalue(as.character(sf2$group), c("1" = "Yes, limited a lot",  "2" = "Yes, limited a little", "3" = "No, not at all"))

sf2$plot <- factor(sf2$group, sf2$group)

sf2.plot <- ggplot(sf2, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshorterfade) +
      ylab("Percent of total") +
      xlab("")
sf2.plot + geom_histogram(aes(x = plot), data = sf2, stat = "identity")

sf2.tb <- as.factor(d$sf2)
sf2.tb <- summary(sf2.tb)
sf2.tb <- as.data.frame(sf2.tb)
sf2.tb$Var1 <- substring(row.names(sf2.tb), 1)
sf2.tb$group <- revalue(as.character(sf2.tb$Var1), c("1" = "Yes, limited a lot",  "2" = "Yes, limited a little", "3" = "No, not at all"))
plot.sf2.tb <- merge(sf2, sf2.tb, by = "group")
plot.sf2.tb <- plot.sf2.tb[-c(2, 4, 6)]
plot.sf2.tb <- setcolorder(plot.sf2.tb, c("group", "sf2.tb", "Freq"))
plot.sf2.tb$order <- c(3, 2, 1)
plot.sf2.tb <- plot.sf2.tb %>% arrange(order)
plot.sf2.tb <- plot.sf2.tb[-c(4)]
colnames(plot.sf2.tb) <- c("Response", "N", "Percentage")

kable(plot.sf2.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes, limited a lot 9 2.85
Yes, limited a little 47 14.87
No, not at all 260 82.28

b. Climbing several flights of stairs

# sf3 

sf3 <- round(prop.table(table(factor(d$sf3, levels = c("1", "2", "3")), exclude = NULL))*100,2)
sf3 <- as.data.frame(sf3)
sf3$group <- substring(row.names(sf3), 1)
sf3$group <- revalue(as.character(sf3$group), c("1" = "Yes, limited a lot",  "2" = "Yes, limited a little", "3" = "No, not at all"))

sf3$plot <- factor(sf3$group, sf3$group)

sf3.plot <- ggplot(sf3, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshorterfade) +
      ylab("Percent of total") +
      xlab("")
      
sf3.plot + geom_histogram(aes(x = plot), data = sf3, stat = "identity") 

# summary table

sf3.tb <- as.factor(d$sf3)
sf3.tb <- summary(sf3.tb)
sf3.tb <- as.data.frame(sf3.tb)
sf3.tb$Var1 <- substring(row.names(sf3.tb), 1)
sf3.tb$group <- revalue(as.character(sf3.tb$Var1), c("1" = "Yes, limited a lot",  "2" = "Yes, limited a little", "3" = "No, not at all"))
plot.sf3.tb <- merge(sf3, sf3.tb, by = "group")
plot.sf3.tb <- plot.sf3.tb[-c(2, 4, 6)]
plot.sf3.tb <- setcolorder(plot.sf3.tb, c("group", "sf3.tb", "Freq"))
plot.sf3.tb$order <- c(3, 2, 1)
plot.sf3.tb <- plot.sf3.tb %>% arrange(order)
plot.sf3.tb <- plot.sf3.tb[-c(4)]
colnames(plot.sf3.tb) <- c("Response", "N", "Percentage")

kable(plot.sf3.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes, limited a lot 18 5.70
Yes, limited a little 72 22.78
No, not at all 226 71.52

During the past 4 weeks, have you had any of the following problems with your work or other regular daily activities as a result of your physical health?

a. Accomplished less than you would like

#sf4 

sf4<- round(prop.table(table(factor(d$sf4, levels = c("1", "2")), exclude = NULL))*100,2)
sf4 <- as.data.frame(sf4)
sf4$group <- substring(row.names(sf4), 1)
sf4$group <- revalue(as.character(sf4$group), c("1" = "Yes",  "2" = "No"))

sf4$plot <- factor(sf4$group, sf4$group)

sf4.plot <- ggplot(sf4, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) 

sf4.plot + geom_histogram(aes(x = plot), data = sf4, stat = "identity") +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTPaletteYN) +
      ylab("Percent of total") +
      xlab("Response")

sf4.tb <- as.factor(d$sf4)
sf4.tb <- summary(sf4.tb)
sf4.tb <- as.data.frame(sf4.tb)
sf4.tb$Var1 <- substring(row.names(sf4.tb), 1)
sf4.tb$group <- revalue(as.character(sf4.tb$Var1), c("1" = "Yes", "2" = "No"))
plot.sf4.tb <- merge(sf4, sf4.tb, by = "group")
plot.sf4.tb <- plot.sf4.tb[-c(2, 4, 6)]
plot.sf4.tb <- setcolorder(plot.sf4.tb, c("group", "sf4.tb", "Freq"))
plot.sf4.tb$order <- c(2, 1)
plot.sf4.tb <- plot.sf4.tb %>% arrange(order)
plot.sf4.tb <- plot.sf4.tb[-c(4)]
colnames(plot.sf4.tb) <- c("Response", "N", "Percentage")

kable(plot.sf4.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 92 29.11
No 224 70.89

b. Were limited in the kind of work or other activities

#sf5
sf5<- round(prop.table(table(factor(d$sf5, levels = c("1", "2")), exclude = NULL))*100,2)
sf5 <- as.data.frame(sf5)
sf5$group <- substring(row.names(sf5), 1)
sf5$group <- revalue(as.character(sf5$group), c("1" = "Yes",  "2" = "No"))

sf5$plot <- factor(sf5$group, sf5$group)

sf5.plot <- ggplot(sf5, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) 

sf5.plot + geom_histogram(aes(x = plot), data = sf5, stat = "identity") +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTPaletteYN) +
      ylab("Percent of total") +
      xlab("Response")

sf5.tb <- as.factor(d$sf5)
sf5.tb <- summary(sf5.tb)
sf5.tb <- as.data.frame(sf5.tb)
sf5.tb$Var1 <- substring(row.names(sf5.tb), 1)
sf5.tb$group <- revalue(as.character(sf5.tb$Var1), c("1" = "Yes", "2" = "No"))
plot.sf5.tb <- merge(sf5, sf5.tb, by = "group")
plot.sf5.tb <- plot.sf5.tb[-c(2, 4, 6)]
plot.sf5.tb <- setcolorder(plot.sf5.tb, c("group", "sf5.tb", "Freq"))
plot.sf5.tb$order <- c(2, 1)
plot.sf5.tb <- plot.sf5.tb %>% arrange(order)
plot.sf5.tb <- plot.sf5.tb[-c(4)]
colnames(plot.sf5.tb) <- c("Response", "N", "Percentage")

kable(plot.sf5.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 63 19.94
No 253 80.06

During the past 4 weeks, have you had any of the following problems with your work or other regular daily activities as a result of any emotional problems (such as feeling depressed or anxious)?

a. Accomplished less than you would like

#sf6

sf6<- round(prop.table(table(factor(d$sf6, levels = c("1", "2")), exclude = NULL))*100,2)
sf6 <- as.data.frame(sf6)
sf6$group <- substring(row.names(sf6), 1)
sf6$group <- revalue(as.character(sf6$group), c("1" = "Yes",  "2" = "No"))

sf6$plot <- factor(sf6$group, sf6$group)

sf6.plot <- ggplot(sf6, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) 

sf6.plot + geom_histogram(aes(x = plot), data = sf6, stat = "identity") +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTPaletteYN) +
      ylab("Percent of total") +
      xlab("Response")

# summary table

sf6.tb <- as.factor(d$sf6)
sf6.tb <- summary(sf6.tb)
sf6.tb <- as.data.frame(sf6.tb)
sf6.tb$Var1 <- substring(row.names(sf6.tb), 1)
sf6.tb$group <- revalue(as.character(sf6.tb$Var1), c("1" = "Yes", "2" = "No"))
plot.sf6.tb <- merge(sf6, sf6.tb, by = "group")
plot.sf6.tb <- plot.sf6.tb[-c(2, 4, 6)]
plot.sf6.tb <- setcolorder(plot.sf6.tb, c("group", "sf6.tb", "Freq"))
plot.sf6.tb$order <- c(2, 1)
plot.sf6.tb <- plot.sf6.tb %>% arrange(order)
plot.sf6.tb <- plot.sf6.tb[-c(4)]
colnames(plot.sf6.tb) <- c("Response", "N", "Percentage")

kable(plot.sf6.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 162 51.27
No 154 48.73

b. Did work or activities less carefully than usual

#sf7

sf7<- round(prop.table(table(factor(d$sf7, levels = c("1", "2")), exclude = NULL))*100,2)
sf7 <- as.data.frame(sf7)
sf7$group <- substring(row.names(sf7), 1)
sf7$group <- revalue(as.character(sf7$group), c("1" = "Yes",  "2" = "No"))

sf7$plot <- factor(sf7$group, sf7$group)

sf7.plot <- ggplot(sf7, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) 

sf7.plot + geom_histogram(aes(x = plot), data = sf7, stat = "identity") +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTPaletteYN) +
      ylab("Percent of total") +
      xlab("Response")

sf7.tb <- as.factor(d$sf7)
sf7.tb <- summary(sf7.tb)
sf7.tb <- as.data.frame(sf7.tb)
sf7.tb$Var1 <- substring(row.names(sf7.tb), 1)
sf7.tb$group <- revalue(as.character(sf7.tb$Var1), c("1" = "Yes", "2" = "No"))
plot.sf7.tb <- merge(sf7, sf7.tb, by = "group")
plot.sf7.tb <- plot.sf7.tb[-c(2, 4, 6)]
plot.sf7.tb <- setcolorder(plot.sf7.tb, c("group", "sf7.tb", "Freq"))
plot.sf7.tb$order <- c(2, 1)
plot.sf7.tb <- plot.sf7.tb %>% arrange(order)
plot.sf7.tb <- plot.sf7.tb[-c(4)]
colnames(plot.sf7.tb) <- c("Response", "N", "Percentage")

kable(plot.sf7.tb) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Yes 105 33.23
No 211 66.77

During the past 4 weeks, how much did pain interfere with your normal work (including work outside the home and housework)?

#sf8

sf8 <- round(prop.table(table(factor(d$sf8, levels = c("1", "2", "3", "4", "5")), exclude = NULL))*100,2)
sf8 <- as.data.frame(sf8)
sf8$group <- substring(row.names(sf8), 1)
sf8$group <- revalue(as.character(sf8$group), c("1" = "Not at all",  "2" = "Slightly", "3" = "Moderately", "4" =  "Quite a bit", "5" = "Extremely"))

sf8$plot <- factor(sf8$group, sf8$group)

sf8.plot <- ggplot(sf8, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=rev(INTERACTshortfade)) +
      ylab("Percent of total") +
      xlab("")
      
sf8.plot + geom_histogram(aes(x = plot), data = sf8, stat = "identity") 

sf8.tb <- as.factor(d$sf8)
sf8.tb <- summary(sf8.tb)
sf8.tb <- as.data.frame(sf8.tb)
sf8.tb$Var1 <- substring(row.names(sf8.tb), 1)
sf8.tb$group <- revalue(as.character(sf8.tb$Var1), c("1" = "Not at all",  "2" = "Slightly", "3" = "Moderately", "4" =  "Quite a bit", "5" = "Extremely"))
plot.sf8 <- merge(sf8, sf8.tb, by = "group")
plot.sf8 <- plot.sf8[-c(2, 4, 6)]
plot.sf8 <- setcolorder(plot.sf8, c("group", "sf8.tb", "Freq"))
plot.sf8$order <- c(5,3,1,4,2)
plot.sf8 <- plot.sf8 %>% arrange(order)
plot.sf8 <- plot.sf8[-c(4)]
colnames(plot.sf8) <- c("Response", "N", "Percentage")

kable(plot.sf8) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
Not at all 149 47.15
Slightly 97 30.70
Moderately 40 12.66
Quite a bit 22 6.96
Extremely 8 2.53

How much of the time during the past 4 weeks.

a. Have you felt calm and peaceful?

#sf9 

sf9 <- round(prop.table(table(factor(d$sf9, levels = c("1", "2", "3", "4", "5", "6")), exclude = NULL))*100,2)
sf9 <- as.data.frame(sf9)
sf9$group <- substring(row.names(sf9), 1)
sf9$group <- revalue(as.character(sf9$group), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))

sf9$plot <- factor(sf9$group, sf9$group)

sf9.plot <- ggplot(sf9, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshortfade) +
      ylab("Percent of total") +
      xlab("")
      
sf9.plot + geom_histogram(aes(x = plot), data = sf9, stat = "identity") 

sf9.tb <- as.factor(d$sf9)
sf9.tb <- summary(sf9.tb)
sf9.tb <- as.data.frame(sf9.tb)
sf9.tb$Var1 <- substring(row.names(sf9.tb), 1)
sf9.tb$group <- revalue(as.character(sf9.tb$Var1), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))
plot.sf9 <- merge(sf9, sf9.tb, by = "group")
plot.sf9 <- plot.sf9[-c(2, 4, 6)]
plot.sf9 <- setcolorder(plot.sf9, c("group", "sf9.tb", "Freq"))
plot.sf9$order <- c(3,5,1,2,6,4)
plot.sf9 <- plot.sf9 %>% arrange(order)
plot.sf9 <- plot.sf9[-c(4)]
colnames(plot.sf9) <- c("Response", "N", "Percentage")

kable(plot.sf9) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
All of the time 11 3.48
Most of the time 86 27.22
A good bit of the time 91 28.80
Some of the time 72 22.78
A little of the time 50 15.82
None of the time 6 1.90

b. Did you have a lot of energy?

sf10 <- round(prop.table(table(factor(d$sf10, levels = c("1", "2", "3", "4", "5", "6")), exclude = NULL))*100,2)
sf10 <- as.data.frame(sf10)
sf10$group <- substring(row.names(sf10), 1)
sf10$group <- revalue(as.character(sf10$group), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))

sf10$plot <- factor(sf10$group, sf10$group)

sf10.plot <- ggplot(sf10, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshortfade) +
      ylab("Percent of total") +
      xlab("")
      
sf10.plot + geom_histogram(aes(x = plot), data = sf10, stat = "identity") 

sf10.tb <- as.factor(d$sf10)
sf10.tb <- summary(sf10.tb)
sf10.tb <- as.data.frame(sf10.tb)
sf10.tb$Var1 <- substring(row.names(sf10.tb), 1)
sf10.tb$group <- revalue(as.character(sf10.tb$Var1), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))
plot.sf10 <- merge(sf10, sf10.tb, by = "group")
plot.sf10 <- plot.sf10[-c(2, 4, 6)]
plot.sf10 <- setcolorder(plot.sf10, c("group", "sf10.tb", "Freq"))
plot.sf10$order <- c(3,5,1,2,6,4)
plot.sf10 <- plot.sf10 %>% arrange(order)
plot.sf10 <- plot.sf10[-c(4)]
colnames(plot.sf10) <- c("Response", "N", "Percentage")

kable(plot.sf10) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
All of the time 8 2.53
Most of the time 65 20.57
A good bit of the time 107 33.86
Some of the time 80 25.32
A little of the time 45 14.24
None of the time 11 3.48

c. Have you felt downhearted and blue?

#check all of the time is 0 

#sf11

sf11 <- round(prop.table(table(factor(d$sf11, levels = c("1", "2", "3", "4", "5", "6")), exclude = NULL))*100,2)
sf11 <- as.data.frame(sf11)
sf11$group <- substring(row.names(sf11), 1)
sf11$group <- revalue(as.character(sf11$group), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))

sf11$plot <- factor(sf11$group, sf11$group)

sf11.plot <- ggplot(sf11, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshortfade) +
      ylab("Percent of total") +
      xlab("")
      
sf11.plot + geom_histogram(aes(x = plot), data = sf11, stat = "identity") 

sf11.tb <- as.factor(d$sf11)
sf11.tb <- summary(sf11.tb)
sf11.tb <- as.data.frame(sf11.tb)
sf11.tb$Var1 <- substring(row.names(sf11.tb), 1)


sf11.tb$group <- revalue(as.character(sf11.tb$Var1), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))
plot.sf11 <- merge(sf11, sf11.tb, by = "group")
plot.sf11 <- plot.sf11[-c(2, 4, 6)]
plot.sf11 <- setcolorder(plot.sf11, c("group", "sf11.tb", "Freq"))
plot.sf11$order <- c(3,5,1,2,6,4)
plot.sf11 <- plot.sf11 %>% arrange(order)
plot.sf11 <- plot.sf11[-c(4)]
colnames(plot.sf11) <- c("Response", "N", "Percentage")


kable(plot.sf11) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
All of the time 5 1.58
Most of the time 30 9.49
A good bit of the time 51 16.14
Some of the time 76 24.05
A little of the time 112 35.44
None of the time 42 13.29

During the past 4 weeks, how much of the time has your physical health or emotional problems interfered with your social activities (like visiting friends, relatives, etc.)?

#sf12

sf12 <- round(prop.table(table(factor(d$sf12, levels = c("1", "2", "3", "4", "5", "6")), exclude = NULL))*100,2)
sf12 <- as.data.frame(sf12)
sf12$group <- substring(row.names(sf12), 1)
sf12$group <- revalue(as.character(sf12$group), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))

sf12$plot <- factor(sf12$group, sf12$group)

sf12.plot <- ggplot(sf12, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values=INTERACTshortfade) +
      ylab("Percent of total") +
      xlab("")
      
sf12.plot + geom_histogram(aes(x = plot), data = sf12, stat = "identity") 

sf12.tb <- as.factor(d$sf12)
sf12.tb <- summary(sf12.tb)
sf12.tb <- as.data.frame(sf12.tb)
sf12.tb$Var1 <- substring(row.names(sf12.tb), 1)
sf12.tb$group <- revalue(as.character(sf12.tb$Var1), c("1" = "All of the time",  "2" = "Most of the time", "3" = "A good bit of the time", "4" =  "Some of the time", "5" = "A little of the time", "6" = "None of the time"))
plot.sf12 <- merge(sf12, sf12.tb, by = "group")
plot.sf12 <- plot.sf12[-c(2, 4, 6)]
plot.sf12 <- setcolorder(plot.sf12, c("group", "sf12.tb", "Freq"))
plot.sf12$order <- c(3,5,1,2,6,4)
plot.sf12 <- plot.sf12 %>% arrange(order)
plot.sf12 <- plot.sf12[-c(4)]
colnames(plot.sf12) <- c("Response", "N", "Percentage")

kable(plot.sf12) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
All of the time 6 1.90
Most of the time 24 7.59
A good bit of the time 25 7.91
Some of the time 54 17.09
A little of the time 103 32.59
None of the time 104 32.91

Section 4: Well-being

Thinking about your own life and personal circumstances, how satisfied are you.

a. With your life as a whole?

#pwb_a

pwb_a <- round(prop.table(table(factor(d$pwb_a)))*100,2)

pwb_a <- as.data.frame(pwb_a)
pwb_a$group <- substring(row.names(pwb_a), 1)
pwb_a$group <- revalue(as.character(pwb_a$group), c("1" = "0- Completely dissatisfied", "2" = "1", "3" = "2", "4" = "3", "5" = "4", "6" = "5", "7" = "6", "8" = "7", "9" = "8", "10" = "9", "11" = "10-Completely satisfied"))

#cols <- c((brewer.pal(11,"RdYlGn")))
pwb_a$plot <- factor(pwb_a$group, pwb_a$group)
pwb_a.plot <- ggplot(pwb_a, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values = rev(INTERACTfade)) +
      ylab("Percent of total") +
      xlab("")
      
pwb_a.plot + geom_histogram(aes(x = plot), data = pwb_a, stat = "identity") 

pwb_a.tb <- as.factor(d$pwb_a)
pwb_a.tb <- summary(pwb_a.tb)
pwb_a.tb <- as.data.frame(pwb_a.tb)
pwb_a.tb$Var1 <- substring(row.names(pwb_a.tb), 1)
                           
pwb_a.tb$group <- revalue(as.character(pwb_a.tb$Var1), c("0" = "0- Completely dissatisfied", "10" = "10-Completely satisfied"))

plot.pwb_a <- merge(pwb_a, pwb_a.tb, by = "group")
plot.pwb_a <- plot.pwb_a[-c(2, 4, 6)]
plot.pwb_a <- setcolorder(plot.pwb_a, c("group", "pwb_a.tb", "Freq"))
plot.pwb_a$order <- c(1, 2, 11, 3, 4, 5, 6, 7, 8, 9, 10)
plot.pwb_a <- plot.pwb_a %>% arrange(order)
plot.pwb_a <- plot.pwb_a[-c(4)]
colnames(plot.pwb_a) <- c("Response", "N", "Percentage")

kable(plot.pwb_a) %>%   kable_styling(bootstrap_options = "striped", full_width = T, position = "left")
Response N Percentage
0- Completely dissatisfied 1 0.32
1 2 0.63
2 3 0.95
3 14 4.43
4 15 4.75
5 19 6.01
6 45 14.24
7 78 24.68
8 77 24.37
9 41 12.97
10-Completely satisfied 21 6.65

b. With your standard of living?

#pwb_b

pwb_b <- round(prop.table(table(factor(d$pwb_b)))*100,2)

pwb_b <- as.data.frame(pwb_b)
pwb_b$group <- substring(row.names(pwb_b), 1)
pwb_b$group <- revalue(as.character(pwb_b$group), c("1" = "0- Completely dissatisfied", "2" = "1", "3" = "2", "4" = "3", "5" = "4", "6" = "5", "7" = "6", "8" = "7", "9" = "8", "10" = "9", "11" = "10-Completely satisfied"))

#cols <- c((brewer.pal(11,"RdYlGn")))
pwb_b$plot <- factor(pwb_b$group, pwb_b$group)
pwb_b.plot <- ggplot(pwb_b, aes(x = group, y = Freq, fill = plot)) + theme(axis.text.x  = element_text(size= 12, angle=0, vjust=.6))  + scale_x_discrete(labels = function(plot) str_wrap(plot, width = 10)) +
      guides(fill = FALSE) +
      scale_fill_manual(values = rev(INTERACTfade)) +
      ylab("Percent of total") +
      xlab("")
      
pwb_b.plot + geom_histogram(aes(x = plot), data = pwb_b, stat = "identity")