setwd("~/UVM/BIO 381 Computational Biology/Website")
  1. Read in the weight data that is posted on webpage as ‘Weight data’.
weightData <- read.csv(file = "weightData.csv", header = TRUE)
head(weightData)
##   gender height_in weight_lbs
## 1      m        72        165
## 2      m        67        160
## 3      m        68        160
## 4      f        64        114
## 5      f        66        135
## 6      m        69        148
  1. What    type    of  object is the   file    read    in  as?     If  it  is  not a   data    frame,  coerce  it  to  one.
str(weightData) # is a data.frame
## 'data.frame':    15 obs. of  3 variables:
##  $ gender    : Factor w/ 2 levels "f","m": 2 2 2 1 1 2 1 1 1 1 ...
##  $ height_in : int  72 67 68 64 66 69 68 63 65 69 ...
##  $ weight_lbs: int  165 160 160 114 135 148 120 138 135 150 ...
  1. What    are object/data types   of  each    of  the columns?
str(weightData) 
## 'data.frame':    15 obs. of  3 variables:
##  $ gender    : Factor w/ 2 levels "f","m": 2 2 2 1 1 2 1 1 1 1 ...
##  $ height_in : int  72 67 68 64 66 69 68 63 65 69 ...
##  $ weight_lbs: int  165 160 160 114 135 148 120 138 135 150 ...
#gender is a factor (with 2 levels)
# height is an integer
# weight is an integer
  1. Plot weight (on y axis) vs height (on x axis) with different colored symbols for each gender.
plot(weightData$height_in, weightData$weight_lbs, col=weightData$gender)

  1. Write   a   function    to  calculate   '10!', i.e.,    10  factorial (10 * 9 * 8 *... * 1).        Show    the result  for 10  and 20.
# 10 factorial
x=10
y=1
for(i in 1:x){
  y <-y*((1:x)[i])
}
print(y)
## [1] 3628800
# 20 factorial
x=20
y=1
for(i in 1:x){
  y <-y*((1:x)[i])
}
print(y)
## [1] 2.432902e+18