Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Loading pre-stored data and viewing the data: We first consider analyzing the iris dataset, which was collected by the famous statistician Sir Ronald Fisher
1. Loading pre-stored data and viewing the data: We first consider analyzing the iris dataset, which was collected by the famous statistician Sir Ronald Fisher (in the early 1900s). This dataset is already available in R, so we only need to call the dataset from the console. Load and view, and read a description about the data using the below commands. #Load the data data(iris) #Look at the data iris #Read a description of the data help(iris) When data is first loaded to your R console, it is stored as a data frame structure. Data frames are a tabular representation of data and can contain any mix of characters, numerical quantities, or factors. An important aspect of the data frame is that it contains both row and column names. Often, we want to extract a subset of the data to take a closer look. This can be done directly using the row or column name or by calling the number of the row/column you want to extract. Follow the example below for an illustration. #Display the column and row names of the data colnames(iris) rownames(iris) #Look at the 10th row iris[10, ] #Look at the 3rd column iris[, 3] #Alternatively, just look at the variable "Petal.Length" 1 iris$Petal.Length #Store columns 1-2 and rows 10-20 for later use subset.data <- iris[10:20, 1:2] #Store the species names for later use Species.names <- iris$Species As we see above, the $ symbol can be used to call a column as long as it is followed by the exact column name. Note: Remember that R is case sensitive! In the command line (not in your knit file), run the command iris$petal.Length to see what happens in your console. Questions (a) (5 points) What are the different variables in this dataset? What are the measurements of each of these variables for the 10th sample? (b) (5 points) How many samples are in this dataset? What are the different species of flower that have been measured
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started