var timeInterval = 5; var blinkTime = 1; var open_signal = 'top_left'; $ (document) .ready (function () {$ ('# div_top_left .timer'). html (timeInterval); $ ('# div_top_right .timer'). html (timeInterval); $ ('# div_bottom_right .timer') .html (timeInterval * 2); $ ('# div_bottom_left .timer'). html (timeInterval * 3); $ ('# div_top_left .green'). css ('background-color', 'green'); $ ( '#div_top_right .red'). css ('background-color', 'red'); $ ('# div_bottom_right .red'). css ('background-color', 'red'); $ ('# div_bottom_left. красный '). css (' background-color ',' red '), setInterval (function () {manageSignals ();}, 1000);}); function manageSignals () {var top_left_time = parseInt ($ ('# div_top_left .timer'). html ()) - 1; var top_right_time = parseInt ($ ('# div_top_right .timer'). html ()) - 1; var bottom_left_time = parseInt ($ ('# div_bottom_left .timer'). html ()) - 1; var bottom_right_time = parseInt ($ ('# div_bottom_right .timer'). html ()) - 1; if (top_left_time == -1 & amp; & amp; open_signal == 'top_left') open_signal = 'top_right'; else if (top_right_time == -1 & amp; & amp; open_signal == 'top_right') open_signal = 'bottom_right'; else if (bottom_right_time == -1 & amp; & open_signal == 'bottom_right') open_signal = 'bottom_left'; else if (bottom_left_time == -1 & amp; & open_signal == 'bottom_left') open_signal = 'top_left'; if (top_left_time == -1) {if (open_signal == 'top_right') {top_left_time = (timeInterval * 3) - 1; $ ('# div_top_left .red'). css ('background-color', 'red'); $ ('# div_top_left .yellow'). css ('background-color', 'white'); $ ('# div_top_left .green'). css ('background-color', 'white'); } else if (open_signal == 'top_left') {top_left_time = timeInterval - 1; $ ('# div_top_left .red'). css ('background-color', 'white'); $ ('# div_top_left .yellow'). css ('background-color', 'white'); $ ('# div_top_left .green'). css ('background-color', 'green'); }} if (top_right_time == -1) {if (open_signal == 'bottom_right') {top_right_time = (timeInterval * 3) - 1; $ ('# div_top_right .red'). css ('background-color', 'red'); $ ('# div_top_right .yellow'). css ('background-color', 'white'); $ ('# div_top_right .green'). css ('background-color', 'white'); } else if (open_signal == 'top_right') {top_right_time = timeInterval - 1; $ ('# div_top_right .red'). css ('background-color', 'white'); $ ('# div_top_right .yellow'). css ('background-color', 'white'); $ ('# div_top_right .green'). css ('background-color', 'green'); }} if (bottom_right_time == -1) {if (open_signal == 'bottom_left') {bottom_right_time = (timeInterval * 3) - 1; $ ('# div_bottom_right .red'). css ('background-color', 'red'); $ ('# div_bottom_right .yellow'). css ('background-color', 'white'); $ ('# div_bottom_right .green'). css ('background-color', 'white'); } else if (open_signal == 'bottom_right') {bottom_right_time = timeInterval - 1; $ ('# div_bottom_right .red'). css ('background-color', 'white'); $ ('# div_bottom_right .yellow'). css ('background-color', 'white'); $ ('# div_bottom_right .green'). css ('background-color', 'green'); }} if (bottom_left_time == -1) {if (open_signal == 'top_left') {bottom_left_time = (timeInterval * 3) - 1; $ ('# div_bottom_left .red'). css ('background-color', 'red'); $ ('# div_bottom_left .yellow'). css ('background-color', 'white'); $ ('# div_bottom_left .green'). css ('background-color', 'white'); } else if (open_signal == 'bottom_left') {bottom_left_time = timeInterval - 1; $ ('# div_bottom_left .red'). css ('background-color', 'white'); $ ('# div_bottom_left .yellow'). css ('background-color', 'white'); $ ('# div_bottom_left .green'). css ('background-color', 'green'); }} if (top_left_time == blinkTime & amp; & amp; open_signal == 'top_left') {$ ('# div_top_left .yellow'). css ('background-color', 'yellow'); $ ('# div_top_left .green'). css ('background-color', 'white'); } if (top_right_time == blinkTime & amp; & amp; open_signal == 'top_right') {$ ('# div_top_right .yellow'). css ('background-color', 'yellow'); $ ('# div_top_right .green'). css ('background-color', 'white'); } if (bottom_left_time == blinkTime & amp; & amp; open_signal == 'bottom_left') {$ ('# div_bottom_left .yellow'). css ('background-color', 'yellow'); $ ('# div_bottom_left .green'). css ('background-color', 'white'); } if (bottom_right_time == blinkTime & amp; & open_signal == 'bottom_right') {$ ('# div_bottom_right .yellow'). css ('background-color', 'yellow'); $ ('# div_bottom_right .green'). css ('background-color', 'white'); } $ ('# div_top_left .timer'). html (top_left_time); $ ('# div_top_right .timer'). html (top_right_time); $ ('# div_bottom_left .timer'). html (bottom_left_time); $ ('# div_bottom_right .timer'). html (bottom_right_time); }
Можете ли вы использовать дату в качестве фактора?
blockquote>Да, но вы, вероятно, не должны.
... или вы должны использовать
< / blockquote>as.Date
в столбце даты?Да.
Что приводит нас к этому:
library(scales) df$Month <- as.Date(df$Month) ggplot(df, aes(x = Month, y = AvgVisits)) + geom_bar(stat = "identity") + theme_bw() + labs(x = "Month", y = "Average Visits per User") + scale_x_date(labels = date_format("%m-%Y"))
[/g0]
, в котором я добавлен
stat = "identity"
к вашему вызовуgeom_bar
.Кроме того, сообщение об ширине бина не было ошибкой. Ошибка будет на самом деле сказать «Ошибка» в нем, и аналогично предупреждение всегда будет говорить «Предупреждение» в нем. В противном случае это просто сообщение.
Показывать месяцы как январь 2017 года февраль 2017 и т. д.:
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y")
Указать даты, если они занимают слишком много места:
theme(axis.text.x=element_text(angle=60, hjust=1))
theme_bw()
перезаписывает все, что theme()
делает. Переупорядочено, и все работает отлично. Оставив его здесь на случай, у кого-то такая же проблема.
– Ufos
3 December 2017 в 19:18
stat = "identity"
. Идем дальше к исследованиям. Благодарю. – mikebmassey 31 July 2012 в 21:56stat = "identity"
, заключается в том, что если вы делаете штриховые графики, и вы уже собрали данные, чтобы у вас были высоты каждого бара, используйте его. – joran 31 July 2012 в 21:57geom_line
- с и безstat = "identity"
- я получаю это предупреждение `geom_path: каждая группа состоят только из одного наблюдения. Если у меня только 1 группа данных, зачем мне нужно группироваться, чтобы она работала? благодаря – mikebmassey 31 July 2012 в 22:03