Intermediate R - Part 2

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:20 PM on 7/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

44 Terms

1
New cards

FRONT

BACK

2
New cards

How would you code the format function for a date or a POSIXct?

format(date/datetime, format = “”)

3
New cards

FIRST PASS

FIRST PASS

4
New cards

SECOND PASS

SECOND PASS

5
New cards

What function allows you to look at your loaded packages?

search()

6
New cards

What function returns a boolean vector for elements that meet a certain pattern in a dataset? What are its basic arguments?

grepl()

grepl(pattern = “string“, x = dataset)

7
New cards

What function allows you to exchange a part of elements in a dataset that matches a particular pattern with specified data? What are it’s basic arguments?

sub()

sub(pattern = ““, replacement = ““, x = dataset)

8
New cards

What function allows you to exchange multiple parts of elements in a dataset that match a particular pattern with specified data? What are it’s basic arguments?

gsub()

gsub(pattern = ““, replacement = ““, x = dataset)

9
New cards

What function applies another function of your choosing to a set of variables and then returns a result with the format of your choosing?

vapply()

10
New cards

What function tells you the date?

Sys.Date()

11
New cards

What function allows you to install a package?

install.packages()

12
New cards

What two functions allow you to load a package, and what is the main difference between them?

library() and require()

library() throws an error whereas require() gives a warning

13
New cards

What function allows you to create a series of numbers with a pattern, that ranges from one number to another number? What are the basic arguments for this function?

seq()

seq(num1, num2, by = numRule)

14
New cards

What function repeats specified code execution a specified number of times? What are the basic arguments for this function?

rep()

rep(code, times = num)

15
New cards

There is a similar set of functions for checking if your variable is the desired data type. What is the version of this function for a list?

is.list()

16
New cards

There is a similar set of functions for creating a temporary conversion of your variable to the desired data type. What is the version of this function for a list?

as.list

17
New cards

What function returns a vector of indices for elements that meet a certain pattern in a dataset? What are its basic arguments?

grep()

grep(pattern = “string“, x = dataset

18
New cards

Which function returns the TRUE indices for a boolean vector?

which()

19
New cards

What function gives you the date and time?

Sys.time()

20
New cards

What is the basic template for coding your own functions?

name <- function(argnames) {

}

21
New cards

What is the .GlobalEnv package?

User defined objects and functions

22
New cards

What function applies another function of your choosing to a set of variables?

lapply()

23
New cards

What function converts a list to a vector?

unlist()

24
New cards

What is the basic template for coding an anonymous function?

function(x) { code }

25
New cards

Can you use $ for vectors?

No

26
New cards

What function applies another function of your choosing to a set of variables and then simplifies the result?

sapply()

27
New cards

What function checks if two things are exactly the same?

identical()

28
New cards

Can you have functions without braces?

Yes, if there is only one line of code

29
New cards

What’s the difference between the order and the sort function?

Both sort low to high, order returns the placement of those values in the original array whereas sort returns the actual values

30
New cards

What function strips away the the class of a variable, leaving only the raw data?

unclass()

31
New cards

What are the object types of dates and datetimes? Also, what does the datetime acronym stand for?

Dates: Date

Datetimes: POSIXct

Portable Operating System Interface Calendar Time

32
New cards

What is the function for creating and possibly printing a differently formatted version of a date or datetime?

format()

33
New cards

What function gives you documentation for a function? What code gives you documentation for a function?

help()

or

?functionname

34
New cards

What function tells you the default arguments of another function?

args()

35
New cards

What function is used to have your function return a value?

return()

36
New cards

What will a function return if you don’t use the return function?

The last expression evaluated in the function

37
New cards

Is null lowercase or caps?

Caps

38
New cards

What happens when you tell vapply() to return one format, but it receives incompatible data?

vapply() throws an error

39
New cards

What function reverses elements in an object?

rev()

40
New cards

What’s the easiest way to combine two vectors?

c(v1, v2)

41
New cards

What happens if you add a number to a date?

The date increases by that number of days

42
New cards

What happens if you subtract one date from another date?

You get the number of days between the two dates

43
New cards

If dates are measured in days, what are date and times measured in?

Seconds

44
New cards

What function generates a vector of the differences between adjacent elements in a numerical vector?

diff()