question archive Create a data frame using the mpg

Create a data frame using the mpg

Subject:Computer SciencePrice:9.82 Bought3

Create a data frame using the mpg.csv file 0 Modify the data frame to drop name, displacement, horsepower, weight, and origin 0 Display the new data frame 0 Display a series of the mean acceleration by model year 0 Display a data frame grouped by year and sub-grouped by cylinders that shows the standard deviation for mpg and acceleration for any model from the 80's 0 Display a series of the standard deviation for mpg and acceleration for any 4cylinder vehicle from the year 81.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Create a data frame using the mpg.csv file

Modify the data frame to drop name, displacement, horsepower, weight, and origin

Install Python  in your  windows  machine  then  install  R Open R  console  then  read  the  mpg.csv  dataset  using the following command.

mydata <- read.csv("C:/Users/Station/Desktop/mpg.csv", header = TRUE)
print(mydata)

The   following  command  will  drop  displacement, horsepower, weight and origin

df = subset(mydata, select = -c(horsepower,displacement,weight,origin) )

Will   display  new data frame

print(df)

Display a series of the mean acceleration by model year, we  use the following  command

Display a data frame grouped by year and sub-grouped by cylinders that shows the
standard deviation for mpg and acceleration for any model from the 80's

Display a data frame grouped by year and sub-grouped by cylinders that shows the standard deviation for mpg and acceleration for any model from the 80's

You  need  to   first  install  and  load  qwraps2  library in your  windows machine.

then  run the  following program to display  the groups , subgroups and  standard  deviation.


mydata <- read.csv("C:/Users/Station/Desktop/mpg.csv", header = TRUE)
str(mydata)

.The names are important, as they are used to label row groups and row names in the table.

our_summary1 <-
  list("Miles Per Gallon" =
       list("min"       = ~ min(mpg),
            "max"       = ~ max(mpg),
            "mean (sd)" = ~ qwraps2::mean_sd(mpg)),
       "Displacement" =
       list("min"       = ~ min(disp),
            "median"    = ~ median(disp),
            "max"       = ~ max(disp),
            "mean (sd)" = ~ qwraps2::mean_sd(disp)),
       "Weight (1000 lbs)" =
       list("min"       = ~ min(wt),
            "max"       = ~ max(wt),
            "mean (sd)" = ~ qwraps2::mean_sd(wt)),
       "Forward Gears" =
       list("Three" = ~ qwraps2::n_perc0(gear == 3),
            "Four"  = ~ qwraps2::n_perc0(gear == 4),
            "Five"  = ~ qwraps2::n_perc0(gear == 5))
       )

By  the number  of Cylinders it will be

by_cyl <- summary_table(dplyr::group_by(mtcars2, cyl_factor), our_summary1)
by_cyl

Related Questions