matlab | 代写oop | 代写assignment | lab – Homework # 1 Assignment

Homework # 1 Assignment

matlab | 代写oop | 代写assignment | lab – 这是一个关于matlab的题目, 主要考察了关于matlab的内容,是一个比较经典的题目, 是比较有代表性的matlab/oop等代写方向, 这是值得参考的lab代写的题目

ass代做 assignment代写 代写assignment

ISE- 535 Data Mining

Due: January 21, 2021
For this assignment (and all assignments in this class), you are to turn in your work as an R Markdown document,which is a great tool for producing documents that include the output of chunks of R code. We will talk about R
Markdown a little in an upcoming class, but it is very easy to do basic operations. For this assignment, all youneed to do is to replace the various sections that say Insert R code here with your R code that provides the
solution to the problem and select Knit – to PDF from the menu in R Studio to generate a PDF file forsubmission.
I would recommend that you print out the four-page R Markdown Reference Guide that is part of R Studio byselecting Help->cheatsheets->R Markdown Reference Guide, although for this assignment all you need to do is
plug your chunks of R code into the assignment .Rmd file.

Problem 1 ( 50 points)

a. Read the csv file Cars Data.csv into an R dataframe variable cars (5 points)

## Insert R code here (^) cars<-read.csv( # ‘/users/xuanyuzhou/desktop/ise-535/Cars Data .csv’)

b. Check the class and dimensions of cars. (5 points)

## Insert R code here (^) class(cars)

[1] "data.frame"

dim(cars)

[1] 428 15

#

c. Display the second and fourth columns of the first 5 items in the dataframe (5 points)

## Insert R code here (^) cars[ 1 : 5 ,c( 2 , 4 )]

(^) (^) M M ooddeell O O rriiggiinn

1 3.5 RL 4dr Asia
2 3.5 RL w/Navigation 4dr Asia
3 MDX Asia
4 NSX coupe 2dr manual S Asia
5 RSX Type S 2dr Asia
5 rows
d. Display the names of the columns in cars. (5 points)

## Insert R code here (^) colnames(cars)

[1] "Make" "Model" "DriveTrain" "Origin" ## [5] "Type" "Cylinders" "Engine.Size..L." "Horsepower" (^)

[9] "Invoice" "Length..IN." "MPG..City." "MPG..Highway." ## [13] "MSRP" "Weight..LBS." "Wheelbase..IN."

#

e. Display the average number of cylinders in the cars dataframe (10 points)

## Insert R code here (^) mean(cars$Cylinders, na.rm = TRUE)

[1] 5.

#

f. Add a new column to your dataframe called wt_len_ratio that is the weight (in pounds) divided by thewheelbase length (in inches) (10 points)

## Insert R code here (^) # cars$wt_len_ratio <- cars$Weight..LBS./cars$Wheelbase..IN.

g. Display the Make and Model of the car with the highest horsepower (10 points)

## Insert R code here (^) sorted_cars <- cars[order(cars$Horsepower, decreasing = print(sorted_cars$Make[ 1 ]) T),]

[1] "Dodge"

print(sorted_cars$Model[ 1 ])

[1] "Viper SRT-10 convertible 2dr"

#

Problem 2 ( 50 points)

A common metric of health is the Body Mass Index (BMI), which is calculated simply as the weight in kilogramsdivided by the height in meters squared ( )
a. Create a function called parameters and returns the BMI. Use the conversions calculate_bmi() that takes height in inches and weight in pounds as and.
Test the function with a height of 72 and a weight of 190 lbs. (15 points)

## Insert R code here (^) calculate_bmi <- height_m <- height_in* function 0.035(height_in, weight_po){ weight_kg <- weight_po* return (weight_kg/(height_m*height_m))0. (^) }BMI <- calculate_bmi( (^72) , 190 ) BMI

[1] 22.

#

b. (15 points) General standard categories for BMI are given by:
BMI < 18.5: UnderweightBMI 18.5-24.9: Normal weight
BMI 25-29.9: OverweightBMI 30 or greater: Obese
Create a function called determine_weight_category that takes height in inches and weight in pounds asparameters and returns the category the person falls into. Test your function with the following values: (15 points)
Height: 60 / Weight 160 lbs
BMI = kg / m^2
inches 0. 035 = m pounds 0. 753592 = kg
Height: 68 / weight 160 lbsHeight 72 / weight 190 lbs

## Insert R code here (^) determine_weight_category <- BMI <- calculate_bmi(height_in, weight_po) function (height_in, weight_po){ if (BMI < return (18.5"Underweight"){ (^) ) } elsereturn if (BMI < ("Normal weight" 25 ){ (^) ) } elsereturn if (BMI < ("Overweight" 30 ){ (^) ) } elsereturn { (^) ("Obese") }} (^) determine_weight_category( 60 , 160 )

[1] "Overweight"

determine_weight_category( 68 , 160 )

[1] "Normal weight"

determine_weight_category( 72 , 190 )

[1] "Normal weight"

#

c. You want to create a plot of the BMI for a 180-pound individual at various heights from 60 to 84 (in one-inch increments). Create a vector heights to hold the various heights from 60 to 84 and write a for-l oop to
call your showing the relationship (using the mat lab plot function). Give the chart a title of BMI at Various Heightscalculate_bmi() function for each value of heights. Then, use these two vectors to plot a chart
for a 180-Pound Individual and label the X and Y axes. (15 points)

## Insert R code here (^) heights <- seq(BMIs <- NULL 60 , 84 , 1 ) for BMIs <- c(BMIs, calculate_bmi(height, (height in heights){ (^180) )) }plot(heights, BMIs, main = (^) "BMI at Various Heights for a 180-Pound Individual")

####### #

d. Repeat the question of part c without using a for-loop by replacing the loop with a single R statement. (5points)

## Insert R code here (^) BMIs <- calculate_bmi(heights, plot(heights, BMIs, main = "BMI at Various Heights for a 180-Pound Individual" 180 ) (^) )

####### #