2017-04-12 9 views

答えて

1

あなたは、データフレームの各列とあなたがベクトルとして追加する名称を通じてwalk2を使用することができます。 2つの引数をとり、プロットを印刷する関数を定義することができます。次の例では、各列のデータをプロットし、各プロットのタイトルとして列名を追加します。

# 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) 
関連する問題