STAT 20 Lecture 12: stats 20 9-14-18

104 views2 pages
Verified Note
School
Department
Course
In R
Using lecture code and family date
Download and then select the “datasets” and “dplyr” packages to use funcitons
family=read.csv("~/Desktop/family.csv")
From last lectur:
# get all data on everyone not overweight
filter(family, !overWt)
# sort by age
arrange(family,age)
# select the ages of everyone not overweight
select(filter(family, !overWt), age)
# select weights of everyone female
select(filter(family, gender =="f"), weight)
# select gender of everyone over 50 and under 70 inches
select(filter(family, age > 50 & height < 70), gender)
New:
# Tallest member of the family
slice(family, which.max(height))
# every other person in the family
# first what does seq() do?
seq(from = 1, to = 10, by = 2)
seq(from = 1, to = 10, length = 3)
# now get every other person
slice(family, seq(from = 1, to = nrow(family), by = 2))
# add new vector of last names
family = mutate(family,
lastName = "Smith")
# compare bmi for different genders
mf_group = group_by(family, gender)
summarise(mf_group, avg_wt = mean(weight),
tallest = max(height))
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Download and then select the datasets and dplyr packages to use funcitons family=read. csv("~/desktop/family. csv") # get all data on everyone not overweight filter(family, !overwt) # select the ages of everyone not overweight select(filter(family, !overwt), age) # select weights of everyone female select(filter(family, gender =="f"), weight) # select gender of everyone over 50 and under 70 inches select(filter(family, age > 50 & height < 70), gender) # tallest member of the family slice(family, which. max(height)) # first what does seq() do? seq(from = 1, to = 10, by = 2) seq(from = 1, to = 10, length = 3) # now get every other person slice(family, seq(from = 1, to = nrow(family), by = 2)) # add new vector of last names family = mutate(family, lastname = "smith") # compare bmi for different genders mf_group = group_by(family, gender) summarise(mf_group, avg_wt = mean(weight), tallest = max(height)) Center and spread- mean (average) = sum of values/# of values.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related textbook solutions