Publications by Dimple K. Patel
HarvardX: PH125.1x
Section 9.9 1. Now we are going to use the geom_histogram function to make a histogram of the heights in the height data frame. When reading the documentation for this function we see that it requires just one mapping, the values to be used for the histogram. Make a histogram of all the plots. What is the variable containing the heights? C. He...
2002 sym R (26662 sym/10 pcs) 6 img
HarvardX: PH125.1x
Section 9.7 1. Define variables containing the heights of males and females like this: How many measurements do we have for each? 238 measurements, female; 812 measurements, male. library(dslabs) data(heights) male <- heights$height[heights$sex == "Male"] female <- heights$height[heights$sex == "Female"] 2. Suppose we can’t make a plot and w...
1254 sym R (729 sym/5 pcs) 1 img
HarvardX: PH125.1x
Section 8.15 library(dplyr) ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union library(ggplot2) library(dslabs) data(heights) data(murders) 1. With ggplot2 plots can be sav...
2875 sym R (1286 sym/22 pcs) 9 img
HarvardX: PH125.1x
Section 6.5 library(dplyr) ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union library(dslabs) library(NHANES) library(data.table) ## ## Attaching package: 'data.table' ## Th...
1013 sym R (1812 sym/15 pcs)
HarvardX: PH125.1x
Section 6.2 Load the data.table package and the murders dataset and convert it to data.table object: library(data.table) library(dslabs) data("murders") murders<-setDT(murders) murders[, population_in_millions := population / 10^6] murders[, rate := total/ population*100000] head(murders) ## state abb region population total po...
1739 sym R (7664 sym/23 pcs)
HarvardX: PH125.1x
Section 5.9 Pick a measurement you can take on a regular basis. For example, your daily weight or how long it takes you to run 5 miles. Keep a spreadsheet that includes the date, the hour, the measurement, and any other informative variable you think is worth keeping. Do this for 2 weeks. Then make a plot library(readr) library(dplyr) ## #...
338 sym R (1982 sym/21 pcs) 1 img
HarvardX: PH125.1x
Section 5.3 1. Use the read_csv function to read each of the files that the following code saves in the files object: library(readr) path<-system.file("extdata", package="dslabs") files<-list.files(path) files ## [1] "2010_bigfive_regents.xls" ## [2] "carbon_emissions.csv" ...
770 sym R (8481 sym/31 pcs)
HarvardX: PH125.1x
Section 4.15 1. Load the murders dataset. Which of the following is true? library(dplyr) ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union library(dslabs) murders ## ...
839 sym R (5373 sym/18 pcs)
HarvardX: PH125.1x
Section 4.6 1. The pipe |> can be used to perform operations sequentially without having to define intermediate objects. Start by redefining murder to include rate and rank. In the solution to the previous exercise, we did the following. Notice that select no longer has a data frame as the first argument. The first argument is assumed to be the...
1058 sym R (4919 sym/8 pcs)
HarvardX: PH125.1x
Section 4.4 Load the dplyr package and the murders dataset. Use the function mutate to add a murders column named rate with the per 100,000 murder rate as in the example code above. Make sure you redefine murders as done in the example code above ( murders <- [your code]) so we can keep using this variable. library(dplyr) ## ## Attaching pac...
2537 sym R (15328 sym/26 pcs)