R code Cheatsheet

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

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:11 PM on 9/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

36 Terms

1
New cards

set working directory

setwd(“/Users/anupo/biostats_lab)

2
New cards

to load dataset

name = read.csv(“/Users/anupo/biostats/nameoffile”)

3
New cards

to see number of total rows and columns

dim(data)

4
New cards

vector for rows and columns

[rows, columns]


give an example?

5
New cards

subset data to only include certain columns or rows


hint: use vector integers

data = data[“row 1”, “row2”, “row3”, “column1”, “column2”, “column3”]

6
New cards

number of columns

ncol(data)

7
New cards

number of rows

nrow(data)

8
New cards

to rename columns/rows

names(data)=c(“rename”)

9
New cards

to print out

print(paste(“total number of variable”, ncol(nyc))

10
New cards

to call specific column/row

data$column/row

11
New cards

in columns, there are numbers representing a certain string. what do you do to change the numbers to a string?

call the row or column, call factor, call the levels, and use the labels function in a c() function to change

data$column = factor(data$column, levels = c(1,2,3,4,5), labels = c(“name”, “name”)

12
New cards

create a table

table_name= table(data$column)

print(table_name)

13
New cards

rounding integers in a columns/row

call the column or row, use round function, and specify number of digits


data$row = round(data$row, digits = 0)

14
New cards

create a vector

v =c(1,2,3)

15
New cards

combine functions, collect elements into a vector

c()

16
New cards

tapply

17
New cards
18
New cards
19
New cards
20
New cards
21
New cards
22
New cards
23
New cards
24
New cards
25
New cards
26
New cards
27
New cards
28
New cards
29
New cards
30
New cards
31
New cards
32
New cards
33
New cards
34
New cards
35
New cards
36
New cards