Oct 2, 2024
[]
randnums[5]
gives the fifth elementrandnums[1:3]
mean()
: Calculate average, e.g., mean(randnums[1:3])
length()
: Find the number of elementslength
function
randnums[length(randnums)]
randnums[(length(randnums)-4):length(randnums)]
length()
is better.?function_name
mean()
function and na.rm
to handle missing valuesdata.frame(variable1, variable2, ...)
dataframe$column_name
mean(dataframe$column, na.rm=TRUE)
dataframe$new_column = operation
dataframe[row_indices, ]
dataframe[, column_indices]
dataframe[row_indices, column_indices]