WorksheetsREVIEWER
Total questions: 93
Worksheet time: 1hrs 27mins
output and error messages are displayed.
(a)
output and error messages are displayed.
(a)
where you will see the different objects you create or the different datasets you import.
(a)
contains everything else including help, plots, packages, etc.
(a)
you can type and save your commands and make notes to yourself about projects.
(a)
Extracting means selecting columns. An imported Excel data file in R is classified as a dataframe, how we can extract a single column from a dataframe. Give the syntax:
(a)
Number values like 3.6 are called? These values are recognized in R as is.
(a)
Boolean values true or false are called_, They are recognized in R as TRUE or T for true and FALSE or F for false.
(a)
Text (or string) values are called (a) , and are recognized with ”” or ”.
a type of array that is one-dimensional.
they are logical elements in programming languages that are used for storing data.
(a)
write the syntax to create a vector.
(a)
create a vector of 5 names (Gwen, Monica, Mercy, Janelle, Kaze). Save it on v_name.
(a)
a function
used to attach files
in the workspace
(a)
a function
used to load a package
in the workspace
(a)
The command for naming object:
(a)
Exercise 1: Assign the values 1, 2, and 3 to variables x, y, and z respectively.
(a)
Exercise 2: Print the variable x and the letter ”x” in 3 ways.
(a)
To check the data type of a variable, what is the syntax to use the class function.
(a)
what will be the outcome if we check the data type of TRUE, class(TRUE)
(a)
what will be the outcome if we check the data type of "1234", class("1234")
(a)
write the syntax of vector of consecutive numbers
(a)
refers to a statistical data type used to store categorical variables. The difference between a categorical variable and a continuous variable is that a
categorical variables can belong to a limited number of categories. A continuous variables, on the other hand, can correspond to an infinite number of values.
(a)
How do you create a factor in R?
(a)
Example: Out of 60 respondents considered in the survey, thirty of them indicate that they are single, twenty of them are married and ten of them are separated. Create a factor, based on the information given. (use replicate function and save in to f_ms)
(a)
what is the syntax of
an ordered factor
(a)
More complex sequences: give the syntax of numbers from 1 to 100, with an interval of 0.5
(a)
More complex sequences: give the syntax of numbers from 1 to 20, and has a total of 50 outcome when printed
(a)
select the 150th outcome in the variable called number1
(a)
a two-dimensional array of numbers having a fixed number of rows and columns and containing a number at the intersection of each row and each column. By storing values in a matrix rather than as individual variables, a program can access and perform operations on the data more efficiently.
(a)
give the syntax to create a matrix
(a)
The entire mth row of a matrix can be extracted as (give the syntax)
(a)
The entire nth column of a matrix can be extracted by (give the syntax)
(a)
To extract more than one rows at a time: (give syntax)
(a)
To extract more than one columns at a time: (give the syntax)
(a)
give the syntax to create a list
(a)
a table or a two-dimensional array-like structure in which each column contains values of one variable and each row contains one set of values from
each column.
(a)
give the syntax to create a data frame
(a)
Create a data frame from the ”SAMPLE DATA” and name it as NEW DF2.
This data frame should include the following variables:
- GENDER
- FAVORITE SUBJECT
- GRADE IN MATH
(a)
give the syntax to create a subset
(a)
Create the following data frame from NEW_DF2 with the following conditions:
►sub_DF1: All male whose favorite subject is math.
(a)
this function determines the number of rows in an object such as matrix, dataframe, or even a dataset.
(a)
usually constructed piecemeal, with each aspect of the plot handled separately through a series of function calls; this is often conceptually simpler and allows plotting to mirror the thought process.
(a)
combines concepts from both base and lattice graphics but uses an independent implementation.
(a)
In the Base Graphics system, we can create a histogram using the hist() function: give its syntax
(a)
Use the dataset package in R to create a histogram of variable Ozone in airquality data frame called "New York Air Quality Measurement". (give the syntax)
(a)
syntax to change or add plot title
(a)
give the syntax to add or change x and y axis labels
(a)
syntax to add or change border color
(a)
give the syntax to add or change the bar color of the graph
(a)
give the syntax: number of breakpoints or can be a vector of breakpoints
(a)
In the Base Graphics system, we can create a scatter plot using the plot() function. give its syntax:
(a)
Using the air quality data frame, create a scatter plot of variable Wind for the x-axis values and variable Ozone for the y-axis values.
(a)
Box plots are created using the boxplot() function. give its syntax:
(a)
the plotting symbol (default is open circle), accepts ASCII code of the symbol (Base Graphics: Parameters)
(a)
the line type (default is solid line), accepts type such as ”dashed”, ”dotted”: (give the syntax)
(a)
the line width, specified as an integer multiple: (give the syntax)
(a)
what function is used to specify global graphics parameters that affect all plots in an R session.
(a)
under the par() function: give the syntax to set the number of plots per row, column (plots are filled row-wise)
(a)
under the par() function: give the syntax to set number of plots per row, column (plots are filled column-wise)
(a)
give the syntax to set the orientation of the axis labels on the plot, accepts values 0,1,2, and 3
(a)
give the syntax to set the background color
(a)
give the syntax to set the margin size, accepts vector c(b,l,t,r)
(a)
give the syntax to set the outer margin size (default is 0 for all sides), accepts vector c(b,l,t,r)
(a)
ggplot2 is a ”third” graphic system for R (along with base and lattice).
There are two plotting functions available:
(a)
give the syntax of qplot()
(a)
Character vector specifying -- to use. Defaults to ”point” if x and y are specified, and ”histogram” if only x is specified. It accepts ”point”, ”line”, ”smooth”, ”boxplot”.
(a)
Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms. Aesthetic mappings can be set in ggplot() and in individual layers.
(a)
Add components to a plot It is the key to constructing sophisticated ggplot2 graphics. It allows you to start simple, then get more and more complex, checking your work at each step.
(a)
In R, we can write a conditional if-else statement as follows: (give syntax)
(a)
Import the SAMPLE DATA and create an if-else statement that will return ”Passed” if the GRADE IN MATH is at least 75, otherwise ”Failed”.
(a)
is calculated by taking the sum of the values and dividing with the number of values in a data series.
(a)
is a measure of how far away items in a data set are from the mean. The larger the standard deviation, the more variation there is in the data set.
(a)
If there are missing values, then the mean and sd function returns NA. To drop the missing values from the calculation use (a)
You can use (a) function to produce mean, median, minimum, maximum, and 1st and 3rd quartile.
The dplyr package allows to use the forward-pipe chaining operator (%>%) for combining multiple operations.
The shortcut key in RStudio for windows is:
(a)
filter(): Use filter to filter data with required condition.(give its syntax)
(a)
Create a data frame from the SAMPLE DATA and name it NEWDATA1. This data frame should have male students whose favorite color is blue with a grade in math greater than or equal to 95.
(a)
Create a data frame from the SAMPLE DATA and name it NEWDATA2. This data frame should have students who have grades above 90 in math, statistics and probability, and science.
(a)
Create a data frame from the SAMPLE DATA and name it NEWDATA3. This data frame should include students whose favorite subject is math or science and who have a grade in Media and Information Literacy greater than 90.
Syntax of condition for favorite subject: <var> %in% c(<var>,..,<var>)
(a)
give the syntax to reorder rows
(a)
Arrange the NEWDATA1 into ascending order based on the students’ weight.
(a)
Arrange the NEWDATA2 into descending order based on the based on students’ weight.
(a)
select(): to select variable: give the syntax:
(a)
To remove columns: give the syntax (data manipulation)
(a)
Manipulate NEWDATA2 to remove the variables FAVORITE COLOR, HEIGHT, WEIGHT, and EXTRA.
(a)
rename(): Use to rename column(s); (give the syntax)
(a)
mutate(): add new variables that are functions of existing variables.(give the syntax)
(a)
Create a column ”AVERAGE” on NEWDATA2, which contains the calculated sum of the 4 subjects divided by 4.
(a)
using the summarise function give the syntax to find the average grade in Math of the students based on their gender.
(a)
take random samples.
To draw a sample of observations without replacement: (give syntax)
(a)
Randomly select 8 observations from SAMPLE DATA.
(a)
To keep only the first set of observation:
(a)
To keep only the last set of observation:
(a)
