biostatistics

biostatistics

The goal of this lab is to introduce you to R and RStudio, which you’ll be using throughout BIOL 3000 both to learn the statistical concepts discussed in the textbook

and also to analyze real data and come to informed conclusions.

Instructions: For all of the problems below, copy the R commands and the results of the R commands into the green boxes.

1. Show that the mathematical quantity e π i = -1 + 0i. Copy your R statement and result into the box below. (Hint: the imaginary number i can be created using

(0+1i) in R. (1 points).

2. The Fibonacci sequence appears in many biological structures. It is formed by starting with the number 0, 1 and then adding the last two numbers to get the next

number: 0, 1, 1, 2, 3, 5, 8, etc. Create variable called fib that is a numeric vector with the first 10 values of the Fibonacci sequence. Type the name of the variable

fib so that it is displayed. (1 points).

3. Create a character vector gtypes that contains three text strings “AA”, “Aa”, and “aa” representing three diploid genotypes. Type the name of the variable

gtypes so that it is displayed. Then use the paste() function to create a single text string displaying all three genotypes. (1 points).

4. Use R to create the following a variable mymat that contains numeric matrix with 0.1, 2, 4 in the first column, 7, 3, 100 in the second column, and -1, -0.9, 8,

in the third column. Type the name of the variable mymat so that it is displayed. Then use the transpose function to display the transpose of the matrix mymat. (1

points).

5. Create a list myvars with elements fib, gtypes, and mymat. Type the name of the variable myvars so that it is displayed. Multiply the third element of the list

by the number p. (1 points).

6. Consider the following data:

Age Height Gender Smoker

22 66 F FALSE

25 71 M TRUE

28 64 F TRUE

Use the function data.frame() to create a data frame object called mydata for these data with the column names and values above. Type the name of the variable mydata

so that the data set is displayed. (1 points).

7. Import the data set in the Excel file Lab2AssignmentData.xlsx into an R data frame variable called mussels. This data set contains the shell length and gonad

weights of marine mussels. Create a scatter plot with shell length on the x-axis and gonad weight on the y-axis. Above the plot, click on the Export button and select

Copy to Clipboard… from the menu. On the panel that appears, click the Copy Plot button and paste the plot into the green box below after your R commands. (2 points).

8. If it is not currently in your workspace, use the following url to import the birth data into an R data file: http://www.openintro.org/stat/data/present.R you

have. Create a line plot of the total number of children (y-axis) versus the year (x-axis) and copy/paste the plot into the green box below after your R commands.

(Hints: the y-variable can be entered as present$boys + present$girls. A line plot can be produced by adding a lower case L, “l”, as an additional parameter in the

plot function.) (2 points).

Order from us and get better grades. We are the service you have been looking for.