Hi All,

I am interested in printing column names without quotes and am struggling to
do it properly. The tough part is that I am interested in using these column
names for a function within a function (e.g., lm() within a wrapper
function). Therefore, cat() doesnt seem appropriate and print() is not what
I need. Ideas?

# sample data
mod1 <- rnorm(20, 10, 2)
mod2 <- rnorm(20, 5, 1)
dat <- data.frame(mod1, mod2)

# collapsing the colnames to 'mod1+mod2'
temp <- paste(names(dat), collapse="+")

temp  # this gives quotes
print(temp, quote = FALSE)  # no quotes but includes [1]

# need the output like this (no quotes & no [1]):    mod1+mod2

Thanks,

AC

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to