SDS 230 Funcs

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

1/233

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 12:01 AM on 2/5/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

234 Terms

1
New cards

Assignment operator that stores the value on the right into an object on the left.

2
New cards

=

Assignment operator that can also store values, but is often used for naming function arguments.

3
New cards

+

Adds numbers or adds corresponding elements of vectors.

4
New cards

-

Subtracts numbers or subtracts corresponding elements of vectors.

5
New cards

/

Divides numbers or divides corresponding elements of vectors.

6
New cards

*

Multiplies numbers or multiplies corresponding elements of vectors.

7
New cards

^

Raises values to a power.

8
New cards

:

Creates a sequence of integers from one value to another.

9
New cards

&

Logical AND operator; both conditions must be TRUE.

10
New cards

|

Logical OR operator; at least one condition must be TRUE.

11
New cards

==

Tests whether two values are equal.

12
New cards

#

Begins a comment; everything after # on the line is ignored by R.

13
New cards

()

Parentheses used to call a function and pass arguments.

14
New cards

[]

Single brackets used to subset vectors, matrices, or data frames.

15
New cards

[[]]

Double brackets used to extract an element from a list itself (not as a list).

16
New cards

$

Accesses a named column (sub-object) inside a data frame or list.

17
New cards

ls()

Lists all objects currently in the workspace.

18
New cards

rm(x)

Removes the object x from the workspace.

19
New cards

names(x)

Returns the names of sub-objects (such as columns in a data frame).

20
New cards

runif(n)

Generates n random numbers from a uniform distribution between 0 and 1.

21
New cards

runif(n, min, max)

Generates n random numbers uniformly between min and max.

22
New cards

sample(x, size)

Randomly samples values from x without replacement.

23
New cards

sample(x, size, replace=TRUE)

Randomly samples values from x with replacement.

24
New cards

c(…)

Creates a vector by concatenating values.

25
New cards

xvec[i]

Returns the i-th element of a vector.

26
New cards

xvec[c(1,3,5)]

Returns selected elements of a vector.

27
New cards

xvec[1:3]

Returns elements 1 through 3 of a vector.

28
New cards

list(…)

Creates a list that can contain mixed data types.

29
New cards

list1[[i]]

Returns the i-th element of a list itself.

30
New cards

list1[i]

Returns the i-th element of a list as a list.

31
New cards

list1[[i]][j]

Returns the j-th element of the vector stored at position i in a list.

32
New cards

matrix(x, nrow)

Creates a matrix with specified number of rows.

33
New cards

matrix(x, ncol)

Creates a matrix with specified number of columns.

34
New cards

matrix(x, byrow=TRUE)

Fills matrix row by row instead of column by column.

35
New cards

cbind(x, y)

Binds vectors x and y together as columns in a matrix.

36
New cards

t(x)

Flips a matrix over its diagonal so rows become columns and columns become rows.

37
New cards

xmat[i, j]

Returns element in row i and column j of a matrix.

38
New cards

xmat[, j]

Returns all rows of column j.

39
New cards

xmat[i, ]

Returns all columns of row i.

40
New cards

data.frame(…)

Creates a data frame that can hold mixed data types.

41
New cards

df[i, j]

Returns value at row i and column j of a data frame.

42
New cards

df[, j]

Returns column j of a data frame.

43
New cards

df[i, ]

Returns row i of a data frame.

44
New cards

df$var

Returns the column named var from a data frame.

45
New cards

read.csv(file, header=TRUE)

Reads a CSV file into a data frame.

46
New cards

head(df)

Displays the first few rows of a data frame.

47
New cards

dim(df)

Returns the number of rows and columns in a data frame.

48
New cards

str(df)

Displays the structure of a data frame and variable types.

49
New cards

df[df$var < x, ]

Returns rows where variable var is less than x.

50
New cards

is.na(x)

Tests whether values are NA.

51
New cards

is.na(x) == F

Tests whether values are not NA.

52
New cards

sqrt(x)

Takes the square root of each element of x.

53
New cards

exp(x)

Exponentiates each element of x.

54
New cards

sort(x)

Sorts values from smallest to largest.

55
New cards

sort(x, decreasing=TRUE)

Sorts values from largest to smallest.

56
New cards

plot(x, y)

Creates a scatterplot of y versus x.

57
New cards

plot(…, xlab, ylab, main)

Adds axis labels and a title to a plot.

58
New cards

plot(…, col, pch)

Changes color and plotting symbol.

59
New cards

boxplot(x)

Creates a boxplot of x.

60
New cards

hist(x)

Creates a histogram of x.

61
New cards

lm(formula, data)

Fits a linear regression model.

62
New cards

summary(model)

Displays summary statistics for a fitted model.

63
New cards

model$fitted.values

Returns predicted values from a regression model.

64
New cards

include = FALSE (chunk option)

Runs the chunk but hides both the code and its output in the knitted document.

65
New cards

echo = FALSE (chunk option)

Hides the code but shows the results in the knitted document.

66
New cards

eval = FALSE (chunk option)

Shows the code in the document but does not run it.

67
New cards

message = FALSE (chunk option)

Hides messages produced by code in the knitted document.

68
New cards

warning = FALSE (chunk option)

Hides warnings produced by code in the knitted document.

69
New cards

fig.cap = "…" (chunk option)

Adds a caption to a figure produced by a chunk.

70
New cards

fig.height (chunk option)

Sets figure height in the knitted document.

71
New cards

fig.width (chunk option)

Sets figure width in the knitted document.

72
New cards

x[x < -3]

Subsets x to values less than -3.

73
New cards

x[x<-3]

Assigns 3 to x (because <- is assignment), then subsets using the result; can unexpectedly overwrite x.

74
New cards

x[y<-3]

Assigns 3 to y, then uses that value as an index into x; x is unchanged.

75
New cards

x[1, ]

Subsets a matrix/data frame: row 1, all columns.

76
New cards

y[ ,1]

Subsets a matrix/data frame: all rows, column 1 (spacing shown around comma).

77
New cards

dim(x)

Returns dimensions of a matrix or data frame (number of rows and columns).

78
New cards

length(x)

Returns the length of a vector or list.

79
New cards

str(x)

Shows the structure of an object, including data types of its components.

80
New cards

typeof(x)

Returns the underlying type of an object (example used on a single-element list).

81
New cards

na.omit(x)

Removes missing values (NA) from the result.

82
New cards

subset(x, condition)

Returns subset meeting a condition; notes say it handles missing values automatically.

83
New cards

grepl(pattern, x)

Searches for a pattern within text values and returns TRUE/FALSE matches.

84
New cards

head(x)

Shows the first few rows/elements of an object (used for a dataset or a variable).

85
New cards

tail(x, n=)

Shows the last n rows/elements of an object.

86
New cards

levels(x)

Shows distinct levels of a factor (categorical variable).

87
New cards

as.numeric(x)

Converts an object to numeric; used to reveal stored numeric codes of a factor.

88
New cards

as.character(x)

Converts an object to character values (text).

89
New cards

$ (data frame)

Accesses a column (sub-object) by name in a data frame (e.g., titanic$pclass).

90
New cards

newcol creation via $<-

Creates a new column in a data frame by assigning to a new name (e.g., titanic$pclassChar <- …).

91
New cards

TRUE

Logical value used for binary (logical) type.

92
New cards

factor("a")

Creates a factor, R's encoding for categorical variables.

93
New cards

table(x)

Creates a frequency table of counts for values of x.

94
New cards

table(x, y)

Creates a contingency table (cross-tabulation) for two variables.

95
New cards

summary(x)

Summarizes an object; notes say it behaves differently depending on the variable/class.

96
New cards

as.factor(x)

Converts a variable to a factor.

97
New cards

levels(x) <- c(…)

Relabels the levels of a factor (used to rename 0/1 to "Died"/"Survived").

98
New cards

paste(…)

Combines pieces of text/numbers into one character string/vector.

99
New cards

sep="" (paste argument)

Removes the default spaces between pasted items.

100
New cards

round(x, digits)

Rounds numbers to a specified number of decimal places.