Overall goal is to call lm(cbind(data$response1, data$response2) ~., data = data). When I use the $, the subsequent call to ~. adds all variables in data as predictors but excludes "response1" and "response2".
I would be very grateful if anyone can help me figure out how to create a function that takes a data frame and a variable name and prints that variable. For example:
(expected output)
create.vector <- function(data, variable.name) {
return(data$variable.name)
}
data <- iris
head(
create.vector(iris, "Species")
)
[1] setosa setosa setosa setosa setosa setosa
Levels: setosa versicolor virginica
I have tried to input the line paste(data, variable.name, collapse = "$"), but the output seems to remain of data type character...