回答編集履歴
1
サンプル追加
test
CHANGED
@@ -9,3 +9,65 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
で事足りるように思います。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
df1 <- read.table(text="
|
18
|
+
|
19
|
+
2021/12/01 12:00,xxx
|
20
|
+
|
21
|
+
2021/12/17 19:00,xxx
|
22
|
+
|
23
|
+
2021/12/30 23:00,xxx
|
24
|
+
|
25
|
+
"
|
26
|
+
|
27
|
+
, stringsAsFactors=F, header=F, sep=",")
|
28
|
+
|
29
|
+
ddsum <- list()
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
for(i in 1:nrow(df1)){
|
34
|
+
|
35
|
+
dd <- unlist(strsplit(df1[i,1], "[ :]"))
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# 日付ごと全部数える
|
40
|
+
|
41
|
+
if(is.null(ddsum[[ dd[1] ]][["total"]])){
|
42
|
+
|
43
|
+
ddsum[[ dd[1] ]][["total"]] <- 1
|
44
|
+
|
45
|
+
}else{
|
46
|
+
|
47
|
+
ddsum[[ dd[1] ]][["total"]] <- ddsum[[ dd[1] ]][["total"]] +1
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
# 日付・時間ごとに数える
|
54
|
+
|
55
|
+
if(is.null(ddsum[[ dd[1] ]][[ dd[2] ]])){
|
56
|
+
|
57
|
+
ddsum[[ dd[1] ]][[ dd[2] ]] <- 1
|
58
|
+
|
59
|
+
}else{
|
60
|
+
|
61
|
+
ddsum[[ dd[1] ]][[ dd[2] ]] <- ddsum[[ dd[1] ]][[ dd[2] ]] +1
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
print(str(ddsum))
|
72
|
+
|
73
|
+
```
|