嗨我需要计算一些实验的累计昆虫日。这就是我的数据框架
Rep trt date BLB
1 I 1 7/12/2017 3
2 I 2 7/12/2017 2
3 I 3 7/12/2017 4
4 I 4 7/12/2017 0
5 II 1 7/12/2017 1
6 II 2 7/12/2017 2
7 II 3 7/12/2017 2
8 II 4 7/12/2017 1
9 III 1 7/12/2017 3
10 III 2 7/12/2017 2
11 III 3 7/12/2017 1
12 III 4 7/12/2017 1
13 IV 1 7/12/2017 0
14 IV 2 7/12/2017 3
15 IV 3 7/12/2017 3
16 IV 4 7/12/2017 0
17 I 1 7/20/2017 12
18 I 2 7/20/2017 6
19 I 3 7/20/2017 7
20 I 4 7/20/2017 18
21 II 1 7/20/2017 17
22 II 2 7/20/2017 11
23 II 3 7/20/2017 25
24 II 4 7/20/2017 17
25 III 1 7/20/2017 18
26 III 2 7/20/2017 6
27 III 3 7/20/2017 48
28 III 4 7/20/2017 13
29 IV 1 7/20/2017 7
30 IV 2 7/20/2017 22
31 IV 3 7/20/2017 18
32 IV 4 7/20/2017 11
33 I 1 7/27/2017 1
34 I 2 7/27/2017 3
35 I 3 7/27/2017 4
36 I 4 7/27/2017 0
37 II 1 7/27/2017 1
38 II 2 7/27/2017 0
39 II 3 7/27/2017 1
40 II 4 7/27/2017 0
41 III 1 7/27/2017 1
42 III 2 7/27/2017 1
43 III 3 7/27/2017 0
44 III 4 7/27/2017 0
45 IV 1 7/27/2017 1
46 IV 2 7/27/2017 0
47 IV 3 7/27/2017 1
48 IV 4 7/27/2017 2
49 I 1 8/2/2017 0
50 I 2 8/2/2017 0
51 I 3 8/2/2017 1
52 I 4 8/2/2017 0
53 II 1 8/2/2017 0
54 II 2 8/2/2017 0
55 II 3 8/2/2017 0
56 II 4 8/2/2017 0
57 III 1 8/2/2017 1
58 III 2 8/2/2017 0
59 III 3 8/2/2017 0
60 III 4 8/2/2017 0
61 IV 1 8/2/2017 0
62 IV 2 8/2/2017 0
63 IV 3 8/2/2017 0
64 IV 4 8/2/2017 2
结构将是:
data.frame': 64 obs. of 4 variables:
$ Rep : Factor w/ 4 levels "I","II","III",..: 1 1 1 1 2 2 2 2 3 3 ...
$ trt : Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
$ date: Factor w/ 4 levels "7/12/2017","7/20/2017",..: 1 1 1 1 1 1 1 1 1 1 ...
$ BLB : int 3 2 4 0 1 2 2 1 3 2 ...
要做到这一点,我需要计算不同治疗的每个日期组合的昆虫的平均值。例如,我必须计算每次治疗的日期7/12和7/20之间的每一次。然后我需要计算日期7/20和7/27等之间的平均值。有谁知道如何使用r软件这样做?我真的很感激帮助!!
答案 0 :(得分:1)
首先创建数据(如果你提供了dput(数据)......会很好):
<input id="firstName" type="text" class="form-control" name="Patient[firstName]" value="{{ $user->getFirstName() }}" required autofocus placeholder="First Name">
<input id="mobileArea" type="text" class="form-control" name="Patient[mobileArea]" value="{{ $user->mobileArea() }}" required autofocus placeholder="mobileArea"
简单的子集和聚合:
protected function validationRules()
{
return [
'Patient.firstName' => 'required|string|min:2',
'Patient.lastName' => 'required|string',
'Patient.sex' => 'required|string',
'Patient.city' => 'required|string',
'Patient.states' => 'required|string',
'Patient.address1' => 'required|string|min:2',
'Patient.zip' => 'required|string|min:2',
'Patient.mobileArea' => 'string|min:3|required_with:Patient.mobilePhone',
'Patient.mobilePhone' => 'string|min:7|required_with:Patient.mobileArea',
'Patient.homePhone' => 'string|min:7|required_with:Patient.homeArea',
'Patient.homeArea' => 'string|min:3|required_with:Patient.homePhone',
];
}
答案 1 :(得分:0)
您错过了某个日期组合小组@useR
有 (2017-07-12,2017-07-27), (2017-07-12,2017-08-02), (2017-07-20,2017-08-02)也。