rOpenSpain / CatastRo

R package to query Sede Electrónica del Catastro (Spain)
http://ropenspain.github.io/CatastRo/
GNU General Public License v2.0
19 stars 5 forks source link

Error: $ operator is invalid for atomic vectors #23

Closed calejero closed 2 years ago

calejero commented 2 years ago

I tried to run this code:

options(repos = c(
  ropenspain = "https://ropenspain.r-universe.dev",
  CRAN = "https://cloud.r-project.org"
))
install.packages("CatastRo")

library(CatastRo)
catr_ovc_get_cpmrc(rc = '13077A01800039')

Console result:

> catr_ovc_get_cpmrc(rc = '13077A01800039')
Error: $ operator is invalid for atomic vectors

NOTE I have analyzed code and I think problem is here:

valid_srs <- valid_srs[valid_srs$ovc_service == TRUE, "SRS"]
valid <- as.character(valid_srs$SRS)

valid_srs is a vector object, not a data.frame. So, when you try to convert valid_srs$SRS into character vector you obtain a error.

UPDATE

Error is solved when I run directly library(tibble)

I have validated that tibble is included to be imported inside Imports into Description file.

dieghernan commented 2 years ago

Thanks for the report. Is this still happening? Please also note that CatastRo is already on CRAN:

https://cran.r-project.org/web/packages/CatastRo/index.html

Could you please recheck after installing the CRAN version?:


install.packages("CatastRo")

library(CatastRo)
catr_ovc_get_cpmrc(rc = '13077A01800039')
dieghernan commented 2 years ago

Also, note that valid_srs should be a tibble, as it comes from catastro::catr_srs_values, that is a tibble as well:

https://github.com/rOpenSpain/CatastRo/blob/6b7e892f1ff90c19ce4c866a0decfe6961c84554/data-raw/catr_srs_values.R#L7:L25

https://github.com/rOpenSpain/CatastRo/blob/6b7e892f1ff90c19ce4c866a0decfe6961c84554/R/ovc_cpmrc.R#L58

calejero commented 2 years ago

Yep but I don't know the reason about when I load package tibble is not loaded automatically.

I must execute explicitly library(tibble) to can execute code without troubles

El mié., 2 mar. 2022 19:50, Diego H. @.***> escribió:

Also, note that valid_srs should be a tibble, as it comes from catastro::catr_srs_values, that is a tibble as well:

https://github.com/rOpenSpain/CatastRo/blob/6b7e892f1ff90c19ce4c866a0decfe6961c84554/data-raw/catr_srs_values.R#L7:L25

— Reply to this email directly, view it on GitHub https://github.com/rOpenSpain/CatastRo/issues/23#issuecomment-1057266919, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN2ZQCCPAAJRASTJXEXVBRTU56Z5ZANCNFSM5PTMY5TQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

dieghernan commented 2 years ago

I would have a look, thanks

dieghernan commented 2 years ago

I added a fix for this, could you please recheck the code with the dev version?:


options(repos = c(
  ropenspain = "https://ropenspain.r-universe.dev",
  CRAN = "https://cloud.r-project.org"
))
install.packages("CatastRo")

library(CatastRo)
catr_ovc_get_cpmrc(rc = '13077A01800039')
calejero commented 2 years ago

Test completed.

Runs correctly.

El jue, 3 mar 2022 a las 15:47, Diego H. @.***>) escribió:

I added a fix for this, could you please recheck the code with the dev version?:

options(repos = c( ropenspain = "https://ropenspain.r-universe.dev", CRAN = "https://cloud.r-project.org" )) install.packages("CatastRo")

library(CatastRo) catr_ovc_get_cpmrc(rc = '13077A01800039')

— Reply to this email directly, view it on GitHub https://github.com/rOpenSpain/CatastRo/issues/23#issuecomment-1058115532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN2ZQCD6W4SRGUGTSTDZWIDU6DGIHANCNFSM5PTMY5TQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

dieghernan commented 2 years ago

Many thanks