【发布时间】:2018-10-16 16:21:35
【问题描述】:
我导入了以下数据,其中一个问题的结构如下:
问题 a) Type_of_input [MULTIPLE SELECT]
- 1:肥料
- 2:农药
- 3:除草剂
- 4:喷雾器
问题 b) 总量。
在 data.frame 中,数据被拆分为一个矩阵,每个选项位于单独的列中,观察值为 0 和 1。如果选择了该选项,则为 1,如果未选择该选项,则为 0。请参阅下面的 data.frame 模型。
Type_of_input <- c("1:Fertiliser|2:Pesticide|4:Sprayer", "2:Pesticide|3:Herbicides", "2:Pesticide|3:Herbicide|4:Sprayer")
Fertiliser <- c(1,0,0)
Pesticide <- c(1,1,1)
Herbicide <- c(0,1,1)
Sprayer <- c(1,0,1)
total_volume <- c(40,50,60)
df_inputs <- data.frame(Type_of_input, Fertiliser, Pesticide, Herbicide, Sprayer, volume)
df_inputs
Type_of_input Fertiliser Pesticide Herbicide Sprayer total_volume
1 1:Fertiliser|2:Pesticide|4:Sprayer 1 1 0 1 40
2 2:Pesticide|3:Herbicides 0 1 1 0 50
3 2:Pesticide|3:Herbicide|4:Sprayer 0 1 1 1 60
如何获取每个输入的频率表计数及其total_volume?
【问题讨论】:
标签: r dplyr frequency data-analysis