# HW3 - Introduction to R

The tasks (steps) within each of the following homework assignments (A to C) are expected to be performed in the order stated, since an earlier task will often generate the input for the next task.

## A. Object Subsetting, Import and Export

• Task 1: Sort the rows of the iris data frame by its first column and sort its columns alphanumerically by column names.
• Task 2: Subset the first 12 rows of the sorted iris dataset, export the result to a tabular file and view it in a spreadsheet program like Excel or Google Sheets.
• Task 3: Change some column titles in your spreadsheet program, save the result to a tab delimited text file and import it back into R. Note, for this task you only want to include the read.table command in the homework result (here R script).

Before you start it can be helpful to evaluate the structure of the iris data set with the following commands:

class(iris)
dim(iris)
colnames(iris)


## B. Scatter Plots

• Task 1: Generate a scatter plot for the first two columns of the iris data frame and color the dots by the Species column.
• Task 2: Use the xlim/ylim arguments to set limits on the x- and y-axes so that all data points are restricted to the bottom left quadrant of the plot.

Again before you start, evaluate the structure of iris data set. The following commands are useful:

iris[1:4,]
table(iris\$Species)


## C. Bar Plots

• Task 1: Calculate the mean values for the Species components of the first four columns in the iris data frame. Organize the results in a matrix where the row names are the unique values from the iris Species column and the column names are the names of the first four iris columns.
• Task 2: Generate two bar plots for the matrix generated in the previous step: one with stacked bars and one with horizontally arranged bars.

## D-H. Analysis Worflow

The instructions for these homework assignments are here.

## Homework submission

Assemble the code for solving the homework assignments A-H in a single R script (HW3.R) and upload it to your private GitHub repository under Homework/HW3/HW3.R. Note, the preassembled workflow script provided for HW3H (here) does not include the solutions for HW3A-C.

## Due date

This homework is due on Thu, April 23th at 6:00 PM.

See here.