简体   繁体   English

ggplot错误,x轴上带有日期字符串

[英]ggplot error with date string on x-axis

I am trying to plot localminute as x-axis and meter_value as y-axis. 我试图将localminute为x轴,并将meter_value为y轴。 Dataset has 11.9K rows, here's a snippet: 数据集有11.9K行,下面是一个代码段:

localminute,dataid,meter_value
2016-01-01 05:18:49.497023-06,35,98178  
2016-01-01 05:45:43.51577-06,35,98182  
2016-01-01 05:57:45.024395-06,35,98184  
2016-01-01 06:08:41.532267-06,35,98186  
2016-01-01 06:36:50.053034-06,35,98188  
2016-01-01 06:56:53.066606-06,35,98192  
2016-01-01 08:57:53.65758-06,35,98212  

I used "ggplot" comment but got error "error in usemethod("depth") :... 我使用了“ ggplot”注释,但收到错误“ usemethod(“ depth”)中的错误:...

test <- read.csv("test_35.csv")  #read data in csv file, to plot data
ggplot(test, aes(x=localminute, y=meter_value)) + geom_point() +
      ggtitle("meter value for dataID=35") +
      theme(axis.text.x = element_text(angle=90, hjust=1))

Error in UseMethod("depth") : 
  no applicable method for 'depth' applied to an object of class "NULL"`

在读取文件时指定变量的格式:

test <- read.csv('test_35.csv', colClasses = c('POSIXct','integer','integer'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM