• Register
0 votes
725 views

Problem :

I am getting error while using ggplot2 to plot the graphs

error in usemethod("depth") : no applicable method for 'depth' applied to an object of class "null"

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Bellow solution should work:

 scale_x_datetime(date_breaks = "1 day", date_labels = "%d/%m/%Y %H:%M:%S", minor_breaks = NULL) +

If plotly is not working for you then there are a few more ways that you could zoom in on your data.

  1. Filter at the source: you could filter in the data as it goes into ggplot.
a <- ggplot(test3a %>% 
         filter(localminute >= ymd(20151001),
                localminute <= ymd(20151031)),
       aes(x = localminute, y = meter_value)) + 
  1. Set limits in scale_x_datetime: This has the same result as filtering the data.
 scale_x_datetime(date_breaks = "1 day", date_labels = "%d/%m %Y %H:%M:%S", minor_breaks = NULL,
                   limits = c(ymd_hm(201510010000), ymd_hm(201510022359))) +
  1. Use coord_cartesian:  It preserves other data that's out of range for your other layers to use, even if you're not showing it. For instance, if you had a geom_smooth layer, you'd want to use this option...
coord_cartesian(xlim = c(ymd_hm(201510010000), ymd_hm(201510011000))) +

9 7 4
38,600 points

Related questions

0 votes
1 answer 2K views
2K views
Problem : I think my dataframe is correct and my code is also okay. But I am facing following error: Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state What is wrong with my below data? date trt var val 1/12/2019 cc sw5 0.2684138 1/12/2019 ... ] Also I want to make the scatterplot as follows: ggplot(data = df,aes(x = date,y = val)) + geom_point(aes(group = trt))
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 37 views
37 views
Problem: Why I got the error: Error in is.finite(x) : default method not implemented for type 'list'.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 3.7K views
3.7K views
Problem : Currently I am trying to create a heatmap using a ggmosaic, But I keep facing below error &ldquo;Error in is.finite(x) : default method not implemented for type 'list'&rdquo; My Configuration is Windows, RStudio, R version mostly one before a most recent, and ggmosaic Ver 0.1.2 How can I fix the above error?
asked Feb 20, 2020 mphil 2.3k points
1 vote
1 answer 83 views
83 views
Problem: I am a naive to R. I am trying to create the bar graph using the ggplot2 to compare a type of 2016 primary election and the Bernie Sanders's respective percentage of the votes in that election. I have below code: y = $ Type : Factor w/ 2 levels ... data of class uneval. I have already tried to search the solution on above error around but because of some unknown reasons to me I am stuck.
asked May 27, 2020 Martin K 6.6k points
1 vote
1 answer 61 views
61 views
Problem : I am trying to understand R and I am very new to Programming as wel. If I try to create the box chart with the use of standard error bars I often face below error message: “Error: ggplot2 doesn't know how to deal with data of class numeric”. Looking for help in quick fixing the above error.
asked May 5, 2020 stewart 4k points
1 vote
2 answers 103 views
103 views
Problem : I have recently started using R I am very new to R while working on R I am facing the below error whenever I try to create the graph on the ggplot: &ldquo;Error: ggplot2 doesn't know how to deal with data of class gg/ggplot&rdquo; I often face the error message if ... = Cost)) MyCars %>% ggplot() %>% geom_point(mapping = aes(x = Destination, y = Cost)) I need help in fixing above error.
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 8 views
8 views
Problem : I need answer to bellow issue don't know how to automatically pick scale for object of type data.frame. defaulting to continuous.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.5K views
1.5K views
Problem : I need answer to bellow issue don't know how to automatically pick scale for object of type data.frame. defaulting to continuous.
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 24 views
24 views
Problem: how i can fix this ? any help ! error: cannot add ggproto objects together. did you forget to add this object to a ggplot object?.
asked Mar 6 Wafa Abu Yousef 6.1k points
1 vote
1 answer 2.8K views
2.8K views
Problem : I am facing error related to ggproto as following error: cannot add ggproto objects together. did you forget to add this object to a ggplot object?
asked Nov 11, 2019 peterlaw 6.9k points