无法使用ggplot2绘制每周数据

时间:2015-10-26 01:36:51

标签: r plot ggplot2

我可以绘制每日但周收益率

  

错误:geom_path:每个组只包含一个观察。

你需要调整群体审美吗?是。

使用此类数据:

DailyDF2 <- 
structure(list(Group.date = structure(c(15023, 15024, 15027, 
15029, 15031, 15035, 15036, 15037, 15039, 15040, 15041, 15043, 
15046, 15048, 15050, 15054, 15056, 15057, 15059, 15061, 15062, 
15063, 15064, 15068, 15070, 15071, 15073, 15078, 15079, 15080, 
15085, 15089, 15090, 15092, 15095, 15099, 15100, 15103, 15104, 
15105, 15106, 15107, 15109, 15110, 15111, 15112, 15113, 15120, 
15121, 15122, 15124, 15127, 15128, 15132, 15133, 15134, 15141, 
15142, 15146, 15148, 15153, 15155, 15156, 15161, 15162, 15169, 
15173, 15174, 15177, 15180, 15181, 15182, 15183, 15186, 15187, 
15188, 15190, 15195, 15196, 15197, 15198, 15199, 15201, 15202, 
15203, 15204, 15205, 15206, 15207, 15208, 15209, 15211, 15212, 
15213, 15214, 15215, 15216, 15218, 15219, 15220, 15223, 15224, 
15225, 15226, 15227, 15228, 15229, 15230, 15231, 15232, 15233, 
15235, 15236, 15237, 15239, 15241, 15243, 15244, 15245, 15246, 
15247, 15248, 15249, 15250, 15251, 15252, 15253, 15254, 15255, 
15257, 15258, 15259, 15260, 15261, 15262, 15263, 15264, 15265, 
15266, 15267, 15268, 15269, 15271, 15274, 15275, 15276, 15278, 
15279, 15280, 15281, 15282, 15283, 15284, 15285, 15286, 15287, 
15288, 15289, 15290, 15291, 15292, 15293, 15294, 15295, 15296, 
15297, 15298, 15299, 15300, 15301, 15302, 15303, 15304, 15305, 
15306, 15307, 15308, 15309, 15310, 15311, 15313, 15314, 15315, 
15316, 15317, 15318, 15320, 15321, 15322, 15323, 15325, 15327, 
15328, 15329, 15330, 15331, 15332, 15333, 15334, 15335, 15336, 
15337, 15338, 15342, 15343, 15344, 15345, 15346, 15347, 15348, 
15350, 15351, 15352, 15353, 15354, 15356, 15357, 15358, 15359, 
15361, 15362, 15363, 15364, 15365, 15367, 15368, 15369, 15370, 
15372, 15373, 15374, 15375, 15376, 15377, 15378, 15379, 15380, 
15381, 15382, 15383, 15384, 15385, 15386, 15387, 15389, 15390, 
15391, 15392, 15393, 15394, 15398, 15399, 15400, 15401, 15403, 
15404, 15405, 15406, 15407, 15408, 15409, 15410, 15411, 15412, 
15413, 15414, 15415, 15416, 15417, 15418, 15419, 15420, 15421, 
15422, 15423, 15424, 15425, 15428, 15429, 15430, 15433, 15434, 
15435, 15437, 15438, 15439, 15440, 15441, 15442, 15443, 15444, 
15446, 15447, 15448, 15449, 15450, 15451, 15454, 15455, 15456, 
15457, 15459, 15460, 15462, 15463, 15464, 15465, 15466, 15467, 
15468, 15469, 15470, 15471, 15474, 15475, 15476, 15477, 15478, 
15481, 15482, 15483, 15484, 15485, 15488, 15489, 15490, 15491, 
15492, 15495, 15496, 15497, 15498, 15500, 15501, 15502, 15503, 
15504, 15505, 15506, 15507, 15508, 15509, 15510, 15511, 15512, 
15514, 15515, 15516, 15518, 15519, 15520, 15522, 15525, 15526, 
15527, 15528, 15529, 15530, 15531, 15532, 15533, 15534, 15536, 
15537, 15539, 15540, 15541, 15542, 15544, 15545, 15546, 15547, 
15548, 15549, 15550, 15551, 15552, 15553, 15554, 15555, 15558, 
15559, 15560, 15561, 15562, 15563, 15565, 15566, 15568, 15569, 
15572, 15573, 15574, 15575, 15576, 15578, 15579, 15580, 15581, 
15582, 15583, 15584, 15587, 15588, 15589, 15590, 15591, 15593, 
15594, 15595, 15596, 15597, 15600, 15602, 15603, 15604, 15605, 
15606, 15607, 15609, 15610, 15611, 15612, 15614, 15615, 15616, 
15617, 15618, 15621, 15622, 15623, 15624, 15625, 15626, 15628, 
15629, 15630, 15631, 15632, 15633, 15634, 15636, 15637, 15638, 
15639, 15641, 15642, 15643, 15644, 15645, 15646, 15647, 15649, 
15650, 15651, 15652, 15654, 15655, 15656, 15657, 15658, 15659, 
15660, 15661, 15662, 15663, 15664, 15665, 15666, 15667, 15670, 
15672, 15673, 15674, 15675, 15676, 15677, 15678, 15679, 15680, 
15681, 15682, 15684, 15685, 15686, 15687, 15688, 15689, 15690, 
15693, 15694, 15695, 15696, 15699, 15700, 15701, 15702, 15703, 
15708, 15709, 15712, 15713, 15715, 15716, 15717, 15719, 15720, 
15722, 15723, 15724, 15726, 15727, 15728, 15730, 15731, 15733, 
15734, 15735, 15736, 15737, 15738, 15739, 15740, 15741, 15742, 
15743, 15744, 15745, 15746, 15747, 15748, 15749, 15750, 15751, 
15752, 15753, 15754, 15755, 15756, 15757, 15758, 15759, 15760, 
15761, 15762), class = "Date"), X.hpm = c(4, 5, 3, 1, 3, 1, 2, 
1, 2, 3, 1, 4, 1, 1, 14, 1, 1, 5, 1, 1, 1, 1, 5, 2, 2, 9, 0, 
5, 1, 1, 1, 3, 1, 8, 1, 6, 5, 1, 2, 2, 3, 4, 1, 2, 2, 4, 4, 3, 
1, 1, 1, 11, 2, 1, 5, 4, 5, 1, 1, 3, 1, 2, 1, 1, 4, 6, 1, 0, 
0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 3, 2, 0, 0, 0, 1, 4, 1, 0, 1, 
0, 1, 2, 1, 1, 0, 0, 0, 27, 5, 2, 1, 0, 13, 1, 0, 0, 1, 0, 2, 
3, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 0, 1, 1, 3, 0, 0, 1, 3, 0, 0, 
1, 0, 15, 1, 0, 0, 1, 0, 4, 16, 0, 0, 4, 3, 3, 0, 0, 1, 1, 2, 
2, 0, 2, 1, 2, 0, 1, 4, 0, 4, 0, 3, 3, 14, 7, 2, 2, 2, 0, 6, 
5, 0, 0, 0, 1, 3, 1, 2, 0, 1, 0, 1, 1, 5, 1, 1, 0, 1, 0, 0, 0, 
0, 0, 1, 4, 0, 0, 0, 1, 2, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 5, 
2, 1, 0, 3, 1, 6, 3, 0, 1, 0, 2, 1, 0, 3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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), .Names = c("Group.date", 
"X.hpm", "X.hospice", "X.palliative", "X.pedpc", "X.pediatric", 
"HashTag"), row.names = c(NA, -545L), class = "data.frame")

DailyDataFrame

通过使用此代码绘图:

ggplot(DailyDF2, aes(Group.date)) +
  geom_line(aes(y = HashTag, colour = "HashTag")) +
  geom_line(aes(y = X.hpm, colour = "#hpm")) + 
  geom_line(aes(y = X.hospice, colour = "#hospice")) +
  geom_line(aes(y = X.palliative, colour="#palliative")) + 
  geom_line(aes(y = X.pedpc, colour = "#pedpc")) +
  geom_line(aes(y = X.pediatric, colour="#pediatric")) +
  ylab(label="Top 5 Hash Tags Frequency") + 
  xlab("Day")+
  theme(axis.text.x=element_text(angle=-45, hjust=0.001))

我明白了:

Daily

当我使用每周数据时:

WeeklyDF2 <-
structure(list(Group.date = c("2011-07", "2011-08", "2011-09", 
"2011-10", "2011-11", "2011-12", "2011-13", "2011-14", "2011-15", 
"2011-16", "2011-17", "2011-18", "2011-19", "2011-20", "2011-21", 
"2011-22", "2011-23", "2011-24", "2011-25", "2011-26", "2011-27", 
"2011-28", "2011-29", "2011-30", "2011-31", "2011-32", "2011-33", 
"2011-34", "2011-35", "2011-36", "2011-37", "2011-38", "2011-39", 
"2011-40", "2011-41", "2011-42", "2011-43", "2011-44", "2011-45", 
"2011-46", "2011-47", "2011-48", "2011-49", "2011-50", "2011-51", 
"2011-52", "2012-01", "2012-02", "2012-03", "2012-04", "2012-05", 
"2012-06", "2012-07", "2012-08", "2012-09", "2012-10", "2012-11", 
"2012-12", "2012-13", "2012-14", "2012-15", "2012-16", "2012-17", 
"2012-18", "2012-19", "2012-20", "2012-21", "2012-22", "2012-23", 
"2012-24", "2012-25", "2012-26", "2012-27", "2012-28", "2012-29", 
"2012-30", "2012-31", "2012-32", "2012-33", "2012-34", "2012-35", 
"2012-36", "2012-37", "2012-38", "2012-39", "2012-40", "2012-41", 
"2012-42", "2012-43", "2012-44", "2012-45", "2012-46", "2012-47", 
"2012-48", "2012-49", "2012-50", "2012-51", "2012-52", "2013-00", 
"2013-01", "2013-02", "2013-03", "2013-04", "2013-05", "2013-06", 
"2013-07", "2013-08"), X.hpm = c(9, 7, 4, 10, 16, 8, 8, 13, 7, 
1, 12, 12, 12, 13, 5, 14, 10, 6, 4, 4, 5, 6, 1, 2, 3, 5, 6, 6, 
34, 15, 6, 1, 4, 8, 17, 21, 10, 6, 10, 33, 15, 8, 9, 1, 5, 4, 
1, 9, 13, 4, 4, 3, 0, 5, 3, 24, 14, 22, 5, 2, 14, 3, 4, 8, 13, 
15, 40, 13, 6, 13, 37, 4, 2, 34, 4, 7, 12, 6, 11, 60, 23, 14, 
13, 12, 7, 12, 11, 36, 23, 5, 2, 10, 10, 7, 8, 10, 2, 5, 7, 14, 
30, 9, 9, 8, 25, 3, 0), X.hospice = c(2, 0, 0, 4, 2, 1, 0, 0, 
0, 0, 4, 0, 3, 7, 0, 0, 3, 1, 0, 3, 1, 0, 4, 9, 7, 17, 17, 5, 
13, 20, 6, 3, 16, 13, 0, 10, 6, 12, 10, 10, 8, 8, 8, 13, 11, 
7, 12, 6, 5, 11, 7, 13, 14, 6, 4, 14, 9, 24, 4, 9, 6, 4, 3, 9, 
8, 19, 5, 8, 10, 14, 3, 2, 5, 6, 7, 5, 6, 11, 9, 10, 6, 8, 9, 
18, 7, 6, 14, 6, 4, 7, 6, 11, 18, 12, 11, 6, 3, 2, 2, 8, 10, 
5, 10, 17, 18, 18, 21), X.palliative = c(1, 3, 0, 0, 1, 0, 0, 
1, 0, 0, 0, 0, 5, 5, 1, 2, 8, 1, 2, 2, 1, 0, 0, 0, 1, 7, 2, 0, 
7, 7, 3, 3, 7, 12, 6, 7, 11, 4, 11, 20, 5, 8, 4, 6, 1, 2, 6, 
2, 0, 4, 4, 3, 2, 4, 5, 8, 10, 19, 6, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0)), .Names = c("Group.date", "X.hpm", "X.hospice", "X.palliative", 
"X.pedpc", "X.pediatric", "HashTag"), row.names = c(NA, -107L
), class = "data.frame")

WeeklyDF

当我用类似的代码绘图时:

ggplot(WeeklyDF2, aes(Group.date))+
  geom_line(aes(y = HashTag, colour = "HashTag")) +
  geom_line(aes(y = X.hpm, colour = "#hpm")) + 
  geom_line(aes(y = X.hospice, colour = "#hospice")) +
  geom_line(aes(y = X.palliative, colour="#palliative")) + 
  geom_line(aes(y = X.pedpc, colour = "#pedpc")) +
  geom_line(aes(y = X.pediatric, colour="#pediatric")) +
  ylab(label="Top 5 Hash Tags Frequency") + 
  xlab("Week")+
  theme(axis.text.x=element_text(angle=-45, hjust=0.001))

我收到以下警告:

geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?

我的情节看起来像这样:

WeeklyErrorPlot

有什么想法吗?

更新我的WeeklyDF2$Group.date是一个字符向量。我的DailyDF2$Group.date是“双”。 WeeklyDF2$Group.date <- as.double.POSIXlt(WeeklyDF2$Group.date)WeeklyDF2$Group.date <- as.double(WeeklyDF2$Group.date)应该解决问题吗?

1 个答案:

答案 0 :(得分:0)

Ista是正确的:WeeklyDF2$Group.date <- as.numeric(as.factor(WeeklyDF$Group.date))

我需要做些什么来纠正这个问题,以便用以下方式进行策划:

ggplot(WeeklyDF2, aes(Group.date))+
  geom_line(aes(y = HashTag, colour = "HashTag")) +
  geom_line(aes(y = X.hpm, colour = "#hpm")) + 
  geom_line(aes(y = X.hospice, colour = "#hospice")) +
  geom_line(aes(y = X.palliative, colour="#palliative")) + 
  geom_line(aes(y = X.pedpc, colour = "#pedpc")) +
  geom_line(aes(y = X.pediatric, colour="#pediatric")) +
  ylab(label="Top 5 Hash Tags Frequency") + 
  xlab("Week")+
  theme(axis.text.x=element_text(angle=-45, hjust=0.001))

解决方案产生了一个序列(1,2,3,4,5,6,7 .......),但总比没有好。

Weekly Plots

知道如何在R中以适当的周日期格式绘制变量会很好。有人知道怎么做吗?我的意思是,有人知道如何将excel日期(MM / DD / YY)以及从api(18FEB2011:16:24:00.00)拉出的奇数日期格式转换为R的周日期格式吗?