R Programming Basics Quiz
16 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What function is used to remove all objects from the R workspace?

  • ls()
  • getwd()
  • rm() (correct)
  • setwd()

How can you load a saved workspace in R?

  • read('workspace.Rdata')
  • load('workspace.Rdata') (correct)
  • import('workspace.Rdata')
  • load.image('workspace.Rdata')

Which command is used to assign a value to a variable in R?

  • define x=1
  • x<-1
  • x=1 (correct)
  • x:=1

What is the function used to calculate the mean of a vector while ignoring NA values?

<p>mean(y, na.rm = TRUE) (C)</p> Signup and view all the answers

How can you create a subset of a dataframe based on a condition?

<p>subset(nobel, condition) (D)</p> Signup and view all the answers

What does the command 'head(nobel)' do?

<p>Displays the first few rows of the dataframe. (A)</p> Signup and view all the answers

In R, which operator is used for binding rows of matrices together?

<p>rbind() (D)</p> Signup and view all the answers

What is the output of mean(y) if y contains NA values and na.rm is set to FALSE?

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

What is the primary purpose of the function 'setwd()' in R?

<p>To change the working directory (C)</p> Signup and view all the answers

The command 'rm(list=ls(all=TRUE))' removes all objects in the current R environment.

<p>True (A)</p> Signup and view all the answers

What does the function 'mean()' do in R?

<p>Calculates the average of a numeric vector.</p> Signup and view all the answers

To import a text file in R, you would use the function 'read.table()' and specify the file name as ______.

<p>filename.csv</p> Signup and view all the answers

Match the following R functions with their primary functionality:

<p>mean() = Calculates the average of numeric values subset() = Extracts subsets of data frames based on conditions head() = Displays the first few rows of a data frame dim() = Returns the dimensions of an object</p> Signup and view all the answers

Which command is used to create a matrix by binding two vectors together vertically?

<p>rbind() (B)</p> Signup and view all the answers

How do you calculate the average age of high creativity for Nobel laureates in the late period?

<p>By using the subset and mean functions on the late_period dataframe.</p> Signup and view all the answers

The expression 'nobel_no_na = subset(nobel, subset=!is.na(duree))' filters out NAs from the 'duree' column.

<p>True (A)</p> Signup and view all the answers

Flashcards

ls()

Lists all objects in the current R environment.

rm(list=ls(all=TRUE))

Removes all objects from the R environment.

getwd()

Displays the current working directory in R.

setwd()

Changes the current working directory.

Signup and view all the flashcards

save.image()

Saves the current R workspace to a file.

Signup and view all the flashcards

load()

Loads a saved R workspace from a file.

Signup and view all the flashcards

x <- 1

Assigns the value 1 to the variable x.

Signup and view all the flashcards

class(x)

Determines the data type of a variable.

Signup and view all the flashcards

y <- c(1, 5, 4, 8)

Creates a vector named y containing the given numbers.

Signup and view all the flashcards

matrix

Two-dimensional array of data.

Signup and view all the flashcards

rbind()

Combines vectors row-wise to form a matrix.

Signup and view all the flashcards

cbind()

Combines vectors column-wise to form a matrix.

Signup and view all the flashcards

?mean

Displays help information for the mean function.

Signup and view all the flashcards

mean(y, na.rm = TRUE)

Calculates the mean of vector y, excluding missing values (NA).

Signup and view all the flashcards

read.table()

Reads data from a text file into R.

Signup and view all the flashcards

data.frame

A tabular data structure with columns of potentially different types.

Signup and view all the flashcards

dim()

Returns the dimensions (rows and columns) of a data object.

Signup and view all the flashcards

rownames()

Displays or sets row names of a data frame or matrix.

Signup and view all the flashcards

colnames()

Displays or sets column names of a data frame or matrix.

Signup and view all the flashcards

head()

Displays the first few rows of a data frame.

Signup and view all the flashcards

subset()

Creates a subset of a data frame based on specified criteria.

Signup and view all the flashcards

R workspace

Area in R where you store and manage your data and functions.

Signup and view all the flashcards

Saving a workspace in R

Saves all your data and variables into a file on your computer.

Signup and view all the flashcards

Loading a workspace

Retrieving a previously saved workspace and its data into your current R session.

Signup and view all the flashcards

Creating a vector in R

Combining multiple values into a single object.

Signup and view all the flashcards

Creating a matrix in R

A 2D array of objects.

Signup and view all the flashcards

rbind() function

Combines objects row-wise to create a matrix.

Signup and view all the flashcards

cbind() function

Combines objects column-wise to form a matrix.

Signup and view all the flashcards

mean(y, na.rm = TRUE)

Calculates the mean of a vector, excluding 'NA' values.

Signup and view all the flashcards

Data frame

A table-like data structure in R with rows and columns.

Signup and view all the flashcards

dim(nobel)

Displays the number of rows and columns of the dataframe 'nobel'.

Signup and view all the flashcards

Analyzing Dataframes

Process of extracting data and calculating values within a dataframe.

Signup and view all the flashcards

Reading text files

Importing external data into R that is organized as a text file.

Signup and view all the flashcards

Subset a dataframe

Filtering data from a dataframe based on conditions.

Signup and view all the flashcards

Calculating average lifespan

Determines the typical lifespan of a group.

Signup and view all the flashcards

Handling missing values (NA)

To address missing data points when calculating averages or perform other operations on data.

Signup and view all the flashcards

Data generation

Creating datasets with specific characteristics, often for testing or experimentation.

Signup and view all the flashcards

More Like This

R Programming Basics
5 questions
R Programming Basics
10 questions
Statistics and R Programming Basics
48 questions
Use Quizgecko on...
Browser
Browser