Question

In: Computer Science

Using R Studio: 1)Use the `mtcars` data (`data(mtcars)`) to answer these questions: a) Which rows of...

Using R Studio:


1)Use the `mtcars` data (`data(mtcars)`) to answer these questions:  
a) Which rows of the data frame contain cars that weigh more than 4000 pounds (the variable is `wt`, units are 1000 pounds).
b) Which cars are these? (*Hint:* since rows are named by car name, use `row.names()`).
c) What is the mean displacement (in inches^3^ ) for cars with at least 200 horsepower (`hp`).
d) Which car has the highest fuel economy (`mpg`)?
e) What was the fuel economy for the Honda Civic?

2) Using the `mtcars` data create a new variable for horespower per unit weight (`hp/wt`). Is this a better predictor of acceleration (`qsec`; seconds to complete a quarter mile) than horsepower alone?

3) Use the function `subset()` to return the cars with 4 cyclinders and automatic transmissions (`am` = `0`). (*Hint:* see `?subset`).

Solutions

Expert Solution

Question 1)

Below is the R code for the given problem. Please follow comments-

R Code-

# Question 1
# a)
# filtering cars with wt more than 4
filter(mtcars, wt > 4.0)

# b)
# List of cars with wt more than 4
mtcars[ which(mtcars$wt>4 ), ]

# c)
# Finding mean disp of cars with hp greater than 200
mtcars %>%
filter(hp > 200) %>%
summarise(mean = mean(disp))

# d)
# Using max function to find cars with maximum mpg
mtcars[ which(mtcars$mpg== max(mtcars$mpg)),]
# e)
# Fuel economy of honda civic
mtcars[grep('^Honda', rownames(mtcars)),]

Code screenshot-

Output-


Related Solutions

using the mtcars data set data(mtcars) USE data in mtcars library in R 5.Use k means...
using the mtcars data set data(mtcars) USE data in mtcars library in R 5.Use k means cluster analysis. 6. Get cluster means. 7. Visualize the clustering result.
please use R studio to answer the following questions 1. An eductional theorist collects behavioural data...
please use R studio to answer the following questions 1. An eductional theorist collects behavioural data from two groups of children in an early childhood center. She measures how much time the children are active (e.g. running or swinging on the monkey bars) in minutes. The first group of children are encouraged to run about and as such are expected to be active; the second group is encouraged to sit still and paint, and are expected to be less active....
Use R studio to answer the following questions location 1 location 2 63.9 66.8 71.3 63.8...
Use R studio to answer the following questions location 1 location 2 63.9 66.8 71.3 63.8 70.6 60.7 54.6 66.2 63.7 59.5 61 59.5 69.8 66.1 72.4 64.6 64.4 64.8 69.8 61.6 65.6 61.3 62.8 64.9 63.6 66.2 Temperatures are extremely variable in sections of the Colorado River near the Glen Canyon Dam.  Researchers measure temperature in two locations (1 and 2) with samples of size n1 = 10 and n2 = 16, and calculate variances of s12 = 20 °C...
Using R-Studio please answer the following questions and show your code. 1. Julie buys a take-out...
Using R-Studio please answer the following questions and show your code. 1. Julie buys a take-out coffee from one of two coffee shops on a random basis: Ultimo Coffee and Joe’s Place. This month, she measured the temperature of each cup immediately after purchase, using a cooking thermometer. Sample data is shown below, temperatures are in Fahrenheit. ultimo =  c(171,161,169,179, 171,166,169,178,171, 165,172,172) joes = c(168,165,172, 151,162,158,157,160, 158,160,158,164) State the null and alternative hypothesis in your own words. What type of statistical...
Using R studio 1. Read the iris data set into a data frame. 2. Print the...
Using R studio 1. Read the iris data set into a data frame. 2. Print the first few lines of the iris dataset. 3. Output all the entries with Sepal Length > 5. 4. Plot a box plot of Petal Length with a color of your choice. 5. Plot a histogram of Sepal Width. 6. Plot a scatter plot showing the relationship between Petal Length and Petal Width. 7. Find the mean of Sepal Length by species. Hint: You could...
Examine classification using logistic regression. In R console, type mtcars. The dataset mtcars is a generic...
Examine classification using logistic regression. In R console, type mtcars. The dataset mtcars is a generic dataset in R. This dataset comprises of fuel consumption and 10 aspects of automobile design and performance for 32 automobiles. Using only the variables am (0 = automatic, 1 = manual) and mpg, your task is to fit a logistic regression model. Complete the following steps using R. Create a scatter plot of am vs. mpg. Describe the relationship and explain why a simple...
Using the mtcars dataset, answer the following questions: Fill in the following table: Variable Correlation with...
Using the mtcars dataset, answer the following questions: Fill in the following table: Variable Correlation with mpg cyl -0.85216 disp -0.84755 hp -0.77617 drat 0.681172 wt -0.86766 qsec 0.418684 vs 0.664039 am 0.599832 gear 0.480285 carb -0.55093 mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21 6 160 110 3.9 2.62 16.46 0 1 4 4 Mazda RX4 Wag 21 6 160 110 3.9 2.875 17.02 0 1 4 4 Datsun 710 22.8 4 108...
Answer using R Studio Here we consider the amount of data needed to perform hypothesis testing....
Answer using R Studio Here we consider the amount of data needed to perform hypothesis testing. Suppose we are testing a coin using observations of tosses. We wish to test H0: p = 0.5 against an alternative of HA : p = 0.6 (in this question use one-sided tests only). How many tosses are needed to guarantee a size Æ∑ 0.05 and Ø∑ 0.2? Now generalize to consider HA : p = 0.5+delta. Choose sensible values for delta and quantify...
r studio answer to these questions What is the intercept parameter (2dp) for the regression equation...
r studio answer to these questions What is the intercept parameter (2dp) for the regression equation of height (y) versus age (x) using the pine_growth.csv data? What is the total amount of variation explained by the regression model (SSr) of height (y) versus age (x) using the pine_growth.csv data? What is the residual error sum of squares (SSe) of a regression model of height (y) versus age (x) using the pine_growth.csv data. Use your regression equation fitted to the pine_growth.csv...
Can You please Answer the question using R studio and R cloud Telomeres are complexes of...
Can You please Answer the question using R studio and R cloud Telomeres are complexes of DNA and protein that cap chromosomal ends. They consist of the same short DNA sequence TTAGGG repeated over and over again. They tend to shorted with cell divisions and with advancing cellular age, which will lead to chromosome instability or apoptosis (programmed cell death). Eukaryotic cells have the ability to reverse telomere shortening by expressing telomerase, an enzyme that extends the telomeres of chromosomes....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT