我有一个包含变量violation1的数据框,其中包含违规类型。
对于某些字符串,我使用下面的代码将它们排除在外。
camparking <- camparking[ grep("OTHER", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("BL- BIKE LANE", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("CENTER STRIP/ISLAND", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("NOT IN METER SPACE", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("OVRNGHT HEAVY VEHCLE", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("PEDESTRIAN ZONE", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("SNOW/WEATHER EMRGY", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("DRIVEWAY", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("HANDICAP RAMP", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("OVER 1FT FROM CURB", camparking$Violation1, invert = TRUE) , ]
camparking <- camparking[ grep("TAXI STAND", camparking$Violation1, invert = TRUE) , ]
我使用summary()来总结每种违规类型的总数,排除的字符串显示为零值。
当我使用此结果绘制条形图时,条形图将显示包含零的值。
1)有没有办法删除这些字符串,使其不会显示在条形图中?恩。删除BL-BIKE LANE或TAXI STAND?
2)有没有办法在该图表的空白处创建一个框,我可以列出违规类型?