Introduction to R and RStudio

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Given R's capabilities in statistical computing, what is the most significant implication of its open-source nature for researchers?

  • It ensures that R is always simpler to use than commercial statistical software.
  • It guarantees that the software is completely bug-free and universally accepted.
  • It restricts the use of R to academic institutions only due to licensing constraints.
  • It allows for community-driven development, validation, and extension of statistical methods. (correct)

RStudio offers both Desktop and Server editions. In what scenario would the Server edition provide the most strategic advantage over the Desktop edition?

  • When teaching introductory statistics courses.
  • When needing to collaborate on R projects and share computational resources across a team or organization. (correct)
  • When the user has limited internet access.
  • When performing simple, one-time data analysis tasks on a personal computer.

Considering the distinct roles of 'Run' and 'Source' in executing R code, in what complex debugging scenario would using 'Run' be more advantageous, despite its limitations with large code blocks?

  • When the goal is to produce a clean, reproducible report.
  • When needing to execute a function defined in another script.
  • When executing an entire script to check for syntax errors.
  • When repeatedly testing a small section of code that modifies global variables, to observe the incremental changes. (correct)

What is the most critical implication of R's capacity to manage files, plots, packages, and help resources through its interface for advanced users managing complex projects?

<p>It centralizes project management, enhancing reproducibility and collaboration. (A)</p>
Signup and view all the answers

Given R's rules for naming variables, which of the following variable names would be considered valid and least likely to cause issues in complex data analysis scripts?

<p>data.2024 (A)</p>
Signup and view all the answers

Considering R's data types and conversion functions, what is the most robust approach to ensure that a character vector representing numerical data is accurately processed in statistical computations?

<p>Use <code>as.numeric()</code> to convert the vector, checking for <code>NA</code> values to handle non-numeric conversions. (A)</p>
Signup and view all the answers

In R, you are tasked with writing an algorithm that requires the creation of a data structure capable of storing elements of varying data types such as numeric, character, and logical values. Furthermore, the order of these elements matters for subsequent processing steps. Which data structure is most appropriate for this task?

<p>List (C)</p>
Signup and view all the answers

When importing a dataset with mixed data types into a data frame, which approach ensures that character columns are not converted into factors, preventing unintended consequences in subsequent analysis stages?

<p>Specify <code>stringsAsFactors = FALSE</code> during the data frame creation. (C)</p>
Signup and view all the answers

When combining two data frames in R using a join operation, what advanced consideration is essential to maintain data integrity and accuracy, especially when duplicate column names exist?

<p>Manually rename overlapping columns before performing the join. (D)</p>
Signup and view all the answers

When reshaping data using melt and cast, what is the most critical implication to consider when selecting id.vars and measure.vars to avoid unintended aggregation or data loss?

<p>The combination of <code>id.vars</code> should uniquely identify each observation. (B)</p>
Signup and view all the answers

In the context of joining data frames using the dplyr package, which join operation is best suited for identifying rows in the first data frame that do not have a match in the second data frame, without including any columns from the second data frame?

<p><code>anti_join()</code> (C)</p>
Signup and view all the answers

How does R handle matrix division, and what implication does this have for users accustomed to linear algebra conventions?

<p>R performs element-wise division, which differs from standard matrix inversion but is useful for scaling operations. (A)</p>
Signup and view all the answers

What is the most significant difference between isTRUE(x) and x == TRUE when evaluating logical conditions in R, especially in the context of debugging complex conditional statements?

<p><code>isTRUE(x)</code> will always return a logical value, while <code>x == TRUE</code> can return <code>NA</code> if x is <code>NA</code>. (B)</p>
Signup and view all the answers

How would you correctly access the element in the 2nd row and 3rd column of a matrix named dataMatrix in R, and what potential error could arise if the matrix is not properly formatted?

<p><code>dataMatrix[2,3]</code>; an error if the matrix has fewer than 3 columns. (D)</p>
Signup and view all the answers

In the context of function creation in R, what is the most critical distinction between defining a function and invoking it in relation to the 'Source' button in RStudio?

<p>The 'Source' button loads the function definition into memory but does not run it; you must invoke the function separately. (C)</p>
Signup and view all the answers

When constructing a custom R function with multiple arguments, in what scenario is it most strategic to specify default values for some arguments, and what potential pitfall should be avoided?

<p>To simplify function calls for common use-cases, ensuring that the default values are meaningful and do not lead to incorrect results if unspecified. (B)</p>
Signup and view all the answers

Regarding lazy evaluation in R functions, what is the most crucial consideration when deciding whether or not to include error handling for missing arguments?

<p>Error handling is essential if the missing argument is used within the function's code; otherwise, the function may execute without issue, potentially yielding incorrect results. (A)</p>
Signup and view all the answers

When writing a function that needs to return multiple computed values, what is the most appropriate and scalable approach to structure the output in R, and what are the implications for accessing those values?

<p>Return a list where each element corresponds to one of the computed values; this allows for easy access by name or index. (D)</p>
Signup and view all the answers

When using the apply() function in R, what is the critical consideration regarding the structure and dimensions of the input matrix to ensure that the function is applied as intended over rows or columns?

<p>The <code>MARGIN</code> argument must be set to '1' for applying the function over rows and '2' for columns, ensuring proper interpretation of summary statistics. (D)</p>
Signup and view all the answers

In complex data analysis workflows in R, what is the most important reason for using control structures (e.g., loops and conditional statements) effectively, especially when dealing with large datasets?

<p>To automate repetitive tasks, perform complex data transformations, and implement custom algorithms, enhancing efficiency and reproducibility. (C)</p>
Signup and view all the answers

Given the possible outcomes of an if statement in R, what are the implications of its flexible syntax for processing datasets with missing or NA values in conditional checks?

<p>The <code>if</code> statement will return an error when encountering an <code>NA</code> value, requiring explicit handling of <code>NA</code> values to ensure robust execution. (C)</p>
Signup and view all the answers

When constructing a loop through elements used in the seq() function to guide sequences, what is the most critical consideration when generating numerical sequences with specific increments, especially for tasks requiring precise calculations?

<p>Floating point arithmetic might be unpredictable because computers only store a limited number of digits for each number. (A)</p>
Signup and view all the answers

When using functions to create visualizations, what important principle of graphic design should be taken into account when determining a title?

<p>Titles help identify the image as well as help the viewer understand the content and takeaways of an image. (B)</p>
Signup and view all the answers

Why is it important to keep in mind limitations in certain R base graphics?

<p>Knowing limitations helps determine when it is appropriate to seek other plotting tools or add-on packages. (C)</p>
Signup and view all the answers

What consideration is most important for reproducibility purposes, when installing R and RStudio, combined with R packages?

<p>Document and replicate the versions of R, RStudio, and all packages used, because using certain software versions can affect code. (B)</p>
Signup and view all the answers

Flashcards

What is R?

An open-source language used for statistical computing, data analysis, and visualization.

What is RStudio?

An Integrated Development Environment (IDE) for R, available in open-source and commercial versions.

What is The Console?

The area in RStudio where you write and execute code.

Environment/History Tab

Shows variables and command history.

Signup and view all the flashcards

Files/Plots/Packages/Help

Used to manage files, view plots, install packages, and get help in RStudio.

Signup and view all the flashcards

Set Working Directory

Choose a directory via icon or use the setwd("directory path") command.

Signup and view all the flashcards

R Script File Creation

Click 'File' > 'New File' > 'R Script'.

Signup and view all the flashcards

Saving an R Script

File > Save or Ctrl + S.

Signup and view all the flashcards

Run Selected Lines

Click Run or press Ctrl + Enter.

Signup and view all the flashcards

Run Whole Script

Click Source or press Ctrl + Shift + S

Signup and view all the flashcards

Run

Executes selected lines of code.

Signup and view all the flashcards

Source with echo

Executes the whole file, and displays output in console.

Signup and view all the flashcards

What R is Mainly Used For

Primarily used for statistical computing and data analysis

Signup and view all the flashcards

Non-existent RStudio Edition

The mobile edition

Signup and view all the flashcards

Command to Set Working Directory

The setwd() command

Signup and view all the flashcards

"Source with echo" Action

Executes and displays the code in the console

Signup and view all the flashcards

Run Selected Lines Shortcut

Ctrl + Enter

Signup and view all the flashcards

What kind of language is R?

Open-source statistical computing language.

Signup and view all the flashcards

Designed for What?

For data analysis and statistical computing.

Signup and view all the flashcards

R's Interface Type

Command Line Interface (CLI).

Signup and view all the flashcards

RStudio Description

An Integrated Development Environment (IDE) for R.

Signup and view all the flashcards

Platform R/RStudio Doesn't Support

Android.

Signup and view all the flashcards

Valid Working Directory

setwd("path")

Signup and view all the flashcards

RStudio Edition Not Available

It is not available

Signup and view all the flashcards

Console Panel Does What?

Executes R code.

Signup and view all the flashcards

Executing Selected Lines of Code

Ctrl + Enter

Signup and view all the flashcards

Used if you want to execute an entire script and display the output

To execute the entire R script and display output

Signup and view all the flashcards

What source does

Executes all commands but hides them in the console.

Signup and view all the flashcards

Why Run for large blocks is not ideal

It overpopulates the console.

Signup and view all the flashcards

Environment/History Tab Shows?

Shows variables and command history.

Signup and view all the flashcards

Major Disadvantage of Using Run over Source

Messy console for large sections.

Signup and view all the flashcards

What happens after save

It can be reused later.

Signup and view all the flashcards

RStudio's Tab is Used For?

“Files/Plots/Packages/Help” tab is used to managing files, viewing plots, managing packages.

Signup and view all the flashcards

Source with Echo

Ctrl + Shift + Enter

Signup and view all the flashcards

Advantage Run

Good for small code testing/debugging.

Signup and view all the flashcards

What RStudio Allows Users To Do?

Write, save, and execute R code

Signup and view all the flashcards

Helps debug code easily

Feature helps debug code easily

Signup and view all the flashcards

Study Notes

Introduction to R

  • R is an open-source programming language
  • R is used for statistical computing, data analysis, and data visualization
  • R possesses a command-line interface (CLI)
  • R is available on Windows, Linux, and Mac OS

What is RStudio?

  • RStudio is an Integrated Development Environment (IDE) for R
  • RStudio comes in open-source and commercial versions, as well as desktop and server editions
  • It is available on Windows, Linux, and Mac OS

RStudio Interface Overview

  • The Console is where code is executed
  • The Environment/History tab displays variables and command history
  • The Files/Plots/Packages/Help tab is used to manage files, view plots, and install packages

Setting the Working Directory

  • To set the working directory, choose a directory through an icon or use the command setwd("directory path")
  • Alternatively, click "More" and then "Set as Working Directory"

Creating and Saving R Script Files

  • To create an R script file, click "File" > "New File" > "R Script" or use the toolbar icon
  • Save a script using "File" > "Save" or Ctrl+S

Executing R Code

  • To run selected lines, click "Run" or press Ctrl+Enter
  • To run the entire script, click "Source" or press Ctrl+Shift+S
  • Use Source with echo (Ctrl+Shift+Enter) for output visibility

Run vs Source

  • Run executes selected lines and is good for debugging
  • Source executes the whole file and is efficient for a full script
  • Run can lead to a messy console with large code

Practice MCQs (Lecture 1)

  • R is primarily used for Statistical Computing and Data Analysis
  • Mobile is not an edition of RStudio
  • setwd() is the command used to set the working directory in R
  • "Source with echo" executes the code and displays the code in the console
  • Ctrl + Enter is the shortcut to run selected lines in RStudio
  • R is an open-source Statistical Computing Language
  • R has a Command Line Interface (CLI)
  • RStudio is an Integrated Development Environment (IDE) for R
  • Android is not a platform R and RStudio support
  • setwd("path") is a valid R command to set a working directory
  • Mobile is not an available RStudio edition
  • The Console panel in RStudio executes R code
  • Ctrl + Enter is the shortcut for executing selected lines of code in RStudio
  • "Source with echo" is used to execute the entire R script and display output
  • Source executes all commands, but hides them in the console
  • Using Run for large code blocks is not ideal as it overpopulates the console
  • RStudio's Environment/History tab shows variables and command history
  • A disadvantage of using Run over Source is a messy console for large sections
  • Saving an R script file means it can be reused later
  • RStudio's “Files/Plots/Packages/Help” tab manages files, viewing plots, managing packages
  • Ctrl + Shift + Enter is the shortcut for Source with echo in RStudio
  • Advantages of using Run are that it is good for small code testing/debugging
  • RStudio allows users to write, save, and execute R code
  • The Run command in RStudio helps debug code easily

Introduction to R – Lecture 2

  • Comments are added using # at the start of the line for single-line comments
  • Multi-line comments can be created by selecting lines and pressing Ctrl + Shift + C, or by going to Code -> Comment/Uncomment Lines
  • Clear the console by pressing Ctrl + L
  • Remove variables from the environment:
    • Single variable: rm(variableName)
    • All variables: rm(list = ls())
  • Workspace data is temporary and lost when R is closed or the computer is restarted
  • Manually save a variable using save(a, file = "sess1.Rdata")
  • Save the entire workspace using save(list = ls(all.names = TRUE), file = "sess1.Rdata")
  • The shortcut to save the whole workspace is save.image()
  • Load a saved workspace using load(file = "sess1.Rdata")

Practice MCQs (Lecture 2)

  • "#" is used for single-line comments in R
  • Ctrl + Shift + C is the shortcut to comment multiple lines in RStudio
  • Ctrl + L clears the console in RStudio
  • rm(x) removes a variable x from the environment
  • rm(list = ls()) removes all variables from the environment
  • ls() lists all variables in the environment
  • Workspace data is lost when R is restarted without saving
  • save(a, file = “sess1.Rdata”) saves a variable
  • save(list = ls()) saves the entire workspace
  • save.image() is the shortcut command to save the entire workspace
  • load(file = “sess1.Rdata”) loads a saved workspace
  • Code > Comment/Uncomment Lines is the RStudio menu option to comment code
  • rm(list = ls()) removes all variables
  • save() saves data to a file
  • It is not possible to recover workspace without saving
  • RStudio's workspace data is temporary
  • clear.console() is not a valid R command
  • Workspace is saved as a .RData file after using save.image()
  • The expression list = ls() inside rm() removes all variables

Variables in R

  • The file extension for a saved R workspace is .Rdata
  • The rules for naming variables are:
    • Includes letters, numbers, _, and.
    • Must start with a letter
    • Cannot use special characters: !, @, #, $, etc
  • Pi, lowercase letters, uppercase letters, and months are examples of pre-defined constants in R and all have specific names

Basic Data Types in R

  • The basic data types in R include:
    • Logical (TRUE, FALSE)
    • Integer (whole numbers)
    • Numeric (real numbers)
    • Complex (complex numbers)
    • Character (letters, symbols)
  • Tasks, syntax and examples for type checking and conversion are as follows:
    • typeof(), is.datatype(), as.datatype()

Basic R Objects

  • The structure of basic R Objects is as follows:
    • Vector (same data type)
    • List (any data type)
    • Data Frame (tables with rows and columns)
  • All elements in a vector must be of the same type are created using c()

Lists

  • Can contain different types, numbers, strings, vectors, etc.
  • Lists are created using the list() function.

Accessing, Modifying and Concatenating Lists

  • Access List Components by name:
    • emp.list = list("Id"= ID, "Names"= emp.name, "Total staff"=num.emp)
    • print(emp.list$Names)
  • Access List Components by indexing:
    • emp.list[[1]] # First component
    • emp.list[[2]][1] # First item in second component
  • Modifying List Components is possible with various indexing, naming, or indexing with missing return
  • Combine lists using c(list1, list2)

Practice MCQs : Variables, Data Types, Vectors & Lists

  • The "@" symbol is not allowed in R variable names
  • value2 is a valid R variable name
  • letters is the predefined constant for lowercase letters in R
  • Numeric is the data type of real numbers in R
  • typeof() function checks an object's data type
  • as.integer() function converts an object to an integer
  • An invalid type conversion returns NA
  • In R, a vector contains the same type of elements
  • c(1,2,3) creates a vector
  • Lists in R can store any objects

Creating, Accessing and Modifying Lists

  • list() creates a list
  • emp.list$Names accesses a named list component
  • emp.list[[1]][1] accesses the first element of the first component in a list
  • emp.list["Total staff"] = 5 modifies a list's named component
  • c(X, 10) adds a new element to an existing vector
  • c(list1, list2) concatenates two lists
  • The output of typeof("Hello") is Character
  • as.logical("text") results in NA
  • A data type that includes TRUE and FALSE is Logical

List Elements

  • Elements in a list are accessed using index or name
  • The Data Extension for a saved workspace on R is .RData
  • Rules for naming variables include letters and numbers with the variable beginning with a letter
  • Calling the typeof command allows variables to change without error
  • Character (letters, symbols) are among the basic data types in R

List Objects

  • List objects include : find data type, check specific data type, convert to another datatype
  • A vector: All elements must be of the same type. Created using the c() function.
  • Can contain different types: numbers, strings, vectors, etc.
  •  Created using list() function
    

The "@" symbol is not allowed in R variable names

  • value2 is a valid R variable name
  • letters is the predefined constant for lowercase letters in R

Numerical Functions in R

  • Numeric is the data type of real numbers in R
  • typeof() function checks an object's data type
  • as.integer() function converts an object to an integer
  • An invalid type conversion returns NA
  • In R, a vector contains the same type of elements
  • c(1,2,3) creates a vector
  • Lists in R can store any objects
  • The function typeof() can be used to check an objects data type

Factors in Data Frames

  • The "@" symbol is not allowed in R variable names
  • value2 is a valid R variable name
  • In R, a data vector contains the same type of elements created using the c() function
  • The type function can be used to check variables When working wiht lists in data frame The elements are accessed using index or name Saving a data workspace in R results in the .Rda file type

Data Frames in R (Lecture 4)

  • Data frames in R store tabular data like Excel sheets.
  • The data frame is a generic object made up of rows and columns
  • Data frames are built via variables, as are the corresponding functions:
    • read.table(file = "path/to/file", sep = " ")
    • df = data.frame(vec1, vec2, vec3)

Adding and Deleting Rows and Columns

  • Use / in file paths rather than \
  • Default separator is space
  • A number of functions exist to change and read these values appropriately:
    • df[1:2, ] accesses rows 1 and 2
    • df[, 1:2] accesses (or df[1:2]) columns 1 and 2
    • df(2,1) accesses a specific cell
  • Extract subsets with the following:
    • subset(pd, Name == "Senthil" | BS > 150)
    • df[[2]][2] = “R” (Direct assignment
  • Functions allow manual changing of the values:
    • edit(myTable)
  • Adding or deleting values happens via these functions:
    • cbind (column based)
    • rbind (row based)
  • Additional examples of deletion include:
    • Delete 3rd row and 1st column: df2 = df[-3, -1]
    • Delete column by name: df3 = df[, !names(df) %in% c("vec3")]
    • Delete rows conditionally: df4 = df[!df$vec1 == 3, ]

Factors and Data Frames

  • By default, character columns become factors, which may cause issues when editing (May result in NA)
  • The issue is solved via setting the stringsAsFactors value:
    • stringsAsFactors = FALSE

Practice MCQs: Data Frames in R

  • A data frame in R is used to store tabular data
  • The data.frame() function creates a data frame
  • The default separator in read.table() is a space
  • df[1:2,] accesses rows 1 and 2
  • A data frame is accessed using Columns 1 and 2
  • subset() is used to extract data conditionally
  • edit() can be used to edit data manually
  • New rows are added to a data frame via rbind()
  • Columns are added to a data frame with cbind() df[-3,-1] results code to delete the 3rd row and 1st column
  • !names(df) %in% c("vec3") deletes column vec3
  • In R factor refers to categorical data
  • By default, character columns in a data frame become factors

Adding Elements and Functions

  • stringsAsFactors = FALSE prevents characters from becoming factors
  • df[[2]][5] = "new" appends a new element to column 2
  • cbind functions create a matrix not a data frame
  • df$vec2 references print the first column using a name
  • Factor levels mismatch causes NA when editing data frames
  • Correct code for the read data set function is read.table(file, sep="\t")
  • print() correctly prints a data set

Re-Casting and Joining Data Frames in R

  • Re-casting is reshaping or manipulating a data frame structure
  • Recasting helps in getting new insights from data
  • A two-step process, or one-step alternative can be chosen; melt to cast, recast()

Wide and Long Data

  • Functions like melt() convert wide data to long data
  • Melt is part of the reshap2 library and uses three variables:
    • id.vars (columns to stay as is: identifiers)
    • measure.vars (columns to reshare: measurements)
  • Convert long data back to wide format, dcast(Df, variable + Month ~ Name, value.var = "value") . Functions:
  • dcast() → Reshape melted data
  • Formula: new format ~ old identifiers
  • value.var → Column holding data values
  • Together they offer Melt & Cast, recast(data, formula, id.var, measure.var) being the full expression here- One-step reshape using both melt and cast logic

Adding and Merging Columns

  • mutate() adds new variables via the dplyr column:
  • pd2 <- mutate(pd, log_BP = log(BP)) (Adds a column log_BP, calculated from BP)
  • Join data frames by combining two data frames using a common column (id.variable).
    • The use can be expanded via the dplyr package
    • library(dplyr), joining with (dfl, df2, by = "ID")
    • Types of joins exist to manipulate the way the data combines, listed below:
    • All rows from df1 + matching rows from df2 (left_join)
    • All rows from df2 + matching rows from dfl (right_join)
    • Only rows with matching IDs in both df1 & df2 (inner_join)
    • All rows from both data frames (full_join)
    • Rows in dfl that match df2 (no columns added) (semi_join)
    • Rows in dfl that don't match df2 (anti_join)

Recasting Data

  • The command for that is known as recasting
  • Melting allows for the reshape from data being wide to long
  • Reshape2 creates the use of the melt() function in the first place
  • d.vars specifies which function to use, in this case melt().

The Mutate Function

  • The correct answer involves identifiers
  • The first joins the correct answer, or "inner joins" when referring to dataframes
  • The antithesis of that would be rows which do not match those data frames

Dataframes and Functions

  • dCast uses values for the column The functions are as follows +, -, * or /, but are known as "Arithmetic" as is the category.

Arithmetic Operations in R

  • A valid assignment in R is x <-5
  • Integer division is calculated by using %/%
  • calculating the remainder results in %%
  • Using parentheses is the way to assign order
  • Using (||) expresses logical operations

The TRUE Function

  • An answer is made true with the (====) command
  • To check the function, try isTRUE()
  • A new metric needs the application of matrix
  • Then an "identity of said" metric To collect the relevant numbers
  • Use ncol(A) And (A[-2, ]) To extract A[-2, ]
  • And a sequence Rbind()

Modifying data in Base R

  • Element-wise operations with vectors: A + B, A - B are matrix arithmetic
  • The code to perform a given function is A valid assignment in R is a * b
  • <-5Integer division and is coded via %%
  • Calculating the remainder results in %% which results in more parentheses if mixed
  • Using parentheses is the way to assing order
  • A nested group can be expressed with another grouping, (||
  • If the variables do end up true, the function to check that variable is isTRUE
  • Using matrix() is what will create those metrics

Function operations

  • ncol (A) will show the value of how many elements fit the matrix
  • And to delete column 2, one should first find a submatrix
  • Functions come from a file to load and read it If the goal is functions from a loaded file, you might prefer copy edit, or something source Functions require code to do so And source loads the files

Function File operations

  • Functions are invoked on the console and can be named "order" if so dictated
  • A value is made, after an argument is set in a missing code
  • Use Source again to edit a file that still exists
  • Functions are "a", or "set", by the first function Functions must therefore be loaded

Lazy Evaluation

  • When using functions the code should be well ordered, with all the commands labeled
  • It should use well written code, and also be properly labeled with the file name
  • Then set by ""a""

Functions in R

  • Create via the R functions, using ()'s for the file names
    • One can have several orders of argument However the functions should be of one object

Looping commands

  • One can go between commands though function(), and iterate between matrices/ arrays based on the margin
  • Or list as appropriate
  • With those well applied, a function should return the proper loop

Iterators for Loop

  • For functions, and loop commands of multi-variant code, remember mapply
  • Inline functions can be expressed Iterators are defined above and need the code labeled to be clear

Control Structures in R

  • Control structures control the flow of execution in a program and are of two main types:
    • Conditional execution (if, if-else, if-else if-else)
    • Loops (for, while, break)
  • Conditional statements are defined with an identifier. The code won't flow without the proper command and syntax
  • The "and" command dictates those flows

Creating Sequences in R

  • seq(from, to, by, length) is used in for loops to generate sequences
  • For loops can be nested and require an interator variable
  • Break exits the loop when a predetermined condition is met
  • The WHILE loop executes as long as a predetermined condition is TRUE

Control MCQs Part 1

  • The control structure to check if its in line with the current code base is the if command
  • If testing to see if it is is false, the code will skip command
  • The output will therefore be 135 The key indicator in this code is to see what the flow is checking on
  • With iterations the syntax code, like "," means it's inside the function. With ( the command will run successfully
  • A break stops and restarts the current order

Control MCQs Part 2

  • 123 is run because of it
  • Invalid means invalid due to it The code will still run
  • The if statement in the code base therefore checks for if x == 5
  • The break exits at the if statement

Creating Graphics

  • The notes provided offer some guidance on the charts you can use and how
  • These tend to require special dependencies with certain data Par(), when done right, allows for new layers of organization
  • Charts can be created with the functions and libraries, depending on the level of complexity you want

Creating Complex Visuals

  • Complex visuals often require loop codes to properly format and create You often require things to write to a specific file for those formats
  • When that happens, they will format that set of data and will show the results as intended, especially through the packages like ggplots2 This happens with a combination of the graphing features provided in the notes as well

Data MCQs part 1

  • It is important to know how to label those and what the best syntax to work with is Functions often depend on those, as the function call allows them to show, like
  • plot(y) without X axis assumes all the given commands The controls happen only for the chart point
  • The line width and plot command are also keys to changing charts

Data MCQs Part 2

Using a variety of calls allows one axis to become a label

  • The code often causes 2X four plots, and will save the code That data should be in mtcars which gives the command for those Charts do not tend to be colorful due to not having enough parameters
  • Those plotters end up not requiring many base commands

Data MCQs Part 3

To draw lines, call the par command, and also ggplot graphs call ggplot

  • A barplot() prints out the data labels Call to add a header, and add one to the label for plots
  • There is only one style for plots, call the function Call only one library on the line
  • R and RStudio are useful with setup to manage all of these commands Visit their websites and download the relevant functions
  • Studio is made better with the addition of having installed packages Functions are downloaded in a script to install the code base

R and RStudio Packages

  • Using a variety of libraries with install commands can allow these features to expand
  • It is possible to download the most stable build of R from the cran website
  • Each package tends to have a base package to run from
  • Dependencies ensure that you have the full code base and everything will run

The ggplot2 function

  • Data visualisers have their code within ggplot2 Dependencies = required packages which makes them have
  • The language itself is known as 1071 for the package's machine learnin features SQLDF will show the querries if that is the intention Data for the samples comes from "mice"

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

R - Langage de base et RStudio
22 questions

R - Langage de base et RStudio

ConstructiveTurtle1043 avatar
ConstructiveTurtle1043
Data Science with R and RStudio
14 questions
Analyse des Données avec RStudio
40 questions
Use Quizgecko on...
Browser
Browser