# Set the working directory to "C:/workspace".
setwd("C:/workspace")
# Check the resulting working directory.
# It should be "C:/workspace".
getwd( )
# Display all files in the working directory
dir( )
# Create an R dataframe from the CSV file
# nist-10.txt. CSV means comma separated value.
weightDf <- read.csv("nist-10.txt")
# Print the resulting data frame.
print(weightDf)
# Extract the Weight column from the dataframe:
w <- weightDf$Weight
# Print the extracted weight vector w.
print(w)
x <- seq(-4, 4, 0.05) y <- dnorm(x) plot(x, y, type="l")Answer: Here is the resulting R graph of the normal density:

x <- c(0.5, 0.5, 0.5, 1.5, 1.5) b1 <- c(0, 1, 2) b2 <- c(0, 1, 4) hist(x, breaks=b1, main="Equal Width Bins") hist(x, breaks=b2, main="Unequal Width Bins")The resulting histograms:


mean(x, trim=0.05)where trim=0.05 means trim 0.05 of the observations from the left and 0.05 of the observations from the right.
Answer for (a):
Calculation using numbers of observations in the
bins for weights:
0.5 * 1 + 1.5 * 3 + 2.5 * 5 + 3.5 * 1 21
------------------------------------- = --- = 2.1
1 + 3 + 5 + 1 10
Calculation using percentages of observations in the
bins for weights:
0.5 * 10 + 1.5 * 30 + 2.5 * 50 + 3.5 * 10 210
----------------------------------------- = --- = 2.1
10 + 30 + 50 + 10 100
Calculation using proportions of observations in the
bins for weights:
0.5 * 0.1 + 1.5 * 0.3 + 2.5 * 0.5 + 3.5 * 0.1 2.1
--------------------------------------------- = --- = 2.1
0.1 + 0.3 + 0.5 + 0.1 1
Ans for (b):
Use percentages for weights
0.5 * 30 + 1.5 * 50 + 3.0 * 20 150
------------------------------ = --- = 1.5
30 + 50 + 20 100
Ans for (c):
Use percentages for weights:
0.5 * 20 + 1.5 * 40 + 2.25 * 30 + 2.75 * 10 165
------------------------------------------- = --- = 1.65.
20 + 40 + 30 + 10 100
setwd("workspace")
thicknessDf <- read.csv("paper-thickness.txt")
t <- thicknessDf$Thickness
mean(t)
sd(t)
range(t)
# Default histogram
hist(t)
# Histogram with less breaks than default.
hist(t, breaks=c(0.09, 0.10, 0.11, 0.12))
# Histogram with more breaks than default.
hist(t, breaks=seq(0.09, 0.12, 0.001))
boxplot(t)