I was just trying to call a certain column inside an R function using the code below but it only returns a null value. I know it sounds stupid to call the column using the $
sign. I know it can be done by defining the targeted column directly in the input of the function. However, I just want to know why the code below is not working. Thanks in advance!
fn <- function(data, var){
return(data$var)
}
data(cars)
fn(cars, speed)