-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 22.9 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
AteDietFoodsOrProducts_TLW = whd080f,
LiquidDiet_TLW = whd080g,
WeightLossProgram_TLW = whd080h,
PrescriptionDietPills_TLW = whd080i,
NonprescriptionPills_TLW = whd080j,
TookLaxativesOrVomited_TLW = whd080k,
DrankLotsOfWater_TLW = whd080m,
SpecialDiet_TLW = whd080n,
AteFewerCarbs_TLW = whd080o,
Smoked_TLW = whd080p,
AteMoreFruitsVegsSalads_TLW = whd080q,
ChangedEatingHabits_TLW = whd080r,
AteLessSweets_TLW = whd080s,
AteLessJunkfood_TLW = whd080t,
HadWeightLossSurgery_TLW = whd080u,
Other_TLW = whd080l,
TimesLost10PoundsOrMore = whq225,
SelfReportedWeight10YearsAgo = whd110,
SelfReportedWeightAge25 = whd120,
SelfReportedHeightAge25 = whd130,
SelfReportedGreatestWeight = whd140,
AgeWhenHeaviest = whq150,
HaveYouEverHadWeightLossSurgery = whq190,
AgeWhenWeightLossSurgery = whq200
)
colnames(weight_df)
weight_df_a <- weight_df
View(weight_df_a)
colnames(weight_df)
weight_df <- rename(weight_df,
RespondentSequenceNumber = seqn,
CurrentSelfReportedHeight_inches = whd010,
CurrentSelfReportedWeight_pounds = whd020,
HowDoYouConsiderYourWeight = whq030,
HowWouldYouLikeToWeigh = whq040,
SelfReportedWeight1YearAgo = whd050,
WeightChangeIntentional = whq060,
TriedToLoseWeightInPastYear = whq070,
AteLess_TLW = whd080a,
SwitchedFoodToLowerCalories_TLW = whd080b,
AteLessFat_TLW = whd080c,
Exercised_TLW = whd080d,
SkippedMeals_TLW = whd080e,
AteDietFoodsOrProducts_TLW = whd080f,
LiquidDiet_TLW = whd080g,
WeightLossProgram_TLW = whd080h,
PrescriptionDietPills_TLW = whd080i,
NonprescriptionPills_TLW = whd080j,
TookLaxativesOrVomited_TLW = whd080k,
DrankLotsOfWater_TLW = whd080m,
SpecialDiet_TLW = whd080n,
AteFewerCarbs_TLW = whd080o,
Smoked_TLW = whd080p,
AteMoreFruitsVegsSalads_TLW = whd080q,
ChangedEatingHabits_TLW = whd080r,
AteLessSweets_TLW = whd080s,
AteLessJunkfood_TLW = whd080t,
HadWeightLossSurgery_TLW = whd080u,
Other_TLW = whd080l,
TimesLost10PoundsOrMore = whq225,
SelfReportedWeight10YearsAgo = whd110,
SelfReportedWeightAge25 = whd120,
SelfReportedHeightAge25 = whd130,
SelfReportedGreatestWeight = whd140,
AgeWhenHeaviest = whq150,
HaveYouEverHadWeightLossSurgery = whq190,
AgeWhenWeightLossSurgery = whq200
)
# Read the xpt file using the SASxport library
weight_df <- sasxport.get('/Users/jasonkim/QBS 181 Final/WHQ_I.XPT')
# I removed the labels for the columns because they were lengthy and contained a lot of whitespace
weight_df <- remove_labels(weight_df)
head(weight_df)
dim(weight_df)
library(readr)
library(labelled)
library(dplyr)
library(magrittr)
library(ggplot2)
library(scales)
library(gridExtra)
library(SASxport)
library(Hmisc)
library(stringr)
colnames(weight_df)
weight_df <- rename(weight_df,
RespondentSequenceNumber = seqn,
CurrentSelfReportedHeight_inches = whd010,
CurrentSelfReportedWeight_pounds = whd020,
HowDoYouConsiderYourWeight = whq030,
HowWouldYouLikeToWeigh = whq040,
SelfReportedWeight1YearAgo = whd050,
WeightChangeIntentional = whq060,
TriedToLoseWeightInPastYear = whq070,
AteLess_TLW = whd080a,
SwitchedFoodToLowerCalories_TLW = whd080b,
AteLessFat_TLW = whd080c,
Exercised_TLW = whd080d,
SkippedMeals_TLW = whd080e,
AteDietFoodsOrProducts_TLW = whd080f,
LiquidDiet_TLW = whd080g,
WeightLossProgram_TLW = whd080h,
PrescriptionDietPills_TLW = whd080i,
NonprescriptionPills_TLW = whd080j,
TookLaxativesOrVomited_TLW = whd080k,
DrankLotsOfWater_TLW = whd080m,
SpecialDiet_TLW = whd080n,
AteFewerCarbs_TLW = whd080o,
Smoked_TLW = whd080p,
AteMoreFruitsVegsSalads_TLW = whd080q,
ChangedEatingHabits_TLW = whd080r,
AteLessSweets_TLW = whd080s,
AteLessJunkfood_TLW = whd080t,
HadWeightLossSurgery_TLW = whd080u,
Other_TLW = whd080l,
TimesLost10PoundsOrMore = whq225,
SelfReportedWeight10YearsAgo = whd110,
SelfReportedWeightAge25 = whd120,
SelfReportedHeightAge25 = whd130,
SelfReportedGreatestWeight = whd140,
AgeWhenHeaviest = whq150,
HaveYouEverHadWeightLossSurgery = whq190,
AgeWhenWeightLossSurgery = whq200
)
colnames(weight_df)
weight_df_dplyr <- weight_df
knitr::opts_chunk$set(echo = TRUE)
library(readr)
library(labelled)
library(dplyr)
library(magrittr)
library(ggplot2)
library(scales)
library(gridExtra)
library(SASxport)
library(Hmisc)
library(stringr)
# Read the xpt file using the SASxport library
weight_df <- sasxport.get('/Users/jasonkim/QBS 181 Final/WHQ_I.XPT')
# I removed the labels for the columns because they were lengthy and contained a lot of whitespace
weight_df <- remove_labels(weight_df)
head(weight_df)
dim(weight_df)
colnames(weight_df)
weight_df <- rename(weight_df,
RespondentSequenceNumber = seqn,
CurrentSelfReportedHeight_inches = whd010,
CurrentSelfReportedWeight_pounds = whd020,
HowDoYouConsiderYourWeight = whq030,
HowWouldYouLikeToWeigh = whq040,
SelfReportedWeight1YearAgo = whd050,
WeightChangeIntentional = whq060,
TriedToLoseWeightInPastYear = whq070,
AteLess_TLW = whd080a,
SwitchedFoodToLowerCalories_TLW = whd080b,
AteLessFat_TLW = whd080c,
Exercised_TLW = whd080d,
SkippedMeals_TLW = whd080e,
AteDietFoodsOrProducts_TLW = whd080f,
LiquidDiet_TLW = whd080g,
WeightLossProgram_TLW = whd080h,
PrescriptionDietPills_TLW = whd080i,
NonprescriptionPills_TLW = whd080j,
TookLaxativesOrVomited_TLW = whd080k,
DrankLotsOfWater_TLW = whd080m,
SpecialDiet_TLW = whd080n,
AteFewerCarbs_TLW = whd080o,
Smoked_TLW = whd080p,
AteMoreFruitsVegsSalads_TLW = whd080q,
ChangedEatingHabits_TLW = whd080r,
AteLessSweets_TLW = whd080s,
AteLessJunkfood_TLW = whd080t,
HadWeightLossSurgery_TLW = whd080u,
Other_TLW = whd080l,
TimesLost10PoundsOrMore = whq225,
SelfReportedWeight10YearsAgo = whd110,
SelfReportedWeightAge25 = whd120,
SelfReportedHeightAge25 = whd130,
SelfReportedGreatestWeight = whd140,
AgeWhenHeaviest = whq150,
HaveYouEverHadWeightLossSurgery = whq190,
AgeWhenWeightLossSurgery = whq200
)
colnames(weight_df)
weight_df_dplyr <- weight_df
weight_df_dplyr %<>% mutate(CurrentSelfReportedHeight_inches =
case_when(CurrentSelfReportedHeight_inches == 7777 ~ "Refused",
CurrentSelfReportedHeight_inches == 9999 ~ "Don't Know",
TRUE ~ as.numeric(CurrentSelfReportedHeight_inches)))
weight_df_dplyr %<>% mutate(CurrentSelfReportedHeight_inches =
case_when(CurrentSelfReportedHeight_inches == 7777 ~ "Refused",
CurrentSelfReportedHeight_inches == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedHeight_inches)))
View(weight_df_dplyr)
table(weight_df_dplyr$CurrentSelfReportedHeight_inches)
# CurrentSelfReportedHeight_inches
weight_df_dplyr %<>% mutate(CurrentSelfReportedHeight_inches =
case_when(CurrentSelfReportedHeight_inches == 7777 ~ "Refused",
CurrentSelfReportedHeight_inches == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedHeight_inches)))
weight_df_dplyr %<>% mutate(CurrentSelfReportedWeight_pounds =
case_when(CurrentSelfReportedWeight_pounds == 7777 ~ "Refused",
CurrentSelfReportedWeight_pounds == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedWeight_pounds)))
View(weight_df)
View(weight_df_dplyr)
# HowDoYouConsiderYourWeight
weight_df$HowDoYouConsiderYourWeight[weight_df$HowDoYouConsiderYourWeight == 1] <- "Overweight"
weight_df$HowDoYouConsiderYourWeight[weight_df$HowDoYouConsiderYourWeight == 2] <- "Underweight"
weight_df$HowDoYouConsiderYourWeight[weight_df$HowDoYouConsiderYourWeight == 3] <- "About the Right Weight"
weight_df$HowDoYouConsiderYourWeight[weight_df$HowDoYouConsiderYourWeight == 7] <- "Refused"
weight_df$HowDoYouConsiderYourWeight[weight_df$HowDoYouConsiderYourWeight == 9] <- "Don't Know"
# HowWouldYouLikeToWeigh
weight_df$HowWouldYouLikeToWeigh[weight_df$HowWouldYouLikeToWeigh == 1] <- "More"
weight_df$HowWouldYouLikeToWeigh[weight_df$HowWouldYouLikeToWeigh == 2] <- "Less"
weight_df$HowWouldYouLikeToWeigh[weight_df$HowWouldYouLikeToWeigh == 3] <- "Stay About the Same"
weight_df$HowWouldYouLikeToWeigh[weight_df$HowWouldYouLikeToWeigh == 7] <- "Refused"
weight_df$HowWouldYouLikeToWeigh[weight_df$HowWouldYouLikeToWeigh == 9] <- "Don't Know"
# SelfReportedWeight1YearAgo
weight_df$SelfReportedWeight1YearAgo[weight_df$SelfReportedWeight1YearAgo == 7777] <- "Refused"
weight_df$SelfReportedWeight1YearAgo[weight_df$SelfReportedWeight1YearAgo == 9999] <- "Don't Know"
# WeightChangeIntentional
weight_df$WeightChangeIntentional[weight_df$WeightChangeIntentional == 1] <- "Yes"
weight_df$WeightChangeIntentional[weight_df$WeightChangeIntentional == 2] <- "No"
weight_df$WeightChangeIntentional[weight_df$WeightChangeIntentional == 7] <- "Refused"
weight_df$WeightChangeIntentional[weight_df$WeightChangeIntentional == 9] <- "Don't Know"
# TriedToLoseWeightInPastYear
weight_df$TriedToLoseWeightInPastYear[weight_df$TriedToLoseWeightInPastYear == 1] <- "Yes"
weight_df$TriedToLoseWeightInPastYear[weight_df$TriedToLoseWeightInPastYear == 2] <- "No"
weight_df$TriedToLoseWeightInPastYear[weight_df$TriedToLoseWeightInPastYear == 7] <- "Refused"
weight_df$TriedToLoseWeightInPastYear[weight_df$TriedToLoseWeightInPastYear == 9] <- "Don't Know"
# CurrentSelfReportedHeight_inches
weight_df_dplyr %<>% mutate(CurrentSelfReportedHeight_inches =
case_when(CurrentSelfReportedHeight_inches == 7777 ~ "Refused",
CurrentSelfReportedHeight_inches == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedHeight_inches)))
# CurrentSelfReportedWeight_pounds
weight_df_dplyr %<>% mutate(CurrentSelfReportedWeight_pounds =
case_when(CurrentSelfReportedWeight_pounds == 7777 ~ "Refused",
CurrentSelfReportedWeight_pounds == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedWeight_pounds)))
#
weight_df_dplyr %<>% mutate(HowDoYouConsiderYourWeight =
case_when(HowDoYouConsiderYourWeight == 1 ~ "Overweight",
HowDoYouConsiderYourWeight == 2 ~ "Underweight",
HowDoYouConsiderYourWeight == 3 ~ "About the Right Weight",
HowDoYouConsiderYourWeight == 7 ~ "Refused",
HowDoYouConsiderYourWeight == 9 ~ "Don't Know",
TRUE ~ as.character(HowDoYouConsiderYourWeight)))
View(weight_df_dplyr)
# AteLess_TLW
weight_df$AteLess_TLW[weight_df$AteLess_TLW == 10] <- "Ate Less Food"
weight_df$AteLess_TLW[weight_df$AteLess_TLW == 77] <- "Refused"
weight_df$AteLess_TLW[weight_df$AteLess_TLW == 99] <- "Don't Know"
# SwitchedFoodToLowerCalories_TLW
weight_df$SwitchedFoodToLowerCalories_TLW[weight_df$SwitchedFoodToLowerCalories_TLW == 11] <- "Switched to Food with Lower Calories"
# AteLessFat_TLW
weight_df$AteLessFat_TLW[weight_df$AteLessFat_TLW == 12] <- "Ate Less Fat"
# Exercised_TLW
weight_df$Exercised_TLW[weight_df$Exercised_TLW == 13] <- "Exercised"
# SkippedMeals_TLW
weight_df$SkippedMeals_TLW[weight_df$SkippedMeals_TLW == 14] <- "SkippedMeals"
# AteDietFoodsOrProducts_TLW
weight_df$AteDietFoodsOrProducts_TLW[weight_df$AteDietFoodsOrProducts_TLW == 15] <- "Ate Diet Foods or Products"
# LiquidDiet_TLW
weight_df$LiquidDiet_TLW[weight_df$LiquidDiet_TLW == 16] <- "Used a Liquid Diet"
# WeightLossProgram_TLW
weight_df$WeightLossProgram_TLW[weight_df$WeightLossProgram_TLW == 17] <- "Joined a Weight Loss Program"
# PrescriptionDietPills_TLW
weight_df$PrescriptionDietPills_TLW[weight_df$PrescriptionDietPills_TLW == 31] <- "Took Diet Pills Prescribed by a Doctor"
# NonprescriptionPills_TLW
weight_df$NonprescriptionPills_TLW[weight_df$NonprescriptionPills_TLW == 32] <- "Took Diet Pills Not Prescribed by a Doctor"
# TookLaxativesOrVomited_TLW
weight_df$TookLaxativesOrVomited_TLW[weight_df$TookLaxativesOrVomited_TLW == 33] <- "Took Laxatives or Vomited"
# DrankLotsOfWater_TLW
weight_df$DrankLotsOfWater_TLW[weight_df$DrankLotsOfWater_TLW == 34] <- "Drank a lot of Water"
# SpecialDiet_TLW
weight_df$SpecialDiet_TLW[weight_df$SpecialDiet_TLW == 30] <- "Followed a Special Diet"
# AteFewerCarbs_TLW
weight_df$AteFewerCarbs_TLW[weight_df$AteFewerCarbs_TLW == 41] <- "Ate Fewer Carbohydrates"
# Smoked_TLW
weight_df$Smoked_TLW[weight_df$Smoked_TLW == 42] <- "Started to Smoke or Began Again"
# AteMoreFruitsVegsSalads_TLW
weight_df$AteMoreFruitsVegsSalads_TLW[weight_df$AteMoreFruitsVegsSalads_TLW == 43] <- "Ate More Fruits, Vegetables, Salads"
# ChangedEatingHabits_TLW
weight_df$ChangedEatingHabits_TLW[weight_df$ChangedEatingHabits_TLW == 44] <- "Changed Eating Habits"
# AteLessSweets_TLW
weight_df$AteLessSweets_TLW[weight_df$AteLessSweets_TLW == 45] <- "Ate Less Sugar,Candy,Sweets"
# AteLessJunkfood_TLW
weight_df$AteLessJunkfood_TLW[weight_df$AteLessJunkfood_TLW == 46] <- "Ate Less Junkfood or Fastfood"
# HadWeightLossSurgery_TLW
weight_df$HadWeightLossSurgery_TLW[weight_df$HadWeightLossSurgery_TLW == 35] <- "Had Weight Loss Surgery"
# Other_TLW
weight_df$Other_TLW[weight_df$Other_TLW == 40] <- "Other"
# TimesLost10PoundsOrMore
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 1] <- "1 to 2"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 2] <- "3 to 5"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 3] <- "6 to 10"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 4] <- "11 or more"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 5] <- "Never"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 7] <- "Refused"
weight_df$TimesLost10PoundsOrMore[weight_df$TimesLost10PoundsOrMore == 9] <- "Don't Know"
# SelfReportedWeight10YearsAgo
weight_df$SelfReportedWeight10YearsAgo[weight_df$SelfReportedWeight10YearsAgo == 7777] <- "Refused"
weight_df$SelfReportedWeight10YearsAgo[weight_df$SelfReportedWeight10YearsAgo == 9999] <- "Don't Know"
# SelfReportedWeightAge25
weight_df$SelfReportedWeightAge25[weight_df$SelfReportedWeightAge25 == 7777] <- "Refused"
weight_df$SelfReportedWeightAge25[weight_df$SelfReportedWeightAge25 == 9999] <- "Don't Know"
# SelfReportedHeightAge25
weight_df$SelfReportedHeightAge25[weight_df$SelfReportedHeightAge25 == 7777] <- "Refused"
weight_df$SelfReportedHeightAge25[weight_df$SelfReportedHeightAge25 == 9999] <- "Don't Know"
# SelfReportedGreatestWeight
weight_df$SelfReportedGreatestWeight[weight_df$SelfReportedGreatestWeight == 7777] <- "Refused"
weight_df$SelfReportedGreatestWeight[weight_df$SelfReportedGreatestWeight == 9999] <- "Don't Know"
# AgeWhenHeaviest
weight_df$AgeWhenHeaviest[weight_df$AgeWhenHeaviest == 80] <- "80 or older"
weight_df$AgeWhenHeaviest[weight_df$AgeWhenHeaviest == 77777] <- "Refused"
weight_df$AgeWhenHeaviest[weight_df$AgeWhenHeaviest == 99999] <- "Don't Know"
# HaveYouEverHadWeightLossSurgery
weight_df$HaveYouEverHadWeightLossSurgery[weight_df$HaveYouEverHadWeightLossSurgery == 1] <- "Yes"
weight_df$HaveYouEverHadWeightLossSurgery[weight_df$HaveYouEverHadWeightLossSurgery == 2] <- "No"
weight_df$HaveYouEverHadWeightLossSurgery[weight_df$HaveYouEverHadWeightLossSurgery == 7] <- "Refused"
weight_df$HaveYouEverHadWeightLossSurgery[weight_df$HaveYouEverHadWeightLossSurgery == 9] <- "Don't Know"
# AgeWhenWeightLossSurgery
weight_df$AgeWhenWeightLossSurgery[weight_df$AgeWhenWeightLossSurgery == 77777] <- "Refused"
weight_df$AgeWhenWeightLossSurgery[weight_df$AgeWhenWeightLossSurgery == 99999] <- "Don't Know"
weight_df_dplyr %<>% mutate(SwitchedFoodToLowerCalories_TLW =
case_when(SwitchedFoodToLowerCalories_TLW == 11 ~ "Switched to Food with Lower Calories",
TRUE ~ as.character(SwitchedFoodToLowerCalories_TLW)))
weight_df_dplyr %<>% mutate(AteMoreFruitsVegsSalads_TLW =
case_when(AteMoreFruitsVegsSalads_TLW == 43 ~ "Ate More Fruits, Vegetables, Salads",
TRUE ~ as.character(AteMoreFruitsVegsSalads_TLW)))
# CurrentSelfReportedHeight_inches
weight_df_dplyr %<>% mutate(CurrentSelfReportedHeight_inches =
case_when(CurrentSelfReportedHeight_inches == 7777 ~ "Refused",
CurrentSelfReportedHeight_inches == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedHeight_inches)))
# CurrentSelfReportedWeight_pounds
weight_df_dplyr %<>% mutate(CurrentSelfReportedWeight_pounds =
case_when(CurrentSelfReportedWeight_pounds == 7777 ~ "Refused",
CurrentSelfReportedWeight_pounds == 9999 ~ "Don't Know",
TRUE ~ as.character(CurrentSelfReportedWeight_pounds)))
# HowDoYouConsiderYourWeight
weight_df_dplyr %<>% mutate(HowDoYouConsiderYourWeight =
case_when(HowDoYouConsiderYourWeight == 1 ~ "Overweight",
HowDoYouConsiderYourWeight == 2 ~ "Underweight",
HowDoYouConsiderYourWeight == 3 ~ "About the Right Weight",
HowDoYouConsiderYourWeight == 7 ~ "Refused",
HowDoYouConsiderYourWeight == 9 ~ "Don't Know",
TRUE ~ as.character(HowDoYouConsiderYourWeight)))
# HowWouldYouLikeToWeigh
weight_df_dplyr %<>% mutate(HowWouldYouLikeToWeigh =
case_when(HowWouldYouLikeToWeigh == 1 ~ "More",
HowWouldYouLikeToWeigh == 2 ~ "Less",
HowWouldYouLikeToWeigh == 3 ~ "Stay About the Same",
HowWouldYouLikeToWeigh == 7 ~ "Refused",
HowWouldYouLikeToWeigh == 9 ~ "Don't Know",
TRUE ~ as.character(HowWouldYouLikeToWeigh)))
# SelfReportedWeight1YearAgo
weight_df_dplyr %<>% mutate(SelfReportedWeight1YearAgo =
case_when(SelfReportedWeight1YearAgo == 7777 ~ "Refused",
SelfReportedWeight1YearAgo == 9999 ~ "Don't Know",
TRUE ~ as.character(SelfReportedWeight1YearAgo)))
# WeightChangeIntentional
weight_df_dplyr %<>% mutate(WeightChangeIntentional =
case_when(WeightChangeIntentional == 1 ~ "Yes",
WeightChangeIntentional == 2 ~ "No",
WeightChangeIntentional == 7 ~ "Refused",
WeightChangeIntentional == 9 ~ "Don't Know",
TRUE ~ as.character(WeightChangeIntentional)))
# TriedToLoseWeightInPastYear
weight_df_dplyr %<>% mutate(TriedToLoseWeightInPastYear =
case_when(TriedToLoseWeightInPastYear == 1 ~ "Yes",
TriedToLoseWeightInPastYear == 2 ~ "No",
TriedToLoseWeightInPastYear == 7 ~ "Refused",
TriedToLoseWeightInPastYear == 9 ~ "Don't Know",
TRUE ~ as.character(TriedToLoseWeightInPastYear)))
# AteLess_TLW
weight_df_dplyr %<>% mutate(AteLess_TLW =
case_when(AteLess_TLW == 10 ~ "Ate Less Food",
AteLess_TLW == 77 ~ "Refused",
AteLess_TLW == 99 ~ "Don't Know",
TRUE ~ as.character(AteLess_TLW)))
# SwitchedFoodToLowerCalories_TLW
weight_df_dplyr %<>% mutate(SwitchedFoodToLowerCalories_TLW =
case_when(SwitchedFoodToLowerCalories_TLW == 11 ~ "Switched to Food with Lower Calories",
TRUE ~ as.character(SwitchedFoodToLowerCalories_TLW)))
# AteLessFat_TLW
weight_df_dplyr %<>% mutate(AteLessFat_TLW =
case_when(AteLessFat_TLW == 12 ~ "Ate Less Fat",
TRUE ~ as.character(AteLessFat_TLW)))
# Exercised_TLW
weight_df_dplyr %<>% mutate(Exercised_TLW =
case_when(Exercised_TLW == 13 ~ "Exercised",
TRUE ~ as.character(Exercised_TLW)))
# SkippedMeals_TLW
weight_df_dplyr %<>% mutate(SkippedMeals_TLW =
case_when(SkippedMeals_TLW == 14 ~ "SkippedMeals",
TRUE ~ as.character(SkippedMeals_TLW)))
# AteDietFoodsOrProducts_TLW
weight_df_dplyr %<>% mutate(AteDietFoodsOrProducts_TLW =
case_when(AteDietFoodsOrProducts_TLW == 15 ~ "Ate Diet Foods or Products",
TRUE ~ as.character(AteDietFoodsOrProducts_TLW)))
# LiquidDiet_TLW
weight_df_dplyr %<>% mutate(LiquidDiet_TLW =
case_when(LiquidDiet_TLW == 16 ~ "Used a Liquid Diet",
TRUE ~ as.character(LiquidDiet_TLW)))
# WeightLossProgram_TLW
weight_df_dplyr %<>% mutate(WeightLossProgram_TLW =
case_when(WeightLossProgram_TLW == 17 ~ "Joined a Weight Loss Program",
TRUE ~ as.character(WeightLossProgram_TLW)))
# PrescriptionDietPills_TLW
weight_df_dplyr %<>% mutate(PrescriptionDietPills_TLW =
case_when(PrescriptionDietPills_TLW == 31 ~ "Took Diet Pills Prescribed by a Doctor",
TRUE ~ as.character(PrescriptionDietPills_TLW)))
# NonprescriptionPills_TLW
weight_df_dplyr %<>% mutate(NonprescriptionPills_TLW =
case_when(NonprescriptionPills_TLW == 32 ~ "Took Diet Pills Not Prescribed by a Doctor",
TRUE ~ as.character(NonprescriptionPills_TLW)))
# TookLaxativesOrVomited_TLW
weight_df_dplyr %<>% mutate(TookLaxativesOrVomited_TLW =
case_when(TookLaxativesOrVomited_TLW == 33 ~ "Took Laxatives or Vomited",
TRUE ~ as.character(TookLaxativesOrVomited_TLW)))
# DrankLotsOfWater_TLW
weight_df_dplyr %<>% mutate(DrankLotsOfWater_TLW =
case_when(DrankLotsOfWater_TLW == 34 ~ "Drank a lot of Water",
TRUE ~ as.character(DrankLotsOfWater_TLW)))
# SpecialDiet_TLW
weight_df_dplyr %<>% mutate(SpecialDiet_TLW =
case_when(SpecialDiet_TLW == 30 ~ "Followed a Special Diet",
TRUE ~ as.character(SpecialDiet_TLW)))
# AteFewerCarbs_TLW
weight_df_dplyr %<>% mutate(AteFewerCarbs_TLW =
case_when(AteFewerCarbs_TLW == 41 ~ "Ate Fewer Carbohydrates",
TRUE ~ as.character(AteFewerCarbs_TLW)))
# Smoked_TLW
weight_df_dplyr %<>% mutate(Smoked_TLW =
case_when(Smoked_TLW == 42 ~ "Started to Smoke or Began Again",
TRUE ~ as.character(Smoked_TLW)))
# AteMoreFruitsVegsSalads_TLW
weight_df_dplyr %<>% mutate(AteMoreFruitsVegsSalads_TLW =
case_when(AteMoreFruitsVegsSalads_TLW == 43 ~ "Ate More Fruits, Vegetables, Salads",
TRUE ~ as.character(AteMoreFruitsVegsSalads_TLW)))
# ChangedEatingHabits_TLW
weight_df_dplyr %<>% mutate(ChangedEatingHabits_TLW =
case_when(ChangedEatingHabits_TLW == 44 ~ "Changed Eating Habits",
TRUE ~ as.character(ChangedEatingHabits_TLW)))
# AteLessSweets_TLW
weight_df_dplyr %<>% mutate(AteLessSweets_TLW =
case_when(AteLessSweets_TLW == 45 ~ "Ate Less Sugar,Candy,Sweets",
TRUE ~ as.character(AteLessSweets_TLW)))
# AteLessJunkfood_TLW
weight_df_dplyr %<>% mutate(AteLessJunkfood_TLW =
case_when(AteLessJunkfood_TLW == 46 ~ "Ate Less Junkfood or Fastfood",
TRUE ~ as.character(AteLessJunkfood_TLW)))
# HadWeightLossSurgery_TLW
weight_df_dplyr %<>% mutate(HadWeightLossSurgery_TLW =
case_when(HadWeightLossSurgery_TLW == 35 ~ "Had Weight Loss Surgery",
TRUE ~ as.character(HadWeightLossSurgery_TLW)))
# Other_TLW
weight_df_dplyr %<>% mutate(Other_TLW =
case_when(Other_TLW == 40 ~ "Other",
TRUE ~ as.character(Other_TLW)))
# TimesLost10PoundsOrMore
weight_df_dplyr %<>% mutate(TimesLost10PoundsOrMore =
case_when(TimesLost10PoundsOrMore == 1 ~ "1 to 2",
TimesLost10PoundsOrMore == 2 ~ "3 to 5",
TimesLost10PoundsOrMore == 3 ~ "6 to 10",
TimesLost10PoundsOrMore == 4 ~ "11 or more",
TimesLost10PoundsOrMore == 5 ~ "Never",
TimesLost10PoundsOrMore == 7 ~ "Refused",
TimesLost10PoundsOrMore == 9 ~ "Don't Know",
TRUE ~ as.character(TimesLost10PoundsOrMore)))
# SelfReportedWeight10YearsAgo
weight_df_dplyr %<>% mutate(SelfReportedWeight10YearsAgo =
case_when(SelfReportedWeight10YearsAgo == 7777 ~ "Refused",
SelfReportedWeight10YearsAgo == 9999 ~ "Don't Know",
TRUE ~ as.character(SelfReportedWeight10YearsAgo)))
# SelfReportedWeightAge25
weight_df_dplyr %<>% mutate(SelfReportedWeightAge25 =
case_when(SelfReportedWeightAge25 == 7777 ~ "Refused",
SelfReportedWeightAge25 == 9999 ~ "Don't Know",
TRUE ~ as.character(SelfReportedWeightAge25)))
# SelfReportedHeightAge25
weight_df_dplyr %<>% mutate(SelfReportedHeightAge25 =
case_when(SelfReportedHeightAge25 == 7777 ~ "Refused",
SelfReportedHeightAge25 == 9999 ~ "Don't Know",
TRUE ~ as.character(SelfReportedHeightAge25)))
# SelfReportedGreatestWeight
weight_df_dplyr %<>% mutate(SelfReportedGreatestWeight =
case_when(SelfReportedGreatestWeight == 7777 ~ "Refused",
SelfReportedGreatestWeight == 9999 ~ "Don't Know",
TRUE ~ as.character(SelfReportedGreatestWeight)))
# AgeWhenHeaviest
weight_df_dplyr %<>% mutate(AgeWhenHeaviest =
case_when(AgeWhenHeaviest == 80 ~ "80 or older",
AgeWhenHeaviest == 7777 ~ "Refused",
AgeWhenHeaviest == 9999 ~ "Don't Know",
TRUE ~ as.character(AgeWhenHeaviest)))
# HaveYouEverHadWeightLossSurgery
weight_df_dplyr %<>% mutate(HaveYouEverHadWeightLossSurgery =
case_when(HaveYouEverHadWeightLossSurgery == 1 ~ "Yes",
HaveYouEverHadWeightLossSurgery == 2 ~ "No",
HaveYouEverHadWeightLossSurgery == 7 ~ "Refused",
HaveYouEverHadWeightLossSurgery == 9 ~ "Don't Know",
TRUE ~ as.character(HaveYouEverHadWeightLossSurgery)))
# AgeWhenWeightLossSurgery
weight_df_dplyr %<>% mutate(AgeWhenWeightLossSurgery =
case_when(AgeWhenWeightLossSurgery == 77777 ~ "Refused",
AgeWhenWeightLossSurgery == 99999 ~ "Don't Know",
TRUE ~ as.character(AgeWhenWeightLossSurgery)))
View(weight_df_dplyr)