Yale College S&DS 2300 All Required R Functions Midterm 2

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

1/170

encourage image

There's no tags or description

Looks like no tags are added yet.

171 Terms

1
New cards

abline() - abline(…)

Purpose: Add horizontal/vertical or slope-intercept lines to an existing base plot. Syntax: abline(…). When to use: Use it to mark no change or an observed statistic. h/v set reference coordinates; a/b set y = a + bx. It changes the display only. Related: lines() connects points; segments() draws finite segments. Inputs: follow the named syntax and inspect ?abline for package-specific arguments. Example: abline(v = 0, col = 'red', lwd = 2). Related: functions in graphics and visualization.

2
New cards

abs() - abs(…)

Purpose: Return nonnegative magnitudes. Syntax: abs(…). When to use: Use it to find extreme changes regardless of direction or make a two-sided comparison. It removes sign, so retain the original statistic for direction. Inputs: follow the named syntax and inspect ?abs for package-specific arguments. Example: abs(nhcombined$improvement) > 50. Related: functions in numerical summaries and transformations.

3
New cards

aes() - aes(…)

Purpose: Create ggplot2 mappings from variables to appearance/position. Syntax: aes(…). When to use: Use it inside ggplot code. Inputs such as x/y/color map variables; settings outside aes() are fixed. It stores mappings, not a complete plot. Inputs: follow the named syntax and inspect ?aes for package-specific arguments. Example: aes(x = EnergyUse, y = CO2, color = Group). Related: functions in graphics and visualization.

4
New cards

align() - align(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: align(object, …). When to use: Use it only in the package context supplied by course code. Check ?align after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?align for package-specific arguments. Example: align(object). Related: functions in formatting and package context.

5
New cards

apply() - apply(…)

Purpose: Apply a function over rows or columns of a matrix/array. Syntax: apply(…). When to use: MARGIN = 1 means rows and 2 means columns. Use for repeated summaries of matrix-like data; mixed-type data frames need care. Inputs: follow the named syntax and inspect ?apply for package-specific arguments. Example: apply(mat, 2, mean, na.rm = TRUE). Related: functions in wrangling text and object construction.

6
New cards

as.character() - as.character(…)

Purpose: Convert values to character strings. Syntax: as.character(…). When to use: Use before gsub() or before converting a factor safely to numbers. Result is text, not numeric data. Inputs: follow the named syntax and inspect ?as.character for package-specific arguments. Example: as.character(survey$Coursework). Related: functions in wrangling text and object construction.

7
New cards

as.factor() - as.factor(…)

Purpose: Convert a vector to a categorical factor. Syntax: as.factor(…). When to use: Use when labels identify groups rather than measurements. factor() gives more control over level order. Inputs: follow the named syntax and inspect ?as.factor for package-specific arguments. Example: as.factor(group). Related: functions in wrangling text and object construction.

8
New cards

as.numeric() - as.numeric(…)

Purpose: Convert values to numbers where possible. Syntax: as.numeric(…). When to use: Invalid strings become NA with a warning. Do not apply directly to a factor unless you want its internal level codes. Inputs: follow the named syntax and inspect ?as.numeric for package-specific arguments. Example: as.numeric(gsub(',', '', as.character(x))). Related: functions in wrangling text and object construction.

9
New cards

as.vector() - as.vector(…)

Purpose: Drop dimensions/attributes to make a plain vector. Syntax: as.vector(…). When to use: Use when a table/matrix must feed a vector function. Keep labels separately because order can matter. Inputs: follow the named syntax and inspect ?as.vector for package-specific arguments. Example: as.vector(table(surveyEcon,surveyEcon, surveySocial)). Related: functions in wrangling text and object construction.

10
New cards

attach() - attach(…)

Purpose: Data import/inspection/data-frame helper. Syntax: attach(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?attach for package-specific arguments. Example: attach(object). Related: functions in import inspection and data frames.

11
New cards

barplot() - barplot(…)

Purpose: Draw bars for counts or precomputed summaries. Syntax: barplot(…). When to use: Use for categorical counts or one summary per group. Height represents supplied values; not a histogram for raw continuous data. Inputs: follow the named syntax and inspect ?barplot for package-specific arguments. Example: barplot(table(survey$Gender), col = 'skyblue'). Related: functions in graphics and visualization.

12
New cards

bold() - bold(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: bold(object, …). When to use: Use it only in the package context supplied by course code. Check ?bold after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?bold for package-specific arguments. Example: bold(object). Related: functions in formatting and package context.

13
New cards

boot() - boot(…)

Purpose: Run a package bootstrap with a supplied statistic function. Syntax: boot(…). When to use: Data are resampled; statistic receives resampled indices. Homework loops with sample(…, replace = TRUE) show the same idea transparently. Inputs: follow the named syntax and inspect ?boot for package-specific arguments. Example: boot(x, function(d, i) mean(d[i]), R = 10000). Related: functions in random distributions and simulation.

14
New cards

boxplot() - boxplot(…)

Purpose: Compare a numeric distribution or distributions by group. Syntax: boxplot(…). When to use: Read medians, IQRs, whiskers, and flagged outliers. Flagged dots merit investigation; they are not automatic deletion rules. Inputs: follow the named syntax and inspect ?boxplot for package-specific arguments. Example: boxplot(Change ~ GNI_group, data = measles). Related: functions in graphics and visualization.

15
New cards

by() - by(…)

Purpose: Apply a summary function separately by group. Syntax: by(…). When to use: Use when each group needs the same summary. Related: tapply() is a compact vector form. Inputs: follow the named syntax and inspect ?by for package-specific arguments. Example: by(measlesChange,measlesChange, measlesGNI_group, mean). Related: functions in import inspection and data frames.

16
New cards

c() - c(…)

Purpose: Combine values into one vector. Syntax: c(…). When to use: Use for requested quantile probabilities, selected names, or endpoints. R may coerce mixed inputs to one type. Inputs: follow the named syntax and inspect ?c for package-specific arguments. Example: c(.025, .975). Related: functions in wrangling text and object construction.

17
New cards

cbind() - cbind(…)

Purpose: Bind equal-length objects as columns. Syntax: cbind(…). When to use: Use carefully: matrices can coerce mixed types. data.frame() is usually safer for analysis data. Inputs: follow the named syntax and inspect ?cbind for package-specific arguments. Example: cbind(x = x, y = y). Related: functions in wrangling text and object construction.

18
New cards

cex() - cex(…)

Purpose: Base-graphics size multiplier; normally an argument, not a standalone call. Syntax: cex(…). When to use: Use to scale points/text. It changes appearance only; cex = 1 is default. Inputs: follow the named syntax and inspect ?cex for package-specific arguments. Example: plot(x, y, cex = .7, pch = 19). Related: functions in graphics and visualization.

19
New cards

chart.Correlation() - chart.Correlation(…)

Purpose: Display scatterplots, correlations, and marginal distributions for several numeric variables. Syntax: chart.Correlation(…). When to use: Use for broad exploration. It suggests association, not causation; corrplot.mixed() is a more compact matrix display. Inputs: follow the named syntax and inspect ?chart.Correlation for package-specific arguments. Example: chart.Correlation(survey2, histogram = TRUE, pch = 19). Related: functions in graphics and visualization.

20
New cards

class() - class(…)

Purpose: Report an object's class. Syntax: class(…). When to use: Use to diagnose whether data are numeric, factor, data.frame, or model objects. str() supplies more detail. Inputs: follow the named syntax and inspect ?class for package-specific arguments. Example: class(measles$GNI_group). Related: functions in import inspection and data frames.

21
New cards

coef() - coef(…)

Purpose: Extract fitted model coefficients. Syntax: coef(…). When to use: For simple regression, intercept is predicted y at x = 0 and slope is predicted change in y per x unit. Inputs: follow the named syntax and inspect ?coef for package-specific arguments. Example: coef(lm(Score ~ Hours, data = dat)). Related: functions in correlation regression and diagnostics.

22
New cards

colnames() - colnames(…)

Purpose: Get or set column names. Syntax: colnames(…). When to use: Use before merging annual measures. It renames columns, not observations; names() is more general. Inputs: follow the named syntax and inspect ?colnames for package-specific arguments. Example: colnames(wb2016) <- c('Country','Measles_16','GNI_16'). Related: functions in import inspection and data frames.

23
New cards

colors() - colors(…)

Purpose: Visualization helper. Syntax: colors(…). When to use: Use it to make a labeled graph that supports, rather than replaces, statistical reasoning. It changes/shows a display; interpret graphical patterns with units and context. Inputs: follow the named syntax and inspect ?colors for package-specific arguments. Example: colors(object). Related: functions in graphics and visualization.

24
New cards

complete.cases() - complete.cases(…)

Purpose: Identify observations with no missing values across supplied variables. Syntax: complete.cases(…). When to use: Use before correlation/bootstrap when every required variable must be observed. It returns TRUE/FALSE rows. Inputs: follow the named syntax and inspect ?complete.cases for package-specific arguments. Example: subset(wb, complete.cases(Country, EnergyUse, CO2)). Related: functions in import inspection and data frames.

25
New cards

confint() - confint(…)

Purpose: Compute confidence intervals for model parameters. Syntax: confint(…). When to use: Use after lm() for a slope/intercept interval. An interval excluding zero aligns with a two-sided significant coefficient at that level. Inputs: follow the named syntax and inspect ?confint for package-specific arguments. Example: confint(fit, 'Hours', level = .95). Related: functions in correlation regression and diagnostics.

26
New cards

cooks.distance() - cooks.distance(…)

Purpose: Compute Cook's distance for regression influence. Syntax: cooks.distance(…). When to use: Use to screen observations whose removal could change a fitted line. Large values merit investigation, not automatic deletion. Inputs: follow the named syntax and inspect ?cooks.distance for package-specific arguments. Example: cooks.distance(fit). Related: functions in correlation regression and diagnostics.

27
New cards

cooksd_bar() - cooksd_bar(…)

Purpose: Regression/correlation helper used to inspect, fit, test, or display an association/model. Syntax: cooksd_bar(…). When to use: Use it after identifying the statistical target and checking data/plot conditions. Read its returned statistic/diagnostic in context. Compare related correlation, residual, leverage, and influence tools rather than treating one number as definitive. Inputs: follow the named syntax and inspect ?cooksd_bar for package-specific arguments. Example: cooksd_bar(object). Related: functions in correlation regression and diagnostics.

28
New cards

cooksd_chart() - cooksd_chart(…)

Purpose: Regression/correlation helper used to inspect, fit, test, or display an association/model. Syntax: cooksd_chart(…). When to use: Use it after identifying the statistical target and checking data/plot conditions. Read its returned statistic/diagnostic in context. Compare related correlation, residual, leverage, and influence tools rather than treating one number as definitive. Inputs: follow the named syntax and inspect ?cooksd_chart for package-specific arguments. Example: cooksd_chart(object). Related: functions in correlation regression and diagnostics.

29
New cards

cor() - cor(…)

Purpose: Compute Pearson correlation by default. Syntax: cor(…). When to use: Use after inspecting a scatterplot for linearity/outliers. r is -1 to 1, measures linear association, and does not establish causation. Inputs: follow the named syntax and inspect ?cor for package-specific arguments. Example: cor(x, y, use = 'complete.obs'). Related: functions in correlation regression and diagnostics.

30
New cards

cor.mtest() - cor.mtest(…)

Purpose: Compute pairwise correlation-test p-values for a corrplot display. Syntax: cor.mtest(…). When to use: Use the p matrix with corrplot.mixed(). Related: cor.test() handles one pair. Inputs: follow the named syntax and inspect ?cor.mtest for package-specific arguments. Example: p.mat <- cor.mtest(survey2, conf.level = .95)$p. Related: functions in correlation regression and diagnostics.

31
New cards

cor.test() - cor.test(…)

Purpose: Test a population correlation and return r, p-value, and confidence interval. Syntax: cor.test(…). When to use: Default null is rho = 0. Interpret p/CI on the scale used; still inspect the scatterplot. Inputs: follow the named syntax and inspect ?cor.test for package-specific arguments. Example: cor.test(wb2logCO2,wb2logCO2, wb2logEnergy, conf.level = .96). Related: functions in correlation regression and diagnostics.

32
New cards

corrplot() - corrplot(…)

Purpose: Visualize a correlation matrix. Syntax: corrplot(…). When to use: Color/shape show sign and strength. The plot summarizes pairwise association, not causation. Inputs: follow the named syntax and inspect ?corrplot for package-specific arguments. Example: corrplot(corMatrix, method = 'color'). Related: functions in graphics and visualization.

33
New cards

corrplot.mixed() - corrplot.mixed(…)

Purpose: Use numbers and shapes in different triangles of a correlation plot. Syntax: corrplot.mixed(…). When to use: An X can mark a correlation not statistically distinguishable from zero when a p-value matrix is supplied. Inputs: follow the named syntax and inspect ?corrplot.mixed for package-specific arguments. Example: corrplot.mixed(corMatrix, p.mat = cor.mtest(dat)$p, sig.level = .05). Related: functions in graphics and visualization.

34
New cards

count() - count(…)

Purpose: dplyr function that counts rows by category combinations. Syntax: count(…). When to use: Returns a data frame/tibble with n. Base-R table() returns an array/table. Inputs: follow the named syntax and inspect ?count for package-specific arguments. Example: count(survey, Econ, Social). Related: functions in import inspection and data frames.

35
New cards

data.frame() - data.frame(…)

Purpose: Create a rectangular data frame from equal-length columns. Syntax: data.frame(…). When to use: Use to assemble selected variables for analysis. Unlike cbind(), it better preserves intended column types. Inputs: follow the named syntax and inspect ?data.frame for package-specific arguments. Example: data.frame(Name = ids, Change = after - before). Related: functions in import inspection and data frames.

36
New cards

data_col() - data_col(…)

Purpose: Data import/inspection/data-frame helper. Syntax: data_col(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?data_col for package-specific arguments. Example: data_col(object). Related: functions in import inspection and data frames.

37
New cards

dbinom() - dbinom(…)

Purpose: Binomial probability mass P(X = x). Syntax: dbinom(…). When to use: Inputs are successes, trials, and success probability. It returns a probability, not simulated data. Inputs: follow the named syntax and inspect ?dbinom for package-specific arguments. Example: dbinom(3, size = 10, prob = .5). Related: functions in random distributions and simulation.

38
New cards

demo() - demo(…)

Purpose: Data import/inspection/data-frame helper. Syntax: demo(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?demo for package-specific arguments. Example: demo(object). Related: functions in import inspection and data frames.

39
New cards

dexp() - dexp(…)

Purpose: Exponential density at x. Syntax: dexp(…). When to use: A density is not the probability at one exact continuous value. pexp() gives cumulative probability; rexp() simulates. Inputs: follow the named syntax and inspect ?dexp for package-specific arguments. Example: dexp(2, rate = .5). Related: functions in random distributions and simulation.

40
New cards

dim() - dim(…)

Purpose: Return rows and columns of a matrix/data frame. Syntax: dim(…). When to use: Use immediately after importing/filtering/merging. nrow() and ncol() give components separately. Inputs: follow the named syntax and inspect ?dim for package-specific arguments. Example: dim(nhcombined). Related: functions in import inspection and data frames.

41
New cards

dirname() - dirname(…)

Purpose: Data import/inspection/data-frame helper. Syntax: dirname(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?dirname for package-specific arguments. Example: dirname(object). Related: functions in import inspection and data frames.

42
New cards

dnorm() - dnorm(…)

Purpose: Normal density at x. Syntax: dnorm(…). When to use: Use only when a normal-density value is requested. pnorm(), qnorm(), and rnorm() have different jobs. Inputs: follow the named syntax and inspect ?dnorm for package-specific arguments. Example: dnorm(0, mean = 0, sd = 1). Related: functions in random distributions and simulation.

43
New cards

droplevels() - droplevels(…)

Purpose: Remove unused factor categories. Syntax: droplevels(…). When to use: Use after filtering when a plot/table still shows a removed group. It preserves values but changes available levels. Inputs: follow the named syntax and inspect ?droplevels for package-specific arguments. Example: datGroup<−droplevels(datGroup <- droplevels(datGroup). Related: functions in import inspection and data frames.

44
New cards

element_text() - element_text(…)

Purpose: Visualization helper. Syntax: element_text(…). When to use: Use it to make a labeled graph that supports, rather than replaces, statistical reasoning. It changes/shows a display; interpret graphical patterns with units and context. Inputs: follow the named syntax and inspect ?element_text for package-specific arguments. Example: element_text(object). Related: functions in graphics and visualization.

45
New cards

exp() - exp(…)

Purpose: Compute e raised to x. Syntax: exp(…). When to use: Use to back-transform a natural log. It produces positive original-scale values. Inputs: follow the named syntax and inspect ?exp for package-specific arguments. Example: exp(logEnergy). Related: functions in numerical summaries and transformations.

46
New cards

factor() - factor(…)

Purpose: Create a categorical variable with chosen levels/labels. Syntax: factor(…). When to use: Use for threshold groups before plots/tests. Level order can affect display/model reference. Inputs: follow the named syntax and inspect ?factor for package-specific arguments. Example: factor(group, levels = c('Low','High')). Related: functions in wrangling text and object construction.

47
New cards

fitted() - fitted(…)

Purpose: Extract model fitted values. Syntax: fitted(…). When to use: Use with resid() for a residual-versus-fitted plot. Values are model predictions for original observations. Inputs: follow the named syntax and inspect ?fitted for package-specific arguments. Example: fitted(fit). Related: functions in correlation regression and diagnostics.

48
New cards

flextable() - flextable(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: flextable(object, …). When to use: Use it only in the package context supplied by course code. Check ?flextable after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?flextable for package-specific arguments. Example: flextable(object). Related: functions in formatting and package context.

49
New cards

fontsize() - fontsize(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: fontsize(object, …). When to use: Use it only in the package context supplied by course code. Check ?fontsize after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?fontsize for package-specific arguments. Example: fontsize(object). Related: functions in formatting and package context.

50
New cards

for() - for(…)

Purpose: Repeat a code block over a sequence. Syntax: for(…). When to use: Initialize storage first. Use for transparent bootstrap/permutation loops; replicate() is a concise alternative. Inputs: follow the named syntax and inspect ?for for package-specific arguments. Example: for (i in 1:B) stats[i] <- mean(sample(x, length(x), replace = TRUE)). Related: functions in wrangling text and object construction.

51
New cards

function() - function(…)

Purpose: Define a reusable function. Syntax: function(…). When to use: Use when identical cleaning/plotting steps apply to several data sets. Inputs are arguments; return a clean object. Inputs: follow the named syntax and inspect ?function for package-specific arguments. Example: cleanIt <- function(x) as.numeric(gsub(',', '', as.character(x))). Related: functions in wrangling text and object construction.

52
New cards

getwd() - getwd(…)

Purpose: Data import/inspection/data-frame helper. Syntax: getwd(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?getwd for package-specific arguments. Example: getwd(object). Related: functions in import inspection and data frames.

53
New cards

grep() - grep(…)

Purpose: Find positions/strings matching a regular expression. Syntax: grep(…). When to use: Use for text/variable-name search. grepl() returns TRUE/FALSE instead. Inputs: follow the named syntax and inspect ?grep for package-specific arguments. Example: grep('Time', names(dat), value = TRUE). Related: functions in wrangling text and object construction.

54
New cards

grepl() - grepl(…)

Purpose: Test whether each string matches a pattern. Syntax: grepl(…). When to use: Use for logical filtering based on text. gsub() changes matches rather than locating them. Inputs: follow the named syntax and inspect ?grepl for package-specific arguments. Example: dat[grepl('^M', dat$Div), ]. Related: functions in wrangling text and object construction.

55
New cards

gsub() - gsub(…)

Purpose: Replace all matching text patterns. Syntax: gsub(…). When to use: Use to remove commas or standardize text before numeric conversion. It returns character data. Inputs: follow the named syntax and inspect ?gsub for package-specific arguments. Example: gsub(',', '', as.character(survey$Coursework)). Related: functions in wrangling text and object construction.

56
New cards

hatvalues() - hatvalues(…)

Purpose: Compute regression leverage values. Syntax: hatvalues(…). When to use: High leverage means unusual predictor configuration; it is not automatically influence. Pair with residual/Cook diagnostics. Inputs: follow the named syntax and inspect ?hatvalues for package-specific arguments. Example: hatvalues(fit). Related: functions in correlation regression and diagnostics.

57
New cards

head() - head(…)

Purpose: Show first observations/elements. Syntax: head(…). When to use: Use as a quick post-import/post-merge check. tail() previews the end; str() checks types. Inputs: follow the named syntax and inspect ?head for package-specific arguments. Example: head(measles, 10). Related: functions in import inspection and data frames.

58
New cards

help() - help(…)

Purpose: Data import/inspection/data-frame helper. Syntax: help(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?help for package-specific arguments. Example: help(object). Related: functions in import inspection and data frames.

59
New cards

hist() - hist(…)

Purpose: Draw a histogram for one numeric variable. Syntax: hist(…). When to use: Describe shape, center, spread, gaps, and unusual values. abline(v = 0) marks no change. Inputs: follow the named syntax and inspect ?hist for package-specific arguments. Example: hist(measles$Change, breaks = 30, col = 'steelblue'). Related: functions in graphics and visualization.

60
New cards

hms() - hms(…)

Purpose: lubridate parser for hour-minute-second durations. Syntax: hms(…). When to use: Use for H:M:S strings in the time-cleaning workflow. Divide seconds by 60 to obtain minutes; ms() is for M:S. Inputs: follow the named syntax and inspect ?hms for package-specific arguments. Example: as.numeric(hms('1:02:30')) / 60. Related: functions in formatting and package context.

61
New cards

is.na() - is.na(…)

Purpose: Identify missing values. Syntax: is.na(…). When to use: Use instead of == NA. complete.cases() checks several variables at once. Inputs: follow the named syntax and inspect ?is.na for package-specific arguments. Example: dat <- dat[!is.na(dat$Gender), ]. Related: functions in wrangling text and object construction.

62
New cards

jitter() - jitter(…)

Purpose: Add small random display noise. Syntax: jitter(…). When to use: Use to reveal overlapping ordinal points. Calculate r on original values, not jittered coordinates. Inputs: follow the named syntax and inspect ?jitter for package-specific arguments. Example: plot(jitter(Social, factor = .7), jitter(Econ, factor = .7)). Related: functions in graphics and visualization.

63
New cards

labs() - labs(…)

Purpose: Visualization helper. Syntax: labs(…). When to use: Use it to make a labeled graph that supports, rather than replaces, statistical reasoning. It changes/shows a display; interpret graphical patterns with units and context. Inputs: follow the named syntax and inspect ?labs for package-specific arguments. Example: labs(object). Related: functions in graphics and visualization.

64
New cards

las() - las(…)

Purpose: Visualization helper. Syntax: las(…). When to use: Use it to make a labeled graph that supports, rather than replaces, statistical reasoning. It changes/shows a display; interpret graphical patterns with units and context. Inputs: follow the named syntax and inspect ?las for package-specific arguments. Example: las(object). Related: functions in graphics and visualization.

65
New cards

left() - left(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: left(object, …). When to use: Use it only in the package context supplied by course code. Check ?left after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?left for package-specific arguments. Example: left(object). Related: functions in formatting and package context.

66
New cards

legend() - legend(…)

Purpose: Add a graphical key. Syntax: legend(…). When to use: Use whenever colors/lines/symbols need explanation. It does not compute anything. Inputs: follow the named syntax and inspect ?legend for package-specific arguments. Example: legend('topright', legend = c('Observed','Permuted'), col = c('blue','gray'), lwd = 2). Related: functions in graphics and visualization.

67
New cards

length() - length(…)

Purpose: Count vector/list elements. Syntax: length(…). When to use: Use for repeat-ID count or number of simulation results. nrow() counts observations in a data frame. Inputs: follow the named syntax and inspect ?length for package-specific arguments. Example: length(repeatrunners). Related: functions in import inspection and data frames.

68
New cards

levels() - levels(…)

Purpose: Get or set factor categories. Syntax: levels(…). When to use: Use to check group labels/order. droplevels() removes unused categories. Inputs: follow the named syntax and inspect ?levels for package-specific arguments. Example: levels(measles$GNI_group). Related: functions in import inspection and data frames.

69
New cards

library() - library(…)

Purpose: Attach an installed package. Syntax: library(…). When to use: Use before package functions such as ms(), hms(), corrplot.mixed(), or chart.Correlation(). Package masking can matter. Inputs: follow the named syntax and inspect ?library for package-specific arguments. Example: library(lubridate). Related: functions in import inspection and data frames.

70
New cards

lines() - lines(…)

Purpose: Add connected coordinates to a base plot. Syntax: lines(…). When to use: Use for curves/fitted values. abline() is better for straight reference lines. Inputs: follow the named syntax and inspect ?lines for package-specific arguments. Example: lines(sort(x), fitted_y[order(x)], col = 'red'). Related: functions in graphics and visualization.

71
New cards

list() - list(…)

Purpose: Create a container for mixed objects. Syntax: list(…). When to use: Use to store related results. Extract named pieces with $. Inputs: follow the named syntax and inspect ?list for package-specific arguments. Example: list(ci = ci_r, test = cor1test). Related: functions in import inspection and data frames.

72
New cards

lm() - lm(…)

Purpose: Fit a least-squares linear regression. Syntax: lm(…). When to use: Use for numeric response/predictor modeling after considering linear-model conditions. summary(fit) gives p-values/R-squared. Inputs: follow the named syntax and inspect ?lm for package-specific arguments. Example: fit <- lm(Y ~ X, data = dat). Related: functions in correlation regression and diagnostics.

73
New cards

log() - log(…)

Purpose: Natural-log transform positive values. Syntax: log(…). When to use: Use to compress right skew and possibly regularize a multiplicative/curved relationship. Cannot accept zero/negative values. Inputs: follow the named syntax and inspect ?log for package-specific arguments. Example: wb2logCO2<−log(wb2logCO2 <- log(wb2CO2). Related: functions in numerical summaries and transformations.

74
New cards

log10() - log10(…)

Purpose: Base-10 logarithm. Syntax: log10(…). When to use: A one-unit increase represents a factor of 10. Homework used natural log() instead. Inputs: follow the named syntax and inspect ?log10 for package-specific arguments. Example: log10(c(1, 10, 100)). Related: functions in numerical summaries and transformations.

75
New cards

logical() - logical(…)

Purpose: Data manipulation/text/object helper. Syntax: logical(…). When to use: Use it to clean, restructure, or construct objects; inspect output type with str() before further analysis. It changes/returns data structure rather than testing a statistical hypothesis. Inputs: follow the named syntax and inspect ?logical for package-specific arguments. Example: logical(object). Related: functions in wrangling text and object construction.

76
New cards

logit() - logit(…)

Purpose: Numerical summary/transformation helper. Syntax: logit(…). When to use: Use it only after checking units, missingness, and whether a robust or transformed scale is appropriate. Interpret in original/transform units and compare with complementary summaries/plots. Inputs: follow the named syntax and inspect ?logit for package-specific arguments. Example: logit(object). Related: functions in numerical summaries and transformations.

77
New cards

ls() - ls(…)

Purpose: Data import/inspection/data-frame helper. Syntax: ls(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?ls for package-specific arguments. Example: ls(object). Related: functions in import inspection and data frames.

78
New cards

matrix() - matrix(…)

Purpose: Data manipulation/text/object helper. Syntax: matrix(…). When to use: Use it to clean, restructure, or construct objects; inspect output type with str() before further analysis. It changes/returns data structure rather than testing a statistical hypothesis. Inputs: follow the named syntax and inspect ?matrix for package-specific arguments. Example: matrix(object). Related: functions in wrangling text and object construction.

79
New cards

max() - max(…)

Purpose: Return largest value. Syntax: max(…). When to use: Use to inspect an upper extreme/limit. Investigate extreme values rather than deleting automatically. Inputs: follow the named syntax and inspect ?max for package-specific arguments. Example: max(x, na.rm = TRUE). Related: functions in numerical summaries and transformations.

80
New cards

mean() - mean(…)

Purpose: Compute arithmetic average. Syntax: mean(…). When to use: Use as bootstrap statistic when asked for a mean. Sensitive to extremes; mean sign does not prove a majority. Inputs: follow the named syntax and inspect ?mean for package-specific arguments. Example: mean(sample(lowGNI, length(lowGNI), replace = TRUE)). Related: functions in numerical summaries and transformations.

81
New cards

median() - median(…)

Purpose: Compute middle value. Syntax: median(…). When to use: Use for robust center or median-difference permutation statistic. Less affected by extremes than mean. Inputs: follow the named syntax and inspect ?median for package-specific arguments. Example: median(highGNI) - median(lowGNI). Related: functions in numerical summaries and transformations.

82
New cards

min() - min(…)

Purpose: Return smallest value. Syntax: min(…). When to use: Use to inspect lower extreme. range() returns min/max together. Inputs: follow the named syntax and inspect ?min for package-specific arguments. Example: min(x, na.rm = TRUE). Related: functions in numerical summaries and transformations.

83
New cards

mosaicplot() - mosaicplot(…)

Purpose: Visualize a contingency table with tile areas proportional to counts. Syntax: mosaicplot(…). When to use: Use for two categorical/discrete variables. table() provides underlying counts. Inputs: follow the named syntax and inspect ?mosaicplot for package-specific arguments. Example: mosaicplot(~ Econ + Social, data = survey). Related: functions in graphics and visualization.

84
New cards

ms() - ms(…)

Purpose: lubridate parser for minute-second durations. Syntax: ms(…). When to use: Use for M:S race times. hms() handles H:M:S; inspect malformed strings first. Inputs: follow the named syntax and inspect ?ms for package-specific arguments. Example: as.numeric(ms('15:16')) / 60. Related: functions in formatting and package context.

85
New cards

mtext() - mtext(…)

Purpose: Add text in a plot margin. Syntax: mtext(…). When to use: Use for correlation/p-value annotation without covering points. text() uses data coordinates. Inputs: follow the named syntax and inspect ?mtext for package-specific arguments. Example: mtext(paste('r =', round(r, 3)), side = 3). Related: functions in graphics and visualization.

86
New cards

n() - n(…)

Purpose: Data import/inspection/data-frame helper. Syntax: n(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?n for package-specific arguments. Example: n(object). Related: functions in import inspection and data frames.

87
New cards

na.omit() - na.omit(…)

Purpose: Remove observations with missing values. Syntax: na.omit(…). When to use: Use only after checking what is removed. complete.cases() gives controlled filtering. Inputs: follow the named syntax and inspect ?na.omit for package-specific arguments. Example: clean <- na.omit(dat[, c('EnergyUse','CO2')]). Related: functions in import inspection and data frames.

88
New cards

names() - names(…)

Purpose: Data import/inspection/data-frame helper. Syntax: names(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?names for package-specific arguments. Example: names(object). Related: functions in import inspection and data frames.

89
New cards

nchar() - nchar(…)

Purpose: Count characters in strings. Syntax: nchar(…). When to use: Use to route inconsistent time formats. substr() extracts pieces. Inputs: follow the named syntax and inspect ?nchar for package-specific arguments. Example: nchar(c('15:16','1:02:30')). Related: functions in numerical summaries and transformations.

90
New cards

ncol() - ncol(…)

Purpose: Data import/inspection/data-frame helper. Syntax: ncol(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?ncol for package-specific arguments. Example: ncol(object). Related: functions in import inspection and data frames.

91
New cards

nrow() - nrow(…)

Purpose: Data import/inspection/data-frame helper. Syntax: nrow(…). When to use: Use it to understand structure or safely prepare data before an analysis. Verify rows, columns, types, and missingness after it runs. Inputs: follow the named syntax and inspect ?nrow for package-specific arguments. Example: nrow(object). Related: functions in import inspection and data frames.

92
New cards

num() - num(object, …)

Purpose: Course-sheet formatting/package-context entry; exact arguments depend on the package/code that defines it. Syntax: num(object, …). When to use: Use it only in the package context supplied by course code. Check ?num after loading the package; it is not a core statistical method. Interpret output as formatting/helper behavior, not a statistical conclusion. Inputs: follow the named syntax and inspect ?num for package-specific arguments. Example: num(object). Related: functions in formatting and package context.

93
New cards

numeric() - numeric(…)

Purpose: Create a numeric vector of zeros. Syntax: numeric(…). When to use: Use for preallocation when zeros are safe initial values. rep(NA, B) makes missing placeholders. Inputs: follow the named syntax and inspect ?numeric for package-specific arguments. Example: stats <- numeric(10000). Related: functions in numerical summaries and transformations.

94
New cards

options() - options(…)

Purpose: Numerical summary/transformation helper. Syntax: options(…). When to use: Use it only after checking units, missingness, and whether a robust or transformed scale is appropriate. Interpret in original/transform units and compare with complementary summaries/plots. Inputs: follow the named syntax and inspect ?options for package-specific arguments. Example: options(object). Related: functions in numerical summaries and transformations.

95
New cards

par() - par(…)

Purpose: Set/query base-graphics settings. Syntax: par(…). When to use: Use for panel layouts, then reset. Settings persist for later plots. Inputs: follow the named syntax and inspect ?par for package-specific arguments. Example: par(mfrow = c(1, 2)); par(mfrow = c(1, 1)). Related: functions in graphics and visualization.

96
New cards

paste() - paste(…)

Purpose: Concatenate text with a separator. Syntax: paste(…). When to use: Use for readable labels. paste0() uses no separator by default. Inputs: follow the named syntax and inspect ?paste for package-specific arguments. Example: paste('Sample correlation =', round(r, 3)). Related: functions in wrangling text and object construction.

97
New cards

paste0() - paste0(…)

Purpose: Concatenate text without a default separator. Syntax: paste0(…). When to use: Use for compact labels/regex. paste() is more readable for phrases. Inputs: follow the named syntax and inspect ?paste0 for package-specific arguments. Example: paste0('Measles_', c('16','24')). Related: functions in wrangling text and object construction.

98
New cards

permCor() - permCor(…)

Purpose: Course permutation test for correlation. Syntax: permCor(…). When to use: Shuffle y relative to x, calculate null r values, and compare |null r| to |observed r|. It tests association, not causation. Inputs: follow the named syntax and inspect ?permCor for package-specific arguments. Example: permCor(x, y, n_samp = 10000, plotit = TRUE). Related: functions in correlation regression and diagnostics.

99
New cards

pexp() - pexp(…)

Purpose: Exponential cumulative probability. Syntax: pexp(…). When to use: Returns P(X <= 2). dexp() is density; rexp() simulates. Inputs: follow the named syntax and inspect ?pexp for package-specific arguments. Example: pexp(2, rate = .5). Related: functions in random distributions and simulation.

100
New cards

plot() - plot(…)

Purpose: Generic base-R plotting function; two numeric vectors make a scatterplot. Syntax: plot(…). When to use: Use first for form/direction/outliers before correlation. Hist() is for one numeric variable. Inputs: follow the named syntax and inspect ?plot for package-specific arguments. Example: plot(EnergyUse, CO2, pch = 19). Related: functions in graphics and visualization.