1/35
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
set working directory
setwd(“/Users/anupo/biostats_lab)
to load dataset
name = read.csv(“/Users/anupo/biostats/nameoffile”)
to see number of total rows and columns
dim(data)
vector for rows and columns
[rows, columns]
give an example?
subset data to only include certain columns or rows
hint: use vector integers
data = data[“row 1”, “row2”, “row3”, “column1”, “column2”, “column3”]
number of columns
ncol(data)
number of rows
nrow(data)
to rename columns/rows
names(data)=c(“rename”)
to print out
print(paste(“total number of variable”, ncol(nyc))
to call specific column/row
data$column/row
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”)
create a table
table_name= table(data$column)
print(table_name)
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)
create a vector
v =c(1,2,3)
combine functions, collect elements into a vector
c()
tapply