2017-04-12 46 views

回答

1

你可以通過你的數據幀的每一列和要添加爲載體的名稱中使用walk2。您可能想要定義一個函數來獲取兩個參數並打印該圖。以下示例繪製每列中的數據並添加列名稱作爲每個繪圖的標題。

# Load the mtcars data frame as an example 
data(mtcars) 

# Load packages 
library(purrr) 

# Define a funciton to take two arguments: column and names of the column 
plotfun <- function(col, title){ 
    temp <- plot(col, main = title) 
    print(temp) 
} 

# Use walk2 through mtcars and names(mtcars) 
walk2(mtcars, names(mtcars), .f = plotfun) 
相關問題