tubby
tubby

Reputation: 2144

Print colnames with spaces

df = readRDS('mydata.RDS')
message('column names: ',colnames(df))

Output

column names: col1col2col2col4

How can I get it to print with spaces like

column names: col1 col2 col3 col4

Upvotes: 0

Views: 109

Answers (1)

Rich Scriven
Rich Scriven

Reputation: 99331

You can use paste(). I used the mtcars data set and added a line-break.

message(
    "now have the following columns: ",
    paste(colnames(mtcars), collapse = " "), 
    "\nand the following rows: ", 
    nrow(mtcars)
)
# now have the following columns: mpg cyl disp hp drat wt qsec vs am gear carb
# and the following rows: 32

Upvotes: 2

Related Questions