の関数の引数として文字列を使用する元の列を使用して新しい列を作成したい、新しい列のすべての組み合わせを表すために文字を使用し、次に新しい列を作成するためにdplyr::mutate
を使用する。 foo <- eval(parse(text = paste(new.feature,collapse = ",")))
に何か間違いがあります、あなたの答えに感謝します。私はpaste(new.feature,collapse = ",")
を使用する場合、私はこれらの何かについてR
paste(new.feature,collapse = ",")
のような文字を取得しますcol.names <- names(iris) sign.paste <- function(x){paste(x,collapse = "-")} new.feature <- apply(combn(col.names,2),2,sign.paste) paste(new.feature,collapse = ",") foo <- eval(parse(text = paste(new.feature,collapse = ","))) dplyr::mutate(iris,foo)
[1]「Sepal.Length-Sepal.Width、Sepal.Length-Petal.Length、Sepal.Length -Petal.Width、Sepal.Length-Species、Sepal.Width-Petal.Length、Sepal.Width-Petal.Width、Sepal.Width-Species、Petal.Length-Petal.Width、Petal.Length-Species、Petal.Width - 種別 "
最後に私は欲しいe mutate
を使用して新しい列を作成しましたが、失敗しました。