week 7 assignment solution
week 7 assignment solution
1. For a frequency distribution of variable x, mean = 32, median = 30, mode = 26. The
distribution is:
a) Positively skewed (Hint: Mean>Median>Mode)
b) Negatively skewed (Hint: Mean < Median < Mode)
c) Mesokurtic (Hint: Probability distribution where extreme events are close to zero)
d) Platykurtic (Hint: Probability distribution is flatter than a normal distribution with
shorter tails)
Hint: mutate() creates new column variables in a dataframe. The filter() function is used to
extract subsets of rows from a data frame based on a certain rule or condition. arrange() is used
to reorder rows of a data frame (e.g., alphabetically or a numerical variable from high to low,
etc.).
d) None of these
a) Integer [Hint: there are no levels in the object having “integer” class in R]
b) Character [Hint: The objects of class “character” contain data in strings, and hence
command is not suitable for identifying levels]
c) Factor [Hint: Levels command is suitable for categorical variables. These variables
are defined as of class “factor” in R]
d) Numeric [Hint: The objects of class “numeric” contains data in decimals and hence does
not include categories/levels in data]
5. Which of the following codes is correct to remove all the objects from the current
working environment?
a) rm(list = ls()) [Hint: This will remove all the objects from the current working
environment]
b) list(rm=T) [Hint: This will create a list object type of class logical]
d) None of these.
a. Factors are used to represent numeric data in R. [Hint: Factors represent categorical
data, such as 1/0 or Male/Female]
b. Factors are used to represent categorical data in R. [Hint: Factors represent
categorical data, such as 1/0 or Male/Female]
c. Factors are used to represent missing values in R. [Hint: Factors represent categorical
data, such as 1/0 or Male/Female]
d. Factors are used to represent character data in R. [Hint: Factors represent categorical
data, such as 1/0 or Male/Female]
a. df[1,]. [Hint: df[1,] will select the first row of dataframe ‘df’ and all the columns]
b. df[,1]. [Hint: df[,1] will select all the rows and first column from ‘df’]
c. df[-1,]. [Hint df[-1,] will select all the columns and all the rows except the first row
from ‘df’]
d. df[1,1]. [Hint: df[1,1] will select the first row and first column element from ‘df’]
9. Which of the following best describes the output of the following R code: sqrt (-16)
a. NaN. [Hint: square root of -16 is not defined so it will result in NaN]
b. 4. [Hint: square root of -16 is not defined so it will result in NaN]
c. NA. [Hint: square root of -16 is not defined so it will result in NaN]
d. FALSE. [Hint: square root of -16 is not defined so it will result in NaN]