Question

In: Statistics and Probability

In R dataframes How to select :1/ a/--all columns for 6 cylinder cars with horsepower >=to...

In R dataframes How to select :1/

a/--all columns for 6 cylinder cars with horsepower >=to 100

b/-only columns mpg,cyl,disp and hp for cars with weight >=3000lbs

Solutions

Expert Solution

Install dplyr package and then use filter function to give condition.

Select function to extract the required columns

There is an inbuilt data frame in R mtcars.,executed the same on mtcars dataframe

Rcode for stepA:

step1 <- filter(dataframe, (cylinder ==8 & horsepower >= 100))

b/-only columns mpg,cyl,disp and hp for cars with weight >=3000lbs

Rcode for stepb:

step2 <- filter(dataframe, (weight>=3000))
Requrdcol <- step2 %>% select(mpg,cyl,disp,hp,wt)

Rscreenshot:

for stepA:

For stepb:


Related Solutions

6 similar cars are entered in a race. The cars all have an equal chance of...
6 similar cars are entered in a race. The cars all have an equal chance of winning and there are no ties. Spectators are invited to complete a single prize ticket with their guesses for which cars will finish in first, second, and third place. The spectators who correctly guess the first, second, and third place finishers will get a small prize. How many different ways can a prize ticket be completed? What is the probability that a spectator will...
Problem 1. (a) The columns of response and factors can be defined in R as follows,...
Problem 1. (a) The columns of response and factors can be defined in R as follows, use these codes to solve the problem. y<-c(2, 3, 10, 12, 8, 4, 11, 8)##response : scores a<-c("Heart","Heart", "Soul", "Soul","Heart","Heart", "Soul", "Soul")##factor A b<-c("D", "D", "D", "D", "R", "R", "R", "R")##factor B (group variable) (b) Find the overall mean, row means, column means, each cell mean for the table given in problem 1.
Please do these questions in the R language 1. Load the cars dataset into R. It...
Please do these questions in the R language 1. Load the cars dataset into R. It is a built-in dataset. 2. Do an str() to determine the number of observations and variables. Enter your answer as a comment. 3. Plot speed on x axis and distance on y axis. 4. Find the correlation between speed and distance. What does the magnitude and sign indicate? Enter your answer as a comment. 5. Build a linear regression model with speed as the...
A long, solid, insulating cylinder of radius R = 6 cm has a uniform charge density...
A long, solid, insulating cylinder of radius R = 6 cm has a uniform charge density of λ = −3 C/m. Find the electric field magnitude everywhere.
In SQL we are working with functions 1. Write a SELECT statement that returns these columns...
In SQL we are working with functions 1. Write a SELECT statement that returns these columns from the Instructors table: a. The AnnualSalary column b. A column named MonthlySalary that is the result of dividing the AnnualSalary column by 12 c. A column named MonthlySalaryRounded that calculates the monthly salary and then uses the ROUND function to round the result to 2 decimal places 2. Write a SELECT statement that returns these columns from the Students table: a. The EnrollmentDate...
Refer to columns 1 and 6 in the table. Incorporate government into the table by assuming...
Refer to columns 1 and 6 in the table. Incorporate government into the table by assuming that it plans to tax and spend $20 billion at each possible level of GDP. Also assume that the tax is a personal tax and that government spending does not induce a shift in the private aggregate expenditures schedule. What is the change in equilibrium GDP caused by the addition of government? (6) Aggregates, Private Open Economy, Billions (5) Net Exports, Billions (4) Imports,...
Air within a piston–cylinder assembly, initially at 15 lbf/ in.2, 510°R, and a volume of 6...
Air within a piston–cylinder assembly, initially at 15 lbf/ in.2, 510°R, and a volume of 6 ft3, is compressed isentropically to a final volume of 1.75 ft3. Assuming the ideal gas model with k = 1.4 for the air, determine the: (a) mass, in lb. (b) final pressure, in lbf/in.2 (c) final temperature, in °R. (d) work, in Btu.
How much horsepower is needed, in a vehicle described below, to travel a distance of 1...
How much horsepower is needed, in a vehicle described below, to travel a distance of 1 statute mile in 35 seconds, from a standing start, with the following information: Air density @ sea level, 59 degrees, no wind = p = .002377 slugs/ft^3 Coefficient of drag (flat plate, NASA) = C(d) = 1.28 Weight = W = 4451 lbs Area = A = 197.5" long x 78.2" wide x (1 ft^2/ 144 in^2) ( Size of vehicle)
1. Select known barriers to telemedicine. (select all that apply) A. It studies how genes can...
1. Select known barriers to telemedicine. (select all that apply) A. It studies how genes can be manipulated for better drug effect B. It studies genetic information looking for new targets for drugs C. It studies how genetic information determines drug allergies D. It studies how drugs affect genetic material 2.What tests/algorithms are shared between statistics and machine learning? A. Bayes, decision trees, neural networks B. Linear regression, logistic regression, neural networks C. Bayes, linear regression, logistic regression D. Linear...
How is coupling of transcription and translation possible in bacteria? Select all that apply. Select all...
How is coupling of transcription and translation possible in bacteria? Select all that apply. Select all that apply. as soon as an mRNA is transcribed, ribosomal subunits have physical access to it there are membranes separating the chromosome from ribosomes bacterial transcripts do not contain introns the primary transcript without the complete open reading frame bacterial ribosomes cannot translate the mRNA without pre-mRNA splicing
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT