Skip to content
Prev 365891 / 398502 Next

Write a function that allows access to columns of a passeddataframe.

This would be an implementation that would support a multi-column extraction using a formula object:

mydf <- data.frame(id=c(1,2,3,4,5),sex=c("M","M","M","F","F"),age=c(20,34,43,32,21))
mydf
class(mydf)
str(mydf)

myfun <- function(frame, vars){
	yy <- terms(vars)
	frame[, attr(yy, "term.labels")]
}

myfun(mydf, ~age+sex)
David Winsemius
Alameda, CA, USA

Thread (21 messages)

John Sorkin Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 John Sorkin Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 David Winsemius Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 5 David Winsemius Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Bert Gunter Write a function that allows access to columns of a passed dataframe. Dec 5 Rui Barradas Write a function that allows access to columns of a passed dataframe. Dec 6 John Sorkin Write a function that allows access to columns of a passeddataframe. Dec 6 Rui Barradas Write a function that allows access to columns of a passeddataframe. Dec 6 William Dunlap Write a function that allows access to columns of a passeddataframe. Dec 6 Rui Barradas Write a function that allows access to columns of a passeddataframe. Dec 6 William Dunlap Write a function that allows access to columns of a passeddataframe. Dec 6 David Winsemius Write a function that allows access to columns of a passeddataframe. Dec 6 Bert Gunter Write a function that allows access to columns of a passeddataframe. Dec 6