You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: what-is-tidier-jl.jl
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -337,6 +337,12 @@ No. The `meds_clean` data frame only captures patients who are taking at least o
337
337
To evaluate this, let's join the `patients_clean` data frame with `meds_clean_count` and examine the `num_meds` column. If all patients in the `patients_clean` data frame are also represented in the `meds_clean_count` data frame, then there should be no missing values for `num_meds`.
338
338
"""
339
339
340
+
# ╔═╡ 597f559a-abd5-4ceb-b23f-1e32b7e5e78b
341
+
@chainbegin
342
+
@left_join(patients_clean, meds_clean_count)
343
+
@count(num_meds)
344
+
end
345
+
340
346
# ╔═╡ 4cb280c9-0f4b-4173-8858-6c1253496d6a
341
347
md"""
342
348
While most patients in this dataset are taking at least one medication, `348` patients have a `missing` value for `num_meds` after joining the two datasets, which means that they are not on medications.
@@ -352,15 +358,25 @@ We will add a `@count(num_meds)` at the end of the chain to confirm that the `mi
352
358
In previous code, we have always started a chain with the syntax `@chain df begin`, where `df` represents a data frame. You can alternatively begin a chain with `@chain begin`, which is especially handy when the initial value is lengthy to type, such as when starting a chain with a `@left_join`.
353
359
"""
354
360
361
+
# ╔═╡ 6ea5a632-0c97-4a8d-90ea-7add7dc99304
362
+
@chainbegin
363
+
@left_join(patients_clean, meds_clean_count)
364
+
@mutate(num_meds =replace_missing(num_meds, 0))
365
+
@count(num_meds)
366
+
end
367
+
355
368
# ╔═╡ f62652d2-43f9-4728-8ff1-856bc26a530e
356
369
md"""
357
370
The 348 `missing` values are now zeros, so let's recalculate the average.
358
371
"""
359
372
360
-
# ╔═╡ 597f559a-abd5-4ceb-b23f-1e32b7e5e78b
373
+
# ╔═╡ 6f1d3c1f-6c77-4474-a69f-bb663c27b6cc
361
374
@chainbegin
362
375
@left_join(patients_clean, meds_clean_count)
363
-
@count(num_meds)
376
+
@mutate(num_meds =replace_missing(num_meds, 0))
377
+
@summarize(mean_num_meds =mean(num_meds),
378
+
min_num_meds =minimum(num_meds),
379
+
max_num_meds =maximum(num_meds))
364
380
end
365
381
366
382
# ╔═╡ 773fba31-b9ad-4db6-a70b-55fc7dd18372
@@ -431,22 +447,6 @@ If you've been carefully looking through the code, following along, and everythi
431
447
The next section on reading data will cover the details, starting with how to read in a data frame from a file.
0 commit comments