2015-10-15 127 views
0
df = readRDS('mydata.RDS') 
message('column names: ',colnames(df)) 

輸出打印用空格

column names: col1col2col2col4 

colnames我怎樣才能得到它用空格打印像

column names: col1 col2 col3 col4 

回答

2

您可以使用paste()。我使用了mtcars數據集並添加了換行符。

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