Question
Before completing this assignment, install and load the tidyverse package as follows in RStudio: install.packages('tidyverse') library(tidyverse) Then create an R script which does the following:
Before completing this assignment, install and load the tidyverse package as follows in RStudio:
install.packages('tidyverse') library(tidyverse)
Then create an R script which does the following:
reproduce the vector from the first task of this module's practice exercise
use the sample function to extract a sample vector of size 10 from the original vector
use various summary statistics functions to display descriptive statistics for the sample
call the mean, median, min, and max functions for your sample vector
use the summary function to also display descriptive statistics for the sample
compare the results of the individual function results to your summary function results
create and print a tibble from the sample vector. A tibble is a tidyverse-specific data type derived from base R data frames (we will cover both of these in this course). We are doing this step to practice loading a package and using its functions. To create a tibble, pass the sample vector as an argument to the tibble() function and assign the returned object to a variable.
For this exercise, we will practice creating and executing an R script in RStudio.
This script will use the following functions: seq (sequence), rep (replicate), and sort.
Use the R help feature for information on these functions, e.g. ?seq Remember that the help pages sometimes include examples at the bottom of the page.
There are three tasks to complete:
Create, store, and display a sequence of values from 5 to -11 that progresses in steps of 0.3.
Repeat the vector c(-1,3,-5,7,-9) twice, with each element repeated 10 times, store and display the result, then display the result, sorted from the largest value to the smallest.
Create, store, and display a vector containing 15 values in a sequence from 10 to 19.
Use "File/New File/R Script" to create a new file and enter your code, including a commented 4-line ID header (file name, your name, date, and a one-line description) at the top. To store a vector, assign it to a variable. To display it, you can either use the print function or just enter the variable name on a line by itself.
Save your file with a .R extension. To source and run it, you can Ctrl-A to select all, then hit the Run button, or use the Shift-Ctrl-Enter key combination (if you just hit Run, the program will run one line at a time).
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