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,12 +337,6 @@ 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
-
346
340
# ╔═╡ 4cb280c9-0f4b-4173-8858-6c1253496d6a
347
341
md"""
348
342
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.
@@ -358,25 +352,15 @@ We will add a `@count(num_meds)` at the end of the chain to confirm that the `mi
358
352
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`.
359
353
"""
360
354
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
-
368
355
# ╔═╡ f62652d2-43f9-4728-8ff1-856bc26a530e
369
356
md"""
370
357
The 348 `missing` values are now zeros, so let's recalculate the average.
371
358
"""
372
359
373
-
# ╔═╡ 6f1d3c1f-6c77-4474-a69f-bb663c27b6cc
360
+
# ╔═╡ 597f559a-abd5-4ceb-b23f-1e32b7e5e78b
374
361
@chainbegin
375
362
@left_join(patients_clean, meds_clean_count)
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))
363
+
@count(num_meds)
380
364
end
381
365
382
366
# ╔═╡ 773fba31-b9ad-4db6-a70b-55fc7dd18372
@@ -447,6 +431,22 @@ If you've been carefully looking through the code, following along, and everythi
447
431
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