Question

Using Rstudio please provide your code as well as a screenshot of your code ## File:...

Using Rstudio
please provide your code as well as a screenshot of your code

## File: lab5
## Author: A. Breitzman
## Description: Manipulating and summarizing a data set
## ------------------------------------------------------------------------

## Instructions: This worksheet is worth 5 points
## Exercises are worth 2.5 point each. If you cannot get the code to work in the line limits specified, the maximum that you can earn per exercise would be 1.5 points.

## First we need to load a library
library(MASS)

## If you got an error you may need to uncomment the next 2 lines
#install.packages("MASS")
#library(MASS)

dim(Cars93)
## 93 rows and 27 columns
## if you got an error message instead of 93 27 then go back to line 11 and reread it.
## Don't go any further until you get a 93 27 for line 15

##We can get the names of each column as follows
names(Cars93)

##Recall to build a subset we can list the rows and columns we want.
##For example the next line will give us the first 2 rows and first 3 columns
Cars93[1:2,1:3]

##Make a new file containing only columns I care about
myCars <- Cars93[,c(1,2,3,5,7,8,10,11,12,25,26)]

##Let's look at first 2 rows
myCars[1:2,]

##summary will give a nice summary of each column
summary(myCars)

##Apparently in 1993 there was a car that cost only $7.400. Let's find it
which(myCars$Price==7.40)
## Row 31
myCars[31,]
##Ford Festiva
##Note we could do the above in one step

myCars[which(myCars$Price==7.40),]

## Exercise 1
## List all cars that cost under 10,000 in 1993 and only show the Manufacturer, Model, Price, and Cylinders
## Do it in 1 line
## Begin your code here

## End your code here

## Exercise 2
## Repeat Exercise 1 with the following variation
## call the subset you create myCars2 and then do a summary of myCars2
## you may have 2 lines for this
## Begin your cod here

## End your code here

0 0
Add a comment Improve this question Transcribed image text
Answer #1

File Edit View Misc Packages Windows Help library (MASS) dim (Cars93) [11 93 27 names (Cars93) 1] Manufacturer 4] Min.PricFile Edit View Misc Packages Windows Help Median :28.00 Rear 16 5 Mcan29.09 3rd Qu.:31.00 Max : 2 Median :2.400 Median :3040

Exercise 1

myCars[which(myCars$Price<10000),c(1,2,4,8)]

Break the code

which(myCars$Price<10000) - This selects the cars whose Price is below 10000 of myCars

c(1,2,4,8) - This selects columns 1,2,4 and 8 of myCars

File Edit View Misc Packages Windows Help 떡 myCars [which (myCarsSPrice 10000), c ( 1, 2, 4, 8) Model Pricc Cylinders > ManufFile Edit View Misc Packages Windows Help Ford Crown Victoria 20.9 rotary 58 Mcrcedes-Benz 59 Mcrcedes-Benz Oldsmobile OldsmoFile Edit View Misc Packages Windows Help irebird 17.7 Volkawagen Volkawagen Volkawagen Volkawagen ENG 19:39 US 24-02-201

Exercise 2

myCars2<-myCars[which(myCars$Price<10000),c(1,2,4,8)]

The result is stored in myCars2

summary(myCars2)

This gives the summary of myCars2

File Edit View Misc Packages Windows Help 67 68 Maxima 21.5 Achieva 13.5 Oldsmobilc Cutlass Ciera 16.3 Silhouctte 19.5 71 Old

Add a comment
Know the answer?
Add Answer to:
Using Rstudio please provide your code as well as a screenshot of your code ## File:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 1 Write your code in the file MatrixOps.java. . Consider the following definitions from matrix...

    Problem 1 Write your code in the file MatrixOps.java. . Consider the following definitions from matrix algebra: A vector is a one-dimensional set of numbers, such as [42 9 20]. The dot product of two equal-length vectors A and B is computed by multiplying the first entry of A by the first entry of B, the second entry of A by the second entry of B, etc., and then summing these products. For example, the dot product of [42 9...

  • I can't attach the data due to the file being real large i can email it...

    I can't attach the data due to the file being real large i can email it to you so i can have your help on it # Assignment 1 # R Programming Language # ---- Why do Exploratory Data Analysis (EDA)? ---- # We will be looking at ## identifying outliers ## null values ## generating plots ## examining correlations # -------------------------------------------------------------- # In this video we will cover: ## univariate plots for continuous variables (boxlots, historgrams) ## bivariate plots...

  • Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you......

    Need help!! Java Eclipse Please provide the screenshot of output of code as well. thank you... PROGRAM 1 –Linear Data Structure Implementation (Due date: March 5th, 2019, 5% Grade Points) Given the starting point in a maze, you are to find and mark a path out of the maze which is represented by a 30x30 array of 1s (representing hedges) and 0s (representing the foot-paths). There is only one exit from the maze (represented by E). You may move vertically...

  • 22.39 LAB 13 C FALL 2019 Overview Demonstrate your ability to use pandas with functions Description...

    22.39 LAB 13 C FALL 2019 Overview Demonstrate your ability to use pandas with functions Description Write a program that reads data from an input file using a DataFrame and displays a subset of data using a method Provided Input Files An input file with nearly 200 rows of data about automobiles. The input file has the following format: mpg, cylinders, displacement, horsepower, weight, acceleration, model_year, origin, name 18,9,307,130,3504, 12, 70, usa, chevrolet chevelle malibu 15,8,350,165,3693, 11.5,70, usa, buick skylark...

  • For the program described below, document your code well. Use descriptive identifier names. Use s...

    For the program described below, document your code well. Use descriptive identifier names. Use spaces and indentation to improve readability. Include a beginning comment block as well as explanatory comments throughout. In the beginning comment block, add your name, program name, date written, program description. The description briefly describes what the program does. Include a comment at the beginning of each method to describe what the method does. Write a program to perform operations on square matrices (i.e. equal number...

  • For the program described below, document your code well. Use descriptive identifier names. Use spaces and...

    For the program described below, document your code well. Use descriptive identifier names. Use spaces and indentation to improve readability. Include a beginning comment block as well as explanatory comments throughout. In the beginning comment block, add your name, program name, date written, program description. The description briefly describes what the program does. Include a comment at the beginning of each method to describe what the method does. Write a program to perform operations on square matrices (i.e. equal number...

  • The goal is to create a code for implementing a Columns game using pygame Your program...

    The goal is to create a code for implementing a Columns game using pygame Your program will read its input via the Python shell (i.e., using the built-in input() function), printing no prompts to a user with no extraneous output other than precisely what is specified below. The intent here is not to write a user-friendly user interface; what you're actually doing is building a tool for testing your game mechanics, which we'll then be using to automatically test them....

  • Question 5: Sevens Let's take a look at data from both of our tables, students and checkboxes, to find out if students that got the number 7 assigned to them also chose '7' for the obedien...

    Question 5: Sevens Let's take a look at data from both of our tables, students and checkboxes, to find out if students that got the number 7 assigned to them also chose '7' for the obedience question. Specifically, we want to look at the students that fulfill the below conditions and see if they also chose '7' in the question that asked students to choose the number 7 (column seven in students). reported that their favorite number (column number in...

  • C++ must use header files and implementation files as separate files. I’ll need a header file,...

    C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...

  • using Java program please copy and paste the code don't screenshot it import java.util.Scanner; import java.io.File;...

    using Java program please copy and paste the code don't screenshot it import java.util.Scanner; import java.io.File; public class { public static void main(String[] args) { // Create a new Scanner object to obtain // input from System.in // --> TODO // Ask user for a word to search for. Print // out a prompt // --> TODO // Use the Scanner object you created above to // take a word of input from the user. // --> TODO // ***...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT