Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<R programming> Suppose that you have a dataset ufc.csv, with forest inventory o

ID: 3302164 • Letter: #

Question

<R programming>

Suppose that you have a dataset ufc.csv, with forest inventory observations(plot, tree, species, diameter, height)

(a) Write a program to know what the species of the three tallest trees are. And the five fattest trees.(Use the order command)

(b) Write a program to know what the mean diameters by species are.

(c) Write a program to know what the two species that have the largest third quartile diameters are .

(d) Write a progrma to know what the two species with the largest median slenderness(height/diameter) ratios. How about the two species with the smallest median slenderness ratios.

(e) Write a program to know what the identity of the tallest tree of the species that was the fattest on average is.

Explanation / Answer

(a)

# Load the ufc.csv file into dataframe ufc
ufc <- read.csv(ufc.csv, header = TRUE)
heights <- ufc$height
diameters <- ufc$diameter
# Get the third tallest tree heights
top.height <- heights[order(heights)[3]]
# Get the fifth fattest tree diameters
top.diameter <- diameters[order(diameters)[5]]
# Select the species which have heights greater than the third tallest tree heights
subset(ufc, height >= top.height, select = c(species))
# Select the species which have diameter greater than the third fattest tree diameter
subset(ufc, diameter >= top.diameter, select = c(species))

(b)

(c)

subset(d ,diameter >= sort(diameter,decreasing = TRUE)[2],select = c(species))

(d)

ufc$slenderness <- ufc$height/ufc$diameter

# 3rd quartile is the 5th element of summary

# two species with the largest median

subset(s ,slenderness >= sort(slenderness,decreasing = TRUE)[2],select = c(species))

# two species with the smallest median

subset(s ,slenderness <= sort(slenderness)[2],select = c(species))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote