首页 > 解决方案 > 使用“Cookbook for R”中的函数汇总 data.frame 仅输出 NA / NaN(ggplot 中的误差线需要)

问题描述

我用 ggplot 创建了一个线图。现在我想将 95% 置信区间添加到数据点。在寻找一种方法时,我从“Cookbook for R”中找到了函数“SummarySE”,并尝试将其应用于我的数据。

我遇到的问题是,所有新的计算列仅包含 NA 和 NaN 以及Warning message: In qt(conf.interval/2 + 0.5, datac$N - 1) : NaNs produced.

head()我得到的输出: 我的输出的头部看起来如何

我的数据:

structure(list(J01 = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 
8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L), .Label = c("Tetrazykline", 
"Penicilline", "Andere Beta-Lactame", "Sulfonamide & Trimethoprim", 
"Makrolide, Lincosamide & Streptogramine", "Aminoglykoside", 
"Chinolone", "Andere Antibiotika"), class = "factor"), Monat = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 
12L, 12L, 12L, 12L), .Label = c("Jan 2018", "Feb 2018", "Mär 2018", 
"Apr 2018", "Mai 2018", "Jun 2018", "Jul 2018", "Aug 2018", "Sep 2018", 
"Okt 2018", "Nov 2018", "Dez 2018"), class = "factor"), DDDs = c(262, 
5729, 3305, 495, 588, 153, 944, 922, 85, 6386, 3157, 546, 753, 
120, 421, 419, 102, 6758, 3582, 682, 853, 167, 884, 1061, 122, 
5628, 3395, 564, 520, 161, 501, 728, 208, 4976, 3380, 508, 620, 
205, 704, 1106, 147, 4420, 3521, 634, 611, 110, 728, 1212, 133, 
5717, 3783, 708, 582, 230, 593, 842, 387, 6191, 3796, 605, 410, 
62, 595, 875, 130, 5309, 4084, 2010, 395, 163, 632, 1202, 84, 
5266, 3437, 617, 568, 141, 623, 948, 60, 5972, 3485, 718, 518, 
132, 588, 1034, 182, 4924, 3360, 573, 405, 96, 319, 1337)), row.names = c(NA, 
-96L), class = "data.frame")

有人现在有什么问题以及我该如何解决?

标签: rggplot2plyr

解决方案


推荐阅读