R Code Module 1

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

1/114

encourage image

There's no tags or description

Looks like no tags are added yet.

115 Terms

1
New cards
Data frames
The most important data structure for data analysis in R within the file 1B
2
New cards
Rows
Observations such as samples or experiments
3
New cards
Columns
Variables such as measurements or categories
4
New cards
Mixed data types
A property of data frames where each column can contain different types of data
5
New cards
data.frame()
A function used to combine vectors into a new data frame
6
New cards
cbind()
A function used to combine or add columns to a data frame
7
New cards
rbind()
A function used to combine or add rows to a data frame
8
New cards
str()
A function used to check the structure and data types of a data frame
9
New cards
dim()
A function that returns the dimensions, specifically the rows and columns, of a data frame
10
New cards
nrow()
A function that returns the number of rows in a data frame
11
New cards
ncol()
A function that returns the number of columns in a data frame
12
New cards
colnames()
A function used to check or rename the column names of a data frame
13
New cards
rownames()
A function that returns the row names of a data frame, which are usually numbers
14
New cards
$
An operator used to access elements or add new columns by their specific name
15
New cards
[row, column]
An operator used to access data frame elements by their position
16
New cards
[condition, ]
An indexing format used with logical conditions to filter and access specific rows
17
New cards
subset()
A function that provides cleaner syntax to filter data frames based on conditions and create subsets
18
New cards
which()
A function used to find row positions based on a specific condition
19
New cards
ifelse()
A function used to add categorical columns or generate conditional values
20
New cards
NULL
A value assigned to a column to remove it completely from a data frame
21
New cards
names()
A function used to rename columns
22
New cards
order()
A function used to get sorting indices in order to sort data frames by single or multiple columns
23
New cards
decreasing = TRUE
An argument used within sorting functions to specify descending order
24
New cards
head()
A function used to preview the first few rows of a data frame
25
New cards
tail()
A function used to preview the last few rows of a data frame
26
New cards
which.min()
A function used to find the row containing the minimum value
27
New cards
which.max()
A function used to find the row containing the maximum value
28
New cards
summary()
A function used to obtain comprehensive statistical summaries for data frame columns
29
New cards
table()
A function used to count categorical data or perform cross
30
New cards
sapply()
A function used to apply functions across multiple numeric columns simultaneously
31
New cards
aggregate()
A function used to calculate summary statistics, such as the mean, by a specific group
32
New cards
save.image()
A function used to save the R workspace to preserve all created objects
33
New cards
is.na()
A function used to check for missing values within a data frame or column
34
New cards
na.rm
An argument used within functions (such as mean or sd) to specify whether missing values should be removed or ignored prior to calculation
35
New cards
Vector
The most fundamental data structure in R that stores a sequence of elements of the same type, such as numeric, character, or logical elements
36
New cards
1
based indexing
37
New cards
c()
A function used to combine individual values and different types into a vector
38
New cards
seq()
A function used to create sequences of numbers with specific patterns, steps, or lengths
39
New cards
rep()
A function used to repeat specific values or a sequence
40
New cards
:
An operator used to generate simple integer sequences
41
New cards
Quotes ("")
Formatting used to define character values
42
New cards
TRUE/FALSE
Keywords used to define logical values
43
New cards
>
A comparison operator used to create logical vectors
44
New cards
*
An arithmetic operator used for element
45
New cards
log()
A function that calculates the natural logarithm of each value in a vector
46
New cards
length()
A summary function that counts the total number of elements present in a vector
47
New cards
sum()
A summary function that calculates the total sum of all values in a vector
48
New cards
mean()
A summary function that calculates the average value of a vector
49
New cards
median()
A summary function that determines the median value of a vector
50
New cards
sd()
A summary function that calculates the standard deviation of a vector
51
New cards
sort()
A function used to arrange values in ascending order, or descending order when using the decreasing = TRUE parameter
52
New cards
unique()
A function used to remove duplicates and find distinct values within a vector
53
New cards
which()
A function used to find the index positions of elements that meet a specific logical condition
54
New cards
rev()
A function used to reverse the order of elements in a vector
55
New cards
prod()
A function used to calculate the product of all values in a vector
56
New cards
which.max()
A function used to find the specific index position of the maximum value in a vector
57
New cards
[position]
Indexing syntax used to access a specific vector element by its numerical position
58
New cards
[c(positions)]
Indexing syntax used to access multiple vector elements at once by passing specific positions
59
New cards
[logical_vector] or [condition]
Indexing syntax used to subset and access vector elements based on a logical condition
60
New cards

[-position]

Indexing syntax that uses negative indexing to exclude specific elements from a vector
61
New cards
62
New cards
read.csv()
Function used to import CSV (comma
63
New cards
read.table()
Function used to import files with custom delimiters
64
New cards
read.delim()
Function used to import tab
65
New cards
write.csv()
Function used to export data to a CSV file
66
New cards
write.table()
Function used to export data to a file with custom separators, such as tabs
67
New cards
Working directory
The folder R looks for files in
68
New cards
File paths
How to specify file locations
69
New cards
Data validation
Checking imported data for issues
70
New cards
Encoding
How text is stored in files
71
New cards
CSV files
Comma
72
New cards
TSV files
Tab
73
New cards
TXT files
Space or other delimited files
74
New cards
getwd()
Function to see the current working directory
75
New cards
setwd()
Function to change the working directory
76
New cards
list.files()
Function to list available files and folders in a directory
77
New cards
file.exists()
Function to check if specific files exist
78
New cards
file.info()
Function to get file information like size and modification date
79
New cards
dir.create()
Function to create a new directory
80
New cards
header = TRUE
Option specifying that the first row of a file contains column names
81
New cards
stringsAsFactors = FALSE
Option to keep text columns as characters instead of converting them to factors
82
New cards
na.strings
Option used to specify missing value indicators, such as empty strings or "N/A"
83
New cards
dim()
Function to check the dimensions of a data frame
84
New cards
str()
Function to check data types and structure
85
New cards

sep

Parameter used to specify the delimiter (e.g., "\t") in read and write functions
86
New cards
save.image()
Function used to save the workspace to preserve all created object
87
New cards
Descriptive statistics
Statistics used to summarize data, including mean, median, and standard deviation
88
New cards
Inferential statistics
Statistics used to make conclusions about populations, such as t
89
New cards
mean()
Calculates the central tendency or basic average of data
90
New cards
median()
Calculates the median value for basic statistics
91
New cards
sd()
Calculates the standard deviation to measure data spread
92
New cards
summary()
Provides a comprehensive overview of descriptive statistics
93
New cards
quantile()
Calculates specific percentiles and quartiles from the data
94
New cards
range()
Finds the minimum and maximum values to show data spread
95
New cards
min()
Finds the extreme minimum value in the data
96
New cards
max()
Finds the extreme maximum value in the data
97
New cards
IQR()
Calculates the interquartile range to measure data spread
98
New cards
data.frame()
Creates a summary table to combine and organize calculated statistics
99
New cards
sapply()
Applies functions to multiple columns, often used with is.numeric to identify numeric columns
100
New cards
aggregate()
Calculates statistics grouped by specific variables