teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの修正

2020/06/05 05:45

投稿

sary
sary

スコア12

title CHANGED
File without changes
body CHANGED
@@ -6,5 +6,56 @@
6
6
 
7
7
 
8
8
  ```
9
+ > gayreshaped <- read.csv("gayreshaped.csv")
10
+ > ccap2012 <- read.csv("ccap2012.csv")
11
+
12
+ > dim(gayreshaped)
13
+ [1] 11948 6
14
+ > summary(gayreshaped)
15
+ study treatment therm1
16
+ Min. :1.000 No Contact :6441 Min. : 0.00
17
+ 1st Qu.:1.000 Recycling Script by Gay Canvasser :1046 1st Qu.: 48.00
18
+ Median :1.000 Recycling Script by Straight Canvasser :1039 Median : 52.00
19
+ Mean :1.204 Same-Sex Marriage Script by Gay Canvasser :2389 Mean : 58.43
20
+ 3rd Qu.:1.000 Same-Sex Marriage Script by Straight Canvasser:1033 3rd Qu.: 84.00
21
+ Max. :2.000 Max. :100.00
22
+
23
+ therm2 therm3 therm4
24
+ Min. : 0.00 Min. : 0.00 Min. : 0.00
25
+ 1st Qu.: 45.00 1st Qu.: 44.00 1st Qu.: 44.00
26
+ Median : 55.00 Median : 57.00 Median : 58.00
27
+ Mean : 58.68 Mean : 59.72 Mean : 59.76
28
+ 3rd Qu.: 84.00 3rd Qu.: 85.00 3rd Qu.: 85.00
29
+ Max. :100.00 Max. :100.00 Max. :100.00
30
+ NA's :1351 NA's :9835 NA's :9777
31
+
32
+ > dim(ccap2012)
33
+ [1] 43998 3
34
+ > summary(ccap2012)
35
+ X caseid gaytherm
36
+ Min. : 1 Min. : 1.0 Min. : 0.00
37
+ 1st Qu.:11000 1st Qu.: 251.0 1st Qu.: 45.00
38
+ Median :22000 Median : 501.0 Median : 54.00
39
+ Mean :22000 Mean : 500.5 Mean : 58.71
40
+ 3rd Qu.:32999 3rd Qu.: 751.0 3rd Qu.: 85.00
41
+ Max. :43998 Max. :1001.0 Max. :100.00
42
+ NA's :3097
43
+
44
+ > cor(gayreshaped$therm1[gayreshaped$study == 1 & gayreshaped$treatment == "No Contact"],
45
+ + gayreshaped$therm2[gayreshaped$study == 1 & gayreshaped$treatment == "No Contact"],
46
+ + use = "complete.obs")
47
+ [1] 0.9975817
48
+
9
- gayreshaped_2 <- gayreshaped[gayreshaped$study == 2 & gayreshaped$treatment == "No Contact",c(3,4,5,6)]
49
+ > gayreshaped_2 <- gayreshaped[gayreshaped$study == 2 & gayreshaped$treatment == "No Contact",c(3,4,5,6)]
50
+
51
+
52
+ > cor(gayreshaped_2,use = "pairwise.complete.obs")
53
+ therm1 therm2 therm3 therm4
54
+ therm1 1.0000000 0.9734449 0.9594085 0.9709017
55
+ therm2 0.9734449 1.0000000 0.9308287 0.9436621
56
+ therm3 0.9594085 0.9308287 1.0000000 0.9343249
57
+ therm4 0.9709017 0.9436621 0.9343249 1.0000000
58
+
59
+ > min(cor(gayreshaped_2,use = "pairwise.complete.obs"))
60
+ [1] 0.9308287
10
61
  ```