Question: # ( G Q 3 b # Use the sum ( ) and is . na ( ) functions to count the number of missing

# (G Q3b # Use the sum() and
is.na() functions to count the number of missing values in the
points column.
sum(
is.na(wine$points))
# (G Q3C # Use the sum() and
is.na() functions to count the number of missing values in the
price column.
sum(
is.na(wine$price))
# (G Q3d # Use the sum() and
is.na() functions to count the number of observations that have a price.
###### Hint: Since the ! means "not", putting an ! in front of
is.na() counts the non-missing values.
sum(!
is.na(wine$price))
# (G Q4a # Use the mean() function to calculate the average points for the wines in the dataset.
mean(wine$points)
# CG Q4b # Use the mean() function to calculate the average price for the wines in the dataset. mean (wine$price, na.rm=T)
# (G Q5a # Use the mean() function to calculate the querage points for the Napa Sonoma subregion.
###### Your code should be a single line and will use the square brackets for subsetting.. mean(wine$points [wine$region=="Napa-Sonoma"])
# (G Q5b # Use the mean() function to calculate the average price for the Napa Sonoma subregionusing a single line of code.
mean(wine$price[wine$region=="Napa-Sonoma"])
# CG Q6 # Now we'll practice our counting skills again.
##### The rating scale being used by these tasters orignally had 91 as the highest possible score
##### and now goes to 100 for exceedingly delicious wines.
##### Use the sum() function on a logical vector that checks for whether points are greater than 91 or not
##### to count the number of wine ratings with more than 91 points.
sum(wine$points>91)
# CG Q7a # Now we'll practice subsetting on more than one criteria.
###### Use the mean() function to compute the average points for wines
###### that are chardonnay and from the Napa Sonoma sub-region.
mean(wine$points [wine$Sonoma&wine$variety="chardonnay"], na.rm=T)
# CG Q7b # More practice subsetting on more than one criteria.
###### Use the mean() function to compute the average price for wines that are ###### either chardonnay or are from the finger lakes sub-region. mean()
# CG Q8 # Use the median() function to find the median price for
##### a Cabernet Sauvignon that is rated higher than 91 points.
 # (G Q3b # Use the sum() and is.na() functions to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!