Introduction to R - Part 2 (COMPLETE)

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/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:27 AM on 7/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

34 Terms

1
New cards

FRONT

BACK

2
New cards

FIRST PASS

FIRST PASS

3
New cards

SECOND PASS

SECOND PASS

4
New cards

What are the arguments for data frames and what do they do?

Data frames have six arguments:

  1. The data

  2. row.names

  3. check.rows: Fixes rare instances where rows can have inconsistent lengths or faulty names without producing an error

  4. check.names: Corrects column names if they are incompatible or duplicates

  5. fix.empty.names: Gives columns with no names a name

  6. stringsAsFactors: Whether to autoconvert character vectors to factors

5
New cards

How do you change the levels of a factor?

levels(factor) <- c(x)

6
New cards

What are the arguments for factors and what do they do?

There are 6 arguments:

  1. x - the data

  2. levels - buckets to match the data to

  3. labels - relabels the buckets from the data names

  4. exclude - what data you want to exclude, (makes them NA)

  5. ordered - (whether or not the levels are hierarchical)

  6. nmax - (maximum number of levels)

7
New cards

What’s the difference between the str() and summary() function?

str() tells you about what’s inside the object, summary() gives you statistical information about the object

8
New cards

What are the two ways you can select list elements other than through numbers?

There are two ways. First through double brackets with the label. Second with a dollar sign.

Ex1: list[[“label”]]

Ex2: list$label

9
New cards

What function allows you to select rows from a dataframe that meet a specific column condition? What are its arguments?

subset(dataframe, condition)

10
New cards

What is a factor?

A statistical data type used to store categorical variables

11
New cards

How do you create a factor?

x <- factor(vector)

12
New cards

How do you get the levels of a factor?

levels(factor)

13
New cards

How are factor levels automatically ordered if you don’t specify them?

Alphabetically

14
New cards

What function gives you a statistical overview of the contents of an object/variable?

summary()

15
New cards

What happens if you try to compare unordered factors?

You get a warning

16
New cards

Are factors unordered or ordered by default?

Unordered

17
New cards

Do factors order from least to greatest, or greatest to least?

Least to greatest

18
New cards

How do you access a specific cell from a factor?

factor[x]

19
New cards

What is the function to create a data frame?

data.frame()

20
New cards

What is the main difference between a matrix and a data frame?

Data frames can contain many different types of data at the same time, where matrices only contain data of the same type

21
New cards

What functions print the first 6 and last 6 lines of data from a data frame or matrix?

head() and tail()

22
New cards

What function shows you the structure of an object?

str()

23
New cards

Can data frames have identical row names?

Not usually

24
New cards

What is a good way to remember how you select data frame elements?

Same as matrix selection

25
New cards

Are there any ways you can select data frame elements other than through numbers? If so, provide an example.

Yes, you can select them through the labels of the rows or columns.

Ex: matrix[1, “label”]

26
New cards

How can you select all of the elements of a column in a dataframe without using brackets?

dataframe$columnname

27
New cards

What happens if you pass a boolean vector as one of the bracket arguments of a dataframe?

You return a dataframe with only the elements in that row or column that are true

28
New cards

What function sorts data from least to greatest?

order()

29
New cards

What function is like a vector, but can carry different variable types?

list()

30
New cards

How do you name a list’s rows while initializing them?

list(name1 = x, name2 = y)

31
New cards

Can you name vectors?

Yes

32
New cards

What’s the difference between single brackets and double brackets for lists?

The single bracket returns the container (a list), the double bracket returns the actual element inside the container

33
New cards

How do you select a specific element FROM a specific element, from a list?

list[[x]][y]

34
New cards

Why don’t dataframes have an argument for the column names?

The labels of the data used to create the dataframe become the column names automatically