Week 2 – Programming using RStudio

data analysis with r programming weekly challenge 2

1. A data analyst is assigning a variable to a value in their company’s sales dataset for 2020. Which variable name uses the correct syntax?

  • -sales-2020
  • 2020_sales
  • sales_2020
  • _2020sales

 

2. You want to create a vector with the values 12, 23, 51, in that exact order. After specifying the variable, what R code chunk allows you to create the vector?

  • c(12, 23, 51)
  • v(12, 23, 51)
  • c(51, 23, 12)
  • v(51, 23, 12)

3. An analyst runs code to convert string data into a date/time data type that results in the following: “2020-07-10”. Which of the following are examples of code that would lead to this return? Select all that apply.

  • mdy(“July 10th, 2020”)
  • ymd(20200710)
  • myd(2020, July 10)
  • dmy(“7-10-2020”)

4. A data analyst inputs the following code in RStudio:

change_1 <- 70

Which of the following types of operators does the analyst use in the code?

  • Assignment
  • Logical
  • Relational
  • Arithmetic

 

5. A data analyst is deciding on naming conventions for an analysis that they are beginning in R. Which of the following rules are widely accepted stylistic conventions that the analyst should use when naming variables? Select all that apply.

  • Use single letters, such as “x” to name all variables
  • Use an underscore to separate words within a variable name
  • Begin all variable names with an underscore
  • Use all lowercase letters in variable names

 

6. In R, what includes reusable functions and documentation about how to use the functions?

  • Pipes
  • Comments
  • Packages
  • Vectors

7. Packages installed in RStudio are called from CRAN. CRAN is an online archive with R packages and other R-related resources.

  • True
  • False

8. A data analyst is reviewing some code and finds the following code chunk:

mtcars %>%
filter(carb > 1) %>%
group_by(cyl) %>%

What is this code chunk an example of?

  • Pipe
  • Nested function
  • Vector
  • Data frame

Shuffle Q/A 1

9. A data analyst finds the code mdy(10211020) in an R script. What is the year of the date that is created?

  • 1021
  • 1020
  • 1102
  • 2120

10. Which of the following is a best practice when naming R script files?

  • R script file names should end in “.R”
  • R script file names should end in “.S”
  • R script file names should end in “.rscript”
  • R script file names should end in “.r-script”

Devendra Kumar

Project Management Apprentice at Google

Leave a Reply