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)</p> Signup and view all the answers

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

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

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

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

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

    <p>rbind()</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</p> Signup and view all the answers

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

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

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

    <p>True</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()</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</p> Signup and view all the answers

    More Like This

    R Programming Basics
    5 questions
    R Programming Basics
    10 questions
    Use Quizgecko on...
    Browser
    Browser