R语言 想要一个频率多边形,但我一直得到直垂直线,而不是一个连续的水平线通过时间框架?

sxissh06  于 2023-01-15  发布在  其他
关注(0)|答案(1)|浏览(105)

这是我正在使用的数据集。大约有1000行。最终目标是,我希望从上午07:00到下午18:00每隔15分钟可视化一次汽车计数。然而,在处理时间间隔之前,我遇到了一个问题。
这是数据集。

dput(Trafic.df)

5281 2016-11-23 07:00:00   DC     PCL     0 07:00:00
5282 2016-11-23 07:00:00   DC     MCL     0 07:00:00
5283 2016-11-23 07:00:00   DC     CAR     0 07:00:00
5284 2016-11-23 07:00:00   DC    TAXI     0 07:00:00
5285 2016-11-23 07:00:00   DC     LGV     0 07:00:00
5286 2016-11-23 07:00:00   DC    OGV1     0 07:00:00
5287 2016-11-23 07:00:00   DC    OGV2     0 07:00:00
5288 2016-11-23 07:00:00   DC     CDB     0 07:00:00
5289 2016-11-23 07:00:00   DC     BEB     0 07:00:00
5290 2016-11-23 07:00:00   DC      OB     0 07:00:00
5291 2016-11-23 07:15:00   DC     PCL     0 07:15:00
5292 2016-11-23 07:15:00   DC     MCL     0 07:15:00
5293 2016-11-23 07:15:00   DC     CAR     0 07:15:00
5294 2016-11-23 07:15:00   DC    TAXI     0 07:15:00
5295 2016-11-23 07:15:00   DC     LGV     0 07:15:00
5296 2016-11-23 07:15:00   DC    OGV1     0 07:15:00
5297 2016-11-23 07:15:00   DC    OGV2     0 07:15:00
5298 2016-11-23 07:15:00   DC     CDB     0 07:15:00
5299 2016-11-23 07:15:00   DC     BEB     1 07:15:00
5300 2016-11-23 07:15:00   DC      OB     0 07:15:00
5301 2016-11-23 07:30:00   DC     PCL     1 07:30:00
5302 2016-11-23 07:30:00   DC     MCL     0 07:30:00
5303 2016-11-23 07:30:00   DC     CAR     5 07:30:00
5304 2016-11-23 07:30:00   DC    TAXI     0 07:30:00
5305 2016-11-23 07:30:00   DC     LGV     1 07:30:00
5306 2016-11-23 07:30:00   DC    OGV1     0 07:30:00
5307 2016-11-23 07:30:00   DC    OGV2     0 07:30:00
5308 2016-11-23 07:30:00   DC     CDB     0 07:30:00
5309 2016-11-23 07:30:00   DC     BEB     0 07:30:00
5310 2016-11-23 07:30:00   DC      OB     0 07:30:00
5311 2016-11-23 07:45:00   DC     PCL     0 07:45:00
5312 2016-11-23 07:45:00   DC     MCL     0 07:45:00
5313 2016-11-23 07:45:00   DC     CAR     3 07:45:00
5314 2016-11-23 07:45:00   DC    TAXI     0 07:45:00
5315 2016-11-23 07:45:00   DC     LGV     1 07:45:00
5316 2016-11-23 07:45:00   DC    OGV1     0 07:45:00
5317 2016-11-23 07:45:00   DC    OGV2     0 07:45:00
5318 2016-11-23 07:45:00   DC     CDB     0 07:45:00
5319 2016-11-23 07:45:00   DC     BEB     0 07:45:00
5320 2016-11-23 07:45:00   DC      OB     0 07:45:00
5321 2016-11-23 08:00:00   DC     PCL     0 08:00:00
5322 2016-11-23 08:00:00   DC     MCL     0 08:00:00
5323 2016-11-23 08:00:00   DC     CAR     8 08:00:00
5324 2016-11-23 08:00:00   DC    TAXI     0 08:00:00
5325 2016-11-23 08:00:00   DC     LGV     0 08:00:00
5326 2016-11-23 08:00:00   DC    OGV1     0 08:00:00
5327 2016-11-23 08:00:00   DC    OGV2     0 08:00:00
5328 2016-11-23 08:00:00   DC     CDB     0 08:00:00
5329 2016-11-23 08:00:00   DC     BEB     0 08:00:00
5330 2016-11-23 08:00:00   DC      OB     0 08:00:00
5331 2016-11-23 08:15:00   DC     PCL     0 08:15:00
5332 2016-11-23 08:15:00   DC     MCL     0 08:15:00
5333 2016-11-23 08:15:00   DC     CAR     4 08:15:00
5334 2016-11-23 08:15:00   DC    TAXI     0 08:15:00
5335 2016-11-23 08:15:00   DC     LGV     0 08:15:00
5336 2016-11-23 08:15:00   DC    OGV1     0 08:15:00
5337 2016-11-23 08:15:00   DC    OGV2     0 08:15:00
5338 2016-11-23 08:15:00   DC     CDB     0 08:15:00
5339 2016-11-23 08:15:00   DC     BEB     0 08:15:00
5340 2016-11-23 08:15:00   DC      OB     0 08:15:00
5341 2016-11-23 08:30:00   DC     PCL     0 08:30:00
5342 2016-11-23 08:30:00   DC     MCL     0 08:30:00
5343 2016-11-23 08:30:00   DC     CAR     6 08:30:00
5344 2016-11-23 08:30:00   DC    TAXI     0 08:30:00
5345 2016-11-23 08:30:00   DC     LGV     0 08:30:00
5346 2016-11-23 08:30:00   DC    OGV1     1 08:30:00
5347 2016-11-23 08:30:00   DC    OGV2     0 08:30:00
5348 2016-11-23 08:30:00   DC     CDB     0 08:30:00
5349 2016-11-23 08:30:00   DC     BEB     1 08:30:00
5350 2016-11-23 08:30:00   DC      OB     0 08:30:00
5351 2016-11-23 08:45:00   DC     PCL     0 08:45:00
5352 2016-11-23 08:45:00   DC     MCL     0 08:45:00
5353 2016-11-23 08:45:00   DC     CAR     8 08:45:00
5354 2016-11-23 08:45:00   DC    TAXI     0 08:45:00
5355 2016-11-23 08:45:00   DC     LGV     1 08:45:00
5356 2016-11-23 08:45:00   DC    OGV1     0 08:45:00
5357 2016-11-23 08:45:00   DC    OGV2     0 08:45:00
5358 2016-11-23 08:45:00   DC     CDB     0 08:45:00
5359 2016-11-23 08:45:00   DC     BEB     0 08:45:00
5360 2016-11-23 08:45:00   DC      OB     0 08:45:00
5361 2016-11-23 09:00:00   DC     PCL     1 09:00:00
5362 2016-11-23 09:00:00   DC     MCL     0 09:00:00
5363 2016-11-23 09:00:00   DC     CAR     5 09:00:00
5364 2016-11-23 09:00:00   DC    TAXI     1 09:00:00
5365 2016-11-23 09:00:00   DC     LGV     0 09:00:00
5366 2016-11-23 09:00:00   DC    OGV1     0 09:00:00
5367 2016-11-23 09:00:00   DC    OGV2     0 09:00:00
5368 2016-11-23 09:00:00   DC     CDB     0 09:00:00
5369 2016-11-23 09:00:00   DC     BEB     0 09:00:00
5370 2016-11-23 09:00:00   DC      OB     0 09:00:00
5371 2016-11-23 09:15:00   DC     PCL     0 09:15:00
5372 2016-11-23 09:15:00   DC     MCL     0 09:15:00
5373 2016-11-23 09:15:00   DC     CAR    11 09:15:00
5374 2016-11-23 09:15:00   DC    TAXI     1 09:15:00
5375 2016-11-23 09:15:00   DC     LGV     4 09:15:00
5376 2016-11-23 09:15:00   DC    OGV1     0 09:15:00
5377 2016-11-23 09:15:00   DC    OGV2     0 09:15:00
5378 2016-11-23 09:15:00   DC     CDB     0 09:15:00
5379 2016-11-23 09:15:00   DC     BEB     1 09:15:00
5380 2016-11-23 09:15:00   DC      OB     0 09:15:00
5381 2016-11-23 09:30:00   DC     PCL     0 09:30:00
5382 2016-11-23 09:30:00   DC     MCL     0 09:30:00
5383 2016-11-23 09:30:00   DC     CAR    10 09:30:00
5384 2016-11-23 09:30:00   DC    TAXI     2 09:30:00
5385 2016-11-23 09:30:00   DC     LGV     0 09:30:00
5386 2016-11-23 09:30:00   DC    OGV1     0 09:30:00
5387 2016-11-23 09:30:00   DC    OGV2     0 09:30:00
5388 2016-11-23 09:30:00   DC     CDB     0 09:30:00
5389 2016-11-23 09:30:00   DC     BEB     0 09:30:00
5390 2016-11-23 09:30:00   DC      OB     0 09:30:00
5391 2016-11-23 09:45:00   DC     PCL     0 09:45:00
5392 2016-11-23 09:45:00   DC     MCL     0 09:45:00
5393 2016-11-23 09:45:00   DC     CAR     9 09:45:00
5394 2016-11-23 09:45:00   DC    TAXI     1 09:45:00
5395 2016-11-23 09:45:00   DC     LGV     0 09:45:00
5396 2016-11-23 09:45:00   DC    OGV1     0 09:45:00
5397 2016-11-23 09:45:00   DC    OGV2     0 09:45:00
5398 2016-11-23 09:45:00   DC     CDB     0 09:45:00
5399 2016-11-23 09:45:00   DC     BEB     0 09:45:00
5400 2016-11-23 09:45:00   DC      OB     0 09:45:00
5401 2016-11-23 10:00:00   DC     PCL     0 10:00:00
5402 2016-11-23 10:00:00   DC     MCL     0 10:00:00
5403 2016-11-23 10:00:00   DC     CAR    14 10:00:00
5404 2016-11-23 10:00:00   DC    TAXI     0 10:00:00
5405 2016-11-23 10:00:00   DC     LGV     0 10:00:00
5406 2016-11-23 10:00:00   DC    OGV1     1 10:00:00
5407 2016-11-23 10:00:00   DC    OGV2     0 10:00:00
5408 2016-11-23 10:00:00   DC     CDB     0 10:00:00
5409 2016-11-23 10:00:00   DC     BEB     0 10:00:00
5410 2016-11-23 10:00:00   DC      OB     0 10:00:00
5411 2016-11-23 10:15:00   DC     PCL     0 10:15:00
5412 2016-11-23 10:15:00   DC     MCL     0 10:15:00
5413 2016-11-23 10:15:00   DC     CAR     4 10:15:00
5414 2016-11-23 10:15:00   DC    TAXI     0 10:15:00
5415 2016-11-23 10:15:00   DC     LGV     0 10:15:00
5416 2016-11-23 10:15:00   DC    OGV1     0 10:15:00
5417 2016-11-23 10:15:00   DC    OGV2     0 10:15:00
5418 2016-11-23 10:15:00   DC     CDB     1 10:15:00
5419 2016-11-23 10:15:00   DC     BEB     1 10:15:00
5420 2016-11-23 10:15:00   DC      OB     0 10:15:00
5421 2016-11-23 10:30:00   DC     PCL     1 10:30:00
5422 2016-11-23 10:30:00   DC     MCL     0 10:30:00
5423 2016-11-23 10:30:00   DC     CAR     8 10:30:00
5424 2016-11-23 10:30:00   DC    TAXI     0 10:30:00
5425 2016-11-23 10:30:00   DC     LGV     1 10:30:00
5426 2016-11-23 10:30:00   DC    OGV1     0 10:30:00
5427 2016-11-23 10:30:00   DC    OGV2     0 10:30:00
5428 2016-11-23 10:30:00   DC     CDB     0 10:30:00
5429 2016-11-23 10:30:00   DC     BEB     0 10:30:00
5430 2016-11-23 10:30:00   DC      OB     1 10:30:00
5431 2016-11-23 10:45:00   DC     PCL     0 10:45:00
5432 2016-11-23 10:45:00   DC     MCL     0 10:45:00
5433 2016-11-23 10:45:00   DC     CAR    12 10:45:00
5434 2016-11-23 10:45:00   DC    TAXI     0 10:45:00
5435 2016-11-23 10:45:00   DC     LGV     0 10:45:00
5436 2016-11-23 10:45:00   DC    OGV1     0 10:45:00
5437 2016-11-23 10:45:00   DC    OGV2     0 10:45:00
5438 2016-11-23 10:45:00   DC     CDB     0 10:45:00
5439 2016-11-23 10:45:00   DC     BEB     0 10:45:00
5440 2016-11-23 10:45:00   DC      OB     0 10:45:00
5441 2016-11-23 11:00:00   DC     PCL     0 11:00:00
5442 2016-11-23 11:00:00   DC     MCL     0 11:00:00
5443 2016-11-23 11:00:00   DC     CAR     7 11:00:00
5444 2016-11-23 11:00:00   DC    TAXI     0 11:00:00
5445 2016-11-23 11:00:00   DC     LGV     1 11:00:00
5446 2016-11-23 11:00:00   DC    OGV1     0 11:00:00
5447 2016-11-23 11:00:00   DC    OGV2     0 11:00:00
5448 2016-11-23 11:00:00   DC     CDB     0 11:00:00
5449 2016-11-23 11:00:00   DC     BEB     0 11:00:00
5450 2016-11-23 11:00:00   DC      OB     0 11:00:00
5451 2016-11-23 11:15:00   DC     PCL     0 11:15:00
5452 2016-11-23 11:15:00   DC     MCL     0 11:15:00
5453 2016-11-23 11:15:00   DC     CAR     9 11:15:00
5454 2016-11-23 11:15:00   DC    TAXI     0 11:15:00
5455 2016-11-23 11:15:00   DC     LGV     0 11:15:00
5456 2016-11-23 11:15:00   DC    OGV1     0 11:15:00
5457 2016-11-23 11:15:00   DC    OGV2     0 11:15:00
5458 2016-11-23 11:15:00   DC     CDB     0 11:15:00
5459 2016-11-23 11:15:00   DC     BEB     1 11:15:00
5460 2016-11-23 11:15:00   DC      OB     0 11:15:00
5461 2016-11-23 11:30:00   DC     PCL     0 11:30:00
5462 2016-11-23 11:30:00   DC     MCL     0 11:30:00
5463 2016-11-23 11:30:00   DC     CAR     4 11:30:00
5464 2016-11-23 11:30:00   DC    TAXI     1 11:30:00
5465 2016-11-23 11:30:00   DC     LGV     0 11:30:00
5466 2016-11-23 11:30:00   DC    OGV1     0 11:30:00
5467 2016-11-23 11:30:00   DC    OGV2     0 11:30:00
5468 2016-11-23 11:30:00   DC     CDB     0 11:30:00
5469 2016-11-23 11:30:00   DC     BEB     0 11:30:00
5470 2016-11-23 11:30:00   DC      OB     0 11:30:00
5471 2016-11-23 11:45:00   DC     PCL     0 11:45:00
5472 2016-11-23 11:45:00   DC     MCL     0 11:45:00
5473 2016-11-23 11:45:00   DC     CAR     5 11:45:00
5474 2016-11-23 11:45:00   DC    TAXI     1 11:45:00
5475 2016-11-23 11:45:00   DC     LGV     0 11:45:00
5476 2016-11-23 11:45:00   DC    OGV1     0 11:45:00
5477 2016-11-23 11:45:00   DC    OGV2     0 11:45:00
5478 2016-11-23 11:45:00   DC     CDB     0 11:45:00
5479 2016-11-23 11:45:00   DC     BEB     0 11:45:00
5480 2016-11-23 11:45:00   DC      OB     0 11:45:00
5481 2016-11-23 12:00:00   DC     PCL     0 12:00:00
5482 2016-11-23 12:00:00   DC     MCL     0 12:00:00
5483 2016-11-23 12:00:00   DC     CAR    10 12:00:00
5484 2016-11-23 12:00:00   DC    TAXI     0 12:00:00
5485 2016-11-23 12:00:00   DC     LGV     0 12:00:00
5486 2016-11-23 12:00:00   DC    OGV1     0 12:00:00
5487 2016-11-23 12:00:00   DC    OGV2     0 12:00:00
5488 2016-11-23 12:00:00   DC     CDB     0 12:00:00
5489 2016-11-23 12:00:00   DC     BEB     0 12:00:00
5490 2016-11-23 12:00:00   DC      OB     0 12:00:00
5491 2016-11-23 12:15:00   DC     PCL     0 12:15:00
5492 2016-11-23 12:15:00   DC     MCL     0 12:15:00
5493 2016-11-23 12:15:00   DC     CAR     9 12:15:00
5494 2016-11-23 12:15:00   DC    TAXI     2 12:15:00
5495 2016-11-23 12:15:00   DC     LGV     0 12:15:00
5496 2016-11-23 12:15:00   DC    OGV1     0 12:15:00
5497 2016-11-23 12:15:00   DC    OGV2     0 12:15:00
5498 2016-11-23 12:15:00   DC     CDB     0 12:15:00
5499 2016-11-23 12:15:00   DC     BEB     0 12:15:00
5500 2016-11-23 12:15:00   DC      OB     0 12:15:00
5501 2016-11-23 12:30:00   DC     PCL     0 12:30:00
5502 2016-11-23 12:30:00   DC     MCL     0 12:30:00
5503 2016-11-23 12:30:00   DC     CAR     8 12:30:00
5504 2016-11-23 12:30:00   DC    TAXI     0 12:30:00
5505 2016-11-23 12:30:00   DC     LGV     0 12:30:00
5506 2016-11-23 12:30:00   DC    OGV1     0 12:30:00
5507 2016-11-23 12:30:00   DC    OGV2     0 12:30:00
5508 2016-11-23 12:30:00   DC     CDB     0 12:30:00
5509 2016-11-23 12:30:00   DC     BEB     1 12:30:00
5510 2016-11-23 12:30:00   DC      OB     0 12:30:00
5511 2016-11-23 12:45:00   DC     PCL     1 12:45:00
5512 2016-11-23 12:45:00   DC     MCL     0 12:45:00
5513 2016-11-23 12:45:00   DC     CAR     9 12:45:00
5514 2016-11-23 12:45:00   DC    TAXI     0 12:45:00
5515 2016-11-23 12:45:00   DC     LGV     1 12:45:00
5516 2016-11-23 12:45:00   DC    OGV1     0 12:45:00
5517 2016-11-23 12:45:00   DC    OGV2     0 12:45:00
5518 2016-11-23 12:45:00   DC     CDB     0 12:45:00
5519 2016-11-23 12:45:00   DC     BEB     0 12:45:00
5520 2016-11-23 12:45:00   DC      OB     0 12:45:00
5521 2016-11-23 13:00:00   DC     PCL     1 13:00:00
5522 2016-11-23 13:00:00   DC     MCL     0 13:00:00
5523 2016-11-23 13:00:00   DC     CAR     8 13:00:00
5524 2016-11-23 13:00:00   DC    TAXI     0 13:00:00
5525 2016-11-23 13:00:00   DC     LGV     1 13:00:00
5526 2016-11-23 13:00:00   DC    OGV1     0 13:00:00
5527 2016-11-23 13:00:00   DC    OGV2     0 13:00:00
5528 2016-11-23 13:00:00   DC     CDB     0 13:00:00
5529 2016-11-23 13:00:00   DC     BEB     0 13:00:00
5530 2016-11-23 13:00:00   DC      OB     0 13:00:00
5531 2016-11-23 13:15:00   DC     PCL     0 13:15:00
5532 2016-11-23 13:15:00   DC     MCL     0 13:15:00
5533 2016-11-23 13:15:00   DC     CAR    15 13:15:00
5534 2016-11-23 13:15:00   DC    TAXI     0 13:15:00
5535 2016-11-23 13:15:00   DC     LGV     0 13:15:00
5536 2016-11-23 13:15:00   DC    OGV1     0 13:15:00
5537 2016-11-23 13:15:00   DC    OGV2     0 13:15:00
5538 2016-11-23 13:15:00   DC     CDB     0 13:15:00
5539 2016-11-23 13:15:00   DC     BEB     1 13:15:00
5540 2016-11-23 13:15:00   DC      OB     0 13:15:00
5541 2016-11-23 13:30:00   DC     PCL     0 13:30:00
5542 2016-11-23 13:30:00   DC     MCL     0 13:30:00
5543 2016-11-23 13:30:00   DC     CAR     7 13:30:00
5544 2016-11-23 13:30:00   DC    TAXI     0 13:30:00
5545 2016-11-23 13:30:00   DC     LGV     1 13:30:00
5546 2016-11-23 13:30:00   DC    OGV1     0 13:30:00
5547 2016-11-23 13:30:00   DC    OGV2     0 13:30:00
5548 2016-11-23 13:30:00   DC     CDB     0 13:30:00
5549 2016-11-23 13:30:00   DC     BEB     0 13:30:00
5550 2016-11-23 13:30:00   DC      OB     0 13:30:00
5551 2016-11-23 13:45:00   DC     PCL     0 13:45:00
5552 2016-11-23 13:45:00   DC     MCL     0 13:45:00
5553 2016-11-23 13:45:00   DC     CAR    16 13:45:00
5554 2016-11-23 13:45:00   DC    TAXI     1 13:45:00
5555 2016-11-23 13:45:00   DC     LGV     1 13:45:00
5556 2016-11-23 13:45:00   DC    OGV1     0 13:45:00
5557 2016-11-23 13:45:00   DC    OGV2     0 13:45:00
5558 2016-11-23 13:45:00   DC     CDB     0 13:45:00
5559 2016-11-23 13:45:00   DC     BEB     0 13:45:00
5560 2016-11-23 13:45:00   DC      OB     0 13:45:00
5561 2016-11-23 14:00:00   DC     PCL     0 14:00:00
5562 2016-11-23 14:00:00   DC     MCL     0 14:00:00
5563 2016-11-23 14:00:00   DC     CAR    15 14:00:00
5564 2016-11-23 14:00:00   DC    TAXI     1 14:00:00
5565 2016-11-23 14:00:00   DC     LGV     1 14:00:00
5566 2016-11-23 14:00:00   DC    OGV1     0 14:00:00
5567 2016-11-23 14:00:00   DC    OGV2     0 14:00:00
5568 2016-11-23 14:00:00   DC     CDB     1 14:00:00
5569 2016-11-23 14:00:00   DC     BEB     0 14:00:00
5570 2016-11-23 14:00:00   DC      OB     0 14:00:00
5571 2016-11-23 14:15:00   DC     PCL     0 14:15:00
5572 2016-11-23 14:15:00   DC     MCL     0 14:15:00
5573 2016-11-23 14:15:00   DC     CAR     7 14:15:00
5574 2016-11-23 14:15:00   DC    TAXI     1 14:15:00
5575 2016-11-23 14:15:00   DC     LGV     0 14:15:00
5576 2016-11-23 14:15:00   DC    OGV1     0 14:15:00
5577 2016-11-23 14:15:00   DC    OGV2     0 14:15:00
5578 2016-11-23 14:15:00   DC     CDB     0 14:15:00
5579 2016-11-23 14:15:00   DC     BEB     1 14:15:00
5580 2016-11-23 14:15:00   DC      OB     0 14:15:00
5581 2016-11-23 14:30:00   DC     PCL     0 14:30:00
5582 2016-11-23 14:30:00   DC     MCL     0 14:30:00
5583 2016-11-23 14:30:00   DC     CAR     3 14:30:00
5584 2016-11-23 14:30:00   DC    TAXI     4 14:30:00
5585 2016-11-23 14:30:00   DC     LGV     1 14:30:00
5586 2016-11-23 14:30:00   DC    OGV1     0 14:30:00
5587 2016-11-23 14:30:00   DC    OGV2     0 14:30:00
5588 2016-11-23 14:30:00   DC     CDB     0 14:30:00
5589 2016-11-23 14:30:00   DC     BEB     0 14:30:00
5590 2016-11-23 14:30:00   DC      OB     0 14:30:00
5591 2016-11-23 14:45:00   DC     PCL     0 14:45:00
5592 2016-11-23 14:45:00   DC     MCL     0 14:45:00
5593 2016-11-23 14:45:00   DC     CAR     5 14:45:00
5594 2016-11-23 14:45:00   DC    TAXI     0 14:45:00
5595 2016-11-23 14:45:00   DC     LGV     0 14:45:00
5596 2016-11-23 14:45:00   DC    OGV1     0 14:45:00
5597 2016-11-23 14:45:00   DC    OGV2     0 14:45:00
5598 2016-11-23 14:45:00   DC     CDB     0 14:45:00
5599 2016-11-23 14:45:00   DC     BEB     0 14:45:00
5600 2016-11-23 14:45:00   DC      OB     0 14:45:00
5601 2016-11-23 15:00:00   DC     PCL     1 15:00:00
5602 2016-11-23 15:00:00   DC     MCL     0 15:00:00
5603 2016-11-23 15:00:00   DC     CAR    16 15:00:00
5604 2016-11-23 15:00:00   DC    TAXI     1 15:00:00
5605 2016-11-23 15:00:00   DC     LGV     2 15:00:00
5606 2016-11-23 15:00:00   DC    OGV1     0 15:00:00
5607 2016-11-23 15:00:00   DC    OGV2     0 15:00:00
5608 2016-11-23 15:00:00   DC     CDB     0 15:00:00
5609 2016-11-23 15:00:00   DC     BEB     0 15:00:00
5610 2016-11-23 15:00:00   DC      OB     0 15:00:00
5611 2016-11-23 15:15:00   DC     PCL     0 15:15:00
5612 2016-11-23 15:15:00   DC     MCL     0 15:15:00
5613 2016-11-23 15:15:00   DC     CAR    10 15:15:00
5614 2016-11-23 15:15:00   DC    TAXI     0 15:15:00
5615 2016-11-23 15:15:00   DC     LGV     1 15:15:00
5616 2016-11-23 15:15:00   DC    OGV1     0 15:15:00
5617 2016-11-23 15:15:00   DC    OGV2     0 15:15:00
5618 2016-11-23 15:15:00   DC     CDB     0 15:15:00
5619 2016-11-23 15:15:00   DC     BEB     1 15:15:00
5620 2016-11-23 15:15:00   DC      OB     0 15:15:00
5621 2016-11-23 15:30:00   DC     PCL     2 15:30:00
5622 2016-11-23 15:30:00   DC     MCL     0 15:30:00
5623 2016-11-23 15:30:00   DC     CAR     8 15:30:00
5624 2016-11-23 15:30:00   DC    TAXI     1 15:30:00
5625 2016-11-23 15:30:00   DC     LGV     1 15:30:00
5626 2016-11-23 15:30:00   DC    OGV1     0 15:30:00
5627 2016-11-23 15:30:00   DC    OGV2     0 15:30:00
5628 2016-11-23 15:30:00   DC     CDB     0 15:30:00
5629 2016-11-23 15:30:00   DC     BEB     0 15:30:00
5630 2016-11-23 15:30:00   DC      OB     0 15:30:00
5631 2016-11-23 15:45:00   DC     PCL     1 15:45:00
5632 2016-11-23 15:45:00   DC     MCL     0 15:45:00
5633 2016-11-23 15:45:00   DC     CAR    12 15:45:00
5634 2016-11-23 15:45:00   DC    TAXI     2 15:45:00
5635 2016-11-23 15:45:00   DC     LGV     1 15:45:00
5636 2016-11-23 15:45:00   DC    OGV1     0 15:45:00
5637 2016-11-23 15:45:00   DC    OGV2     0 15:45:00
5638 2016-11-23 15:45:00   DC     CDB     0 15:45:00
5639 2016-11-23 15:45:00   DC     BEB     0 15:45:00
5640 2016-11-23 15:45:00   DC      OB     0 15:45:00
5641 2016-11-23 16:00:00   DC     PCL     2 16:00:00
5642 2016-11-23 16:00:00   DC     MCL     0 16:00:00
5643 2016-11-23 16:00:00   DC     CAR    21 16:00:00
5644 2016-11-23 16:00:00   DC    TAXI     0 16:00:00
5645 2016-11-23 16:00:00   DC     LGV     0 16:00:00
5646 2016-11-23 16:00:00   DC    OGV1     0 16:00:00
5647 2016-11-23 16:00:00   DC    OGV2     0 16:00:00
5648 2016-11-23 16:00:00   DC     CDB     0 16:00:00
5649 2016-11-23 16:00:00   DC     BEB     0 16:00:00
5650 2016-11-23 16:00:00   DC      OB     0 16:00:00
5651 2016-11-23 16:15:00   DC     PCL     1 16:15:00
5652 2016-11-23 16:15:00   DC     MCL     0 16:15:00
5653 2016-11-23 16:15:00   DC     CAR    20 16:15:00
5654 2016-11-23 16:15:00   DC    TAXI     0 16:15:00
5655 2016-11-23 16:15:00   DC     LGV     2 16:15:00
5656 2016-11-23 16:15:00   DC    OGV1     0 16:15:00
5657 2016-11-23 16:15:00   DC    OGV2     0 16:15:00
5658 2016-11-23 16:15:00   DC     CDB     0 16:15:00
5659 2016-11-23 16:15:00   DC     BEB     0 16:15:00
5660 2016-11-23 16:15:00   DC      OB     0 16:15:00
5661 2016-11-23 16:30:00   DC     PCL     1 16:30:00
5662 2016-11-23 16:30:00   DC     MCL     0 16:30:00
5663 2016-11-23 16:30:00   DC     CAR    23 16:30:00
5664 2016-11-23 16:30:00   DC    TAXI     0 16:30:00
5665 2016-11-23 16:30:00   DC     LGV     0 16:30:00
5666 2016-11-23 16:30:00   DC    OGV1     0 16:30:00
5667 2016-11-23 16:30:00   DC    OGV2     0 16:30:00
5668 2016-11-23 16:30:00   DC     CDB     0 16:30:00
5669 2016-11-23 16:30:00   DC     BEB     1 16:30:00
5670 2016-11-23 16:30:00   DC      OB     0 16:30:00
5671 2016-11-23 16:45:00   DC     PCL     0 16:45:00
5672 2016-11-23 16:45:00   DC     MCL     0 16:45:00
5673 2016-11-23 16:45:00   DC     CAR    21 16:45:00
5674 2016-11-23 16:45:00   DC    TAXI     0 16:45:00
5675 2016-11-23 16:45:00   DC     LGV     0 16:45:00
5676 2016-11-23 16:45:00   DC    OGV1     0 16:45:00
5677 2016-11-23 16:45:00   DC    OGV2     0 16:45:00
5678 2016-11-23 16:45:00   DC     CDB     0 16:45:00
5679 2016-11-23 16:45:00   DC     BEB     0 16:45:00
5680 2016-11-23 16:45:00   DC      OB     0 16:45:00
5681 2016-11-23 17:00:00   DC     PCL     1 17:00:00
5682 2016-11-23 17:00:00   DC     MCL     0 17:00:00
5683 2016-11-23 17:00:00   DC     CAR    15 17:00:00
5684 2016-11-23 17:00:00   DC    TAXI     1 17:00:00
5685 2016-11-23 17:00:00   DC     LGV     0 17:00:00
5686 2016-11-23 17:00:00   DC    OGV1     0 17:00:00
5687 2016-11-23 17:00:00   DC    OGV2     0 17:00:00
5688 2016-11-23 17:00:00   DC     CDB     0 17:00:00
5689 2016-11-23 17:00:00   DC     BEB     0 17:00:00
5690 2016-11-23 17:00:00   DC      OB     0 17:00:00
5691 2016-11-23 17:15:00   DC     PCL     4 17:15:00
5692 2016-11-23 17:15:00   DC     MCL     0 17:15:00
5693 2016-11-23 17:15:00   DC     CAR    21 17:15:00
5694 2016-11-23 17:15:00   DC    TAXI     0 17:15:00
5695 2016-11-23 17:15:00   DC     LGV     2 17:15:00
5696 2016-11-23 17:15:00   DC    OGV1     0 17:15:00
5697 2016-11-23 17:15:00   DC    OGV2     0 17:15:00
5698 2016-11-23 17:15:00   DC     CDB     0 17:15:00
5699 2016-11-23 17:15:00   DC     BEB     0 17:15:00
5700 2016-11-23 17:15:00   DC      OB     0 17:15:00
5701 2016-11-23 17:30:00   DC     PCL     1 17:30:00
5702 2016-11-23 17:30:00   DC     MCL     0 17:30:00
5703 2016-11-23 17:30:00   DC     CAR    18 17:30:00
5704 2016-11-23 17:30:00   DC    TAXI     0 17:30:00
5705 2016-11-23 17:30:00   DC     LGV     0 17:30:00
5706 2016-11-23 17:30:00   DC    OGV1     0 17:30:00
5707 2016-11-23 17:30:00   DC    OGV2     0 17:30:00
5708 2016-11-23 17:30:00   DC     CDB     0 17:30:00
5709 2016-11-23 17:30:00   DC     BEB     1 17:30:00
5710 2016-11-23 17:30:00   DC      OB     0 17:30:00
5711 2016-11-23 17:45:00   DC     PCL     3 17:45:00
5712 2016-11-23 17:45:00   DC     MCL     0 17:45:00
5713 2016-11-23 17:45:00   DC     CAR    24 17:45:00
5714 2016-11-23 17:45:00   DC    TAXI     0 17:45:00
5715 2016-11-23 17:45:00   DC     LGV     0 17:45:00
5716 2016-11-23 17:45:00   DC    OGV1     0 17:45:00
5717 2016-11-23 17:45:00   DC    OGV2     0 17:45:00
5718 2016-11-23 17:45:00   DC     CDB     0 17:45:00
5719 2016-11-23 17:45:00   DC     BEB     0 17:45:00
5720 2016-11-23 17:45:00   DC      OB     0 17:45:00
5721 2016-11-23 18:00:00   DC     PCL     2 18:00:00
5722 2016-11-23 18:00:00   DC     MCL     0 18:00:00
5723 2016-11-23 18:00:00   DC     CAR    18 18:00:00
5724 2016-11-23 18:00:00   DC    TAXI     0 18:00:00
5725 2016-11-23 18:00:00   DC     LGV     1 18:00:00
5726 2016-11-23 18:00:00   DC    OGV1     0 18:00:00
5727 2016-11-23 18:00:00   DC    OGV2     0 18:00:00
5728 2016-11-23 18:00:00   DC     CDB     0 18:00:00
5729 2016-11-23 18:00:00   DC     BEB     0 18:00:00
5730 2016-11-23 18:00:00   DC      OB     0 18:00:00
5731 2016-11-23 18:15:00   DC     PCL     1 18:15:00
5732 2016-11-23 18:15:00   DC     MCL     0 18:15:00
5733 2016-11-23 18:15:00   DC     CAR    19 18:15:00
5734 2016-11-23 18:15:00   DC    TAXI     0 18:15:00
5735 2016-11-23 18:15:00   DC     LGV     0 18:15:00
5736 2016-11-23 18:15:00   DC    OGV1     0 18:15:00
5737 2016-11-23 18:15:00   DC    OGV2     0 18:15:00
5738 2016-11-23 18:15:00   DC     CDB     0 18:15:00
5739 2016-11-23 18:15:00   DC     BEB     0 18:15:00
5740 2016-11-23 18:15:00   DC      OB     0 18:15:00
5741 2016-11-23 18:30:00   DC     PCL     0 18:30:00
5742 2016-11-23 18:30:00   DC     MCL     0 18:30:00
5743 2016-11-23 18:30:00   DC     CAR    15 18:30:00
5744 2016-11-23 18:30:00   DC    TAXI     0 18:30:00
5745 2016-11-23 18:30:00   DC     LGV     1 18:30:00
5746 2016-11-23 18:30:00   DC    OGV1     0 18:30:00
5747 2016-11-23 18:30:00   DC    OGV2     0 18:30:00
5748 2016-11-23 18:30:00   DC     CDB     1 18:30:00
5749 2016-11-23 18:30:00   DC     BEB     1 18:30:00
5750 2016-11-23 18:30:00   DC      OB     0 18:30:00
5751 2016-11-23 18:45:00   DC     PCL     0 18:45:00
5752 2016-11-23 18:45:00   DC     MCL     0 18:45:00
5753 2016-11-23 18:45:00   DC     CAR     8 18:45:00
5754 2016-11-23 18:45:00   DC    TAXI     0 18:45:00
5755 2016-11-23 18:45:00   DC     LGV     1 18:45:00
5756 2016-11-23 18:45:00   DC    OGV1     0 18:45:00
5757 2016-11-23 18:45:00   DC    OGV2     0 18:45:00
5758 2016-11-23 18:45:00   DC     CDB     0 18:45:00
5759 2016-11-23 18:45:00   DC     BEB     0 18:45:00
5760 2016-11-23 18:45:00   DC      OB     0 18:45:00

当我运行代码时,它在时间范围内给出直的垂直线而不是连续的水平线

p<-ggplot(Trafic.df2, aes(x=TIME, y=Count1, group=vehicle)) +
geom_line(aes(color=vehicle))

p

我希望图表看起来像这样:

pftdvrlh

pftdvrlh1#

你应该提到colourgroup美学中的vehicle来创建多个连续的线条。我创建了一个可复制的示例数据:

Trafic.df2 <- data.frame(vehicle = c("PCL", "MCL", "CAR", "TAXI", "LGV", "OGV1", "OGV2", "CDB", "BEB", "OB", "PCL", "MCL", "CAR", "TAXI", "LGV", "OGV1", "OGV2", "CDB", "BEB", "OB", "PCL", "MCL", "CAR", "TAXI", "LGV", "OGV1", "OGV2", "CDB", "BEB", "OB"),
                 Count1 = runif(30, 0, 5),
                 TIME1 = c("07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:00:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:15:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00", "07:30:00"))

   vehicle     Count1    TIME1
1      PCL 4.60342740 07:00:00
2      MCL 4.69378275 07:00:00
3      CAR 3.92516450 07:00:00
4     TAXI 4.38129959 07:00:00
5      LGV 4.57192533 07:00:00
6     OGV1 3.71202981 07:00:00
7     OGV2 0.16943578 07:00:00
8      CDB 3.39898188 07:00:00
9      BEB 2.28041694 07:00:00
10      OB 0.36784521 07:00:00
11     PCL 4.24148947 07:15:00
12     MCL 1.08148816 07:15:00
13     CAR 2.67379600 07:15:00
14    TAXI 0.58097226 07:15:00
15     LGV 4.03152690 07:15:00
16    OGV1 0.41630204 07:15:00
17    OGV2 1.19749041 07:15:00
18     CDB 3.26995273 07:15:00
19     BEB 3.00905560 07:15:00
20      OB 1.16030767 07:15:00
21     PCL 2.76079835 07:30:00
22     MCL 1.84286273 07:30:00
23     CAR 4.57924276 07:30:00
24    TAXI 0.05042954 07:30:00
25     LGV 2.20119221 07:30:00
26    OGV1 4.61564323 07:30:00
27    OGV2 0.90202414 07:30:00
28     CDB 2.61759706 07:30:00
29     BEB 0.79251202 07:30:00
30      OB 1.09316959 07:30:00

您可以使用以下代码:

library(tidyverse)

Trafic.df2 %>%
  ggplot(aes(x = TIME1, y = Count1, colour = vehicle, group = vehicle)) +
  geom_line() +
  xlab("time") +
  ylab("count") +
  theme_minimal()

输出如下所示:

行不长,因为我只创建了三个不同时间点的数据。

相关问题