'geom_bar and geom_col producing missing data
I am not sure if this is a bug or if I am doing something wrong.
I am plotting the amount of observation per time unit (second). For some reason this produces missing data in ggplot2 geom_bar and geom_col. I thought some data was missing, but after inspection the data looks fine. What is going on here?
Commands used
data %>%
group_by(TIJD) %>% summarise(n = n()) %>%
filter(TIJD > hms::as_hms('9:30:00')) %>%
filter(TIJD < hms::as_hms('9:35:00')) %>%
ggplot() +
geom_col(aes(x = TIJD, y = n))
and
data %>%
group_by(TIJD) %>% summarise(n = n()) %>%
filter(TIJD > hms::as_hms('9:30:00')) %>%
filter(TIJD < hms::as_hms('9:31:00')) %>%
ggplot() +
geom_col(aes(x = TIJD, y = n))
Producing
Data is
structure(list(time = structure(c(34201, 34202, 34203, 34204,
34205, 34206, 34207, 34208, 34209, 34210, 34211, 34212, 34213,
34214, 34215, 34216, 34217, 34218, 34219, 34220, 34221, 34222,
34223, 34224, 34225, 34226, 34227, 34228, 34229, 34230, 34231,
34232, 34233, 34234, 34235, 34236, 34237, 34238, 34239, 34240,
34241, 34242, 34243, 34244, 34245, 34246, 34247, 34248, 34249,
34250, 34251, 34252, 34253, 34254, 34255, 34256, 34257, 34258,
34259, 34260, 34261, 34262, 34263, 34264, 34265, 34266, 34267,
34268, 34269, 34270, 34271, 34272, 34273, 34274, 34275, 34276,
34277, 34278, 34279, 34280, 34281, 34282, 34283, 34284, 34285,
34286, 34287, 34288, 34289, 34290, 34291, 34292, 34293, 34294,
34295, 34296, 34297, 34298, 34299, 34300, 34301, 34302, 34303,
34304, 34305, 34306, 34307, 34308, 34309, 34310, 34311, 34312,
34313, 34314, 34315, 34316, 34317, 34318, 34319, 34320, 34321,
34322, 34323, 34324, 34325, 34326, 34327, 34328, 34329, 34330,
34331, 34332, 34333, 34334, 34335, 34336, 34337, 34338, 34339,
34340, 34341, 34342, 34343, 34344, 34345, 34346, 34347, 34348,
34349, 34350, 34351, 34352, 34353, 34354, 34355, 34356, 34357,
34358, 34359, 34360, 34361, 34362, 34363, 34364, 34365, 34366,
34367, 34368, 34369, 34370, 34371, 34372, 34373, 34374, 34375,
34376, 34377, 34378, 34379, 34380, 34381, 34382, 34383, 34384,
34385, 34386, 34387, 34388, 34389, 34390, 34391, 34392, 34393,
34394, 34395, 34396, 34397, 34398, 34399, 34400, 34401, 34402,
34403, 34404, 34405, 34406, 34407, 34408, 34409, 34410, 34411,
34412, 34413, 34414, 34415, 34416, 34417, 34418, 34419, 34420,
34421, 34422, 34423, 34424, 34425, 34426, 34427, 34428, 34429,
34430, 34431, 34432, 34433, 34434, 34435, 34436, 34437, 34438,
34439, 34440, 34441, 34442, 34443, 34444, 34445, 34446, 34447,
34448, 34449, 34450, 34451, 34452, 34453, 34454, 34455, 34456,
34457, 34458, 34459, 34460, 34461, 34462, 34463, 34464, 34465,
34466, 34467, 34468, 34469, 34470, 34471, 34472, 34473, 34474,
34475, 34476, 34477, 34478, 34479, 34480, 34481, 34482, 34483,
34484, 34485, 34486, 34487, 34488, 34489, 34490, 34491, 34492,
34493, 34494, 34495, 34496, 34497, 34498, 34499), class = c("hms",
"difftime"), units = "secs"), n = c(42L, 41L, 37L, 40L, 26L,
38L, 38L, 36L, 32L, 41L, 21L, 31L, 30L, 23L, 40L, 39L, 25L, 27L,
20L, 35L, 26L, 30L, 41L, 32L, 36L, 25L, 24L, 23L, 38L, 55L, 40L,
34L, 42L, 30L, 32L, 33L, 42L, 31L, 43L, 31L, 45L, 27L, 34L, 29L,
29L, 42L, 30L, 42L, 42L, 40L, 46L, 17L, 35L, 32L, 39L, 29L, 35L,
29L, 38L, 29L, 48L, 37L, 37L, 34L, 38L, 26L, 34L, 27L, 37L, 27L,
32L, 34L, 26L, 37L, 31L, 33L, 26L, 30L, 38L, 37L, 34L, 41L, 38L,
34L, 28L, 39L, 30L, 23L, 25L, 33L, 39L, 33L, 30L, 26L, 41L, 32L,
37L, 30L, 24L, 35L, 33L, 36L, 34L, 31L, 33L, 23L, 32L, 24L, 21L,
25L, 34L, 38L, 27L, 31L, 28L, 26L, 34L, 27L, 29L, 49L, 43L, 46L,
32L, 30L, 30L, 39L, 28L, 25L, 30L, 42L, 39L, 37L, 24L, 32L, 27L,
42L, 36L, 38L, 27L, 28L, 24L, 48L, 33L, 32L, 41L, 24L, 30L, 31L,
30L, 33L, 20L, 36L, 42L, 25L, 33L, 30L, 23L, 35L, 29L, 35L, 34L,
32L, 25L, 39L, 25L, 21L, 29L, 41L, 24L, 31L, 21L, 44L, 25L, 20L,
32L, 33L, 31L, 28L, 29L, 29L, 31L, 38L, 27L, 28L, 32L, 37L, 29L,
42L, 27L, 38L, 32L, 37L, 31L, 21L, 36L, 31L, 28L, 35L, 29L, 33L,
30L, 30L, 33L, 36L, 37L, 29L, 28L, 30L, 29L, 25L, 29L, 25L, 29L,
36L, 36L, 16L, 29L, 38L, 33L, 33L, 40L, 31L, 30L, 25L, 31L, 29L,
27L, 32L, 24L, 35L, 39L, 26L, 23L, 31L, 28L, 34L, 26L, 35L, 34L,
37L, 22L, 36L, 29L, 31L, 32L, 30L, 35L, 35L, 33L, 34L, 37L, 27L,
27L, 32L, 34L, 43L, 27L, 36L, 33L, 35L, 31L, 31L, 30L, 45L, 33L,
40L, 28L, 32L, 28L, 41L, 30L, 33L, 29L, 33L, 32L, 30L, 33L, 36L,
30L, 29L, 41L, 27L, 31L, 27L, 35L, 23L, 33L, 29L, 20L, 26L, 24L,
30L, 35L, 38L, 37L, 30L, 21L, 25L, 26L)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -299L))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


