ggplot gives "arguments imply differing number of rows" error in geom_point while it isn't true - how to debug?


I got around this by making a new data frame.


It seems that ggplot no longer likes have data-less geom components, as the prior version I used was perfectly okay with using aes(x=c(0,100000),y=c(0,100000).

Author by


Updated on August 17, 2022


  • mrz
    mrz about 1 year

    I have two objects of type Large SpatialPointsDataFrame named st2 and st10. They come from the same source. They both plot without problems with:




    But I want to plot them with ggmap and ggplot. I can do this for st2 with a simple code like this:

    map <- get_map(location = 'Poznań', zoom = 12)
    ggmap(map) + geom_point(aes(x =st2@coords[,1], y = st2@coords[,2]))

    But when it comes to st10 I get an error:

    Error in data.frame(x = c(16.910848618, 16.910863876, 16.910913467, 16.910936356,  :   
    arguments imply differing number of rows: 53885, 4

    I check the values with length():

    > length(st10@coords[,1])
    [1] 53885
    > length(st10@coords[,2])
    [1] 53885

    I check them with summary()

    > summary(st10@coords[,1])
       Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      16.84   16.88   16.91   16.91   16.91   16.99 
    > summary(st10@coords[,2])
       Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      52.35   52.41   52.46   52.44   52.46   52.46 

    What is wrong? I have over 20 of those SP data frames and some of the plot well other give the error mentioned above...this is not related to number of points

    What can be wrong? Or maybe someone can give me some tips how can i debug this?