Giter Club home page Giter Club logo

Comments (5)

JosiahParry avatar JosiahParry commented on June 3, 2024 1

Confirmed that this is a bug with {arcgisbinding} CC @dpavlushko

library(arcgisbinding)
#> *** Please call arc.check_product() to define a desktop license.
arc.check_product()
arc.check_portal()

url <- "https://services1.arcgis.com/vkTwD8kHw2woKBqV/arcgis/rest/services/ESCAD_Current_Incidents_Public/FeatureServer/0"

tmp <- arc.open(url) |> 
  arc.select()

class(tmp$Response_Date)
#> [1] "POSIXt"  "POSIXct"

from r-bridge.

JosiahParry avatar JosiahParry commented on June 3, 2024

That's very odd. I do not know what happens with arcgisbinding, but arcgislayers uses as.POSIXct() to create the date time field. Perhaps there is somewhere else upstream where your class is being modified? I will create a feature service with date time to test with.

https://github.com/R-ArcGIS/arcgisutils/blob/494e17003c3fa5ca08ab2b5b9365126f01b15701/R/utils-dates.R#L42C1-L42C1

In the mean time here is a simple function to fix your classes with:

x <-  Sys.time()

class(x) <- rev(class(x))

restore_posixct <- function(x) {
  if (identical(class(x), c("POSIXt", "POSIXct"))) {
    class(x) <- rev(class(x))
  }
  x
}

class(x)
#> [1] "POSIXt"  "POSIXct"
class(restore_posixct(x))
#> [1] "POSIXct" "POSIXt"

Note that as.POSIXct() will not reorder the class attributes nor will lubridate::as_datetime() which leads me to think this might be a bug in dplyr or vctrs where the class order is being checked perhaps too strictly.

from r-bridge.

JosiahParry avatar JosiahParry commented on June 3, 2024

In the case of {arcgislayers}, the class is assigned correctly. Will report back with the result of arcgisbinding.

library(arcgis)
#> Attaching core arcgis packages:
#>   - {arcgisutils} v0.1.0
#>   - {arcgislayers} v0.1.0

url <- "https://services1.arcgis.com/vkTwD8kHw2woKBqV/arcgis/rest/services/ESCAD_Current_Incidents_Public/FeatureServer/0"
arc_open(url) |> 
  arc_select() -> tmp

class(tmp$Response_Date)
#> [1] "POSIXct" "POSIXt"

from r-bridge.

JosiahParry avatar JosiahParry commented on June 3, 2024

Fortunately a super simple fix that I'll try and address next week. It's just one line that needs to be changed. @Nova-Scotia, otherwise you can use arcgislayers to get the class assignment correct, or you can use the helper function above in the mean time. Sorry about this!

from r-bridge.

Nova-Scotia avatar Nova-Scotia commented on June 3, 2024

Thank you so much @JosiahParry! It took me longer than I'd like to admit to figure out what was happening... as usual making a minimal reproducible example helped me ferret out the issue.

from r-bridge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.