複数の変数(すなわちVar.50、Var.100、Var.150およびVar.200)を含むtbl_df
オブジェクトdf
が与えられ、2回測定された場合(P1およびP2)、mutate
に同じ変数の新しいセット反復測定(例えば、平均P1およびP2、対応する各変数のP3を作成する)。dplyrを使用して複数の変数を変更するにはどうすればよいですか?
Similar questionsは前に頼まれてきたが、clear answers using dplyr
.
例のデータを持っていないようです:
df <- structure(list(P1.Var.50 = c(134.242050170898, 52.375, 177.126017252604
), P1.Var.100 = c(395.202219645182, 161.636606852214, 538.408426920573
), P1.Var.150 = c(544.40028889974, 266.439168294271, 718.998555501302
), P1.Var.200 = c(620.076151529948, 333.218780517578, 837.109700520833
), P2.Var.50 = c(106.133892059326, 113.252154032389, 172.384114583333
), P2.Var.100 = c(355.226725260417, 277.197153727214, 502.086781819661
), P2.Var.150 = c(481.993103027344, 329.575764973958, 709.315409342448
), P2.Var.200 = c(541.859161376953, 372.05473836263, 829.299621582031
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-3L), .Names = c("P1.Var.50", "P1.Var.100", "P1.Var.150", "P1.Var.200",
"P2.Var.50", "P2.Var.100", "P2.Var.150", "P2.Var.200"))
たぶんデータセットは、スプリット変数2部、P変数にdcastの列、P3を作成し、再溶融、連結柱、redcast溶融 –