[R-pkg-devel] “unable to find an inherited method” error in choroplethr package

2016-03-25 Thread arilamstein
Recently the functionality in the choroplethr
<https://cran.r-project.org/web/packages/choroplethr/index.html> package
that depends on the acs
<https://cran.r-project.org/web/packages/acs/index.html> package has
stopped working. I've been able to narrow down the cause, but cannot figure
out how to fix it. Any help would be appreciated. To reproduce the error
you can type:

install.packages("choroplethr")

library(choroplethr)

?get_state_demographics

get_state_demographics()

Error in (function (classes, fdef, mtable)  :

unable to find an inherited method for function ‘geography’ for signature
"matrix"’

(Note: you will need to set a census API key for this example to "work".
See here
<https://cran.r-project.org/web/packages/choroplethr/vignettes/e-mapping-us-census-data.html>
for instructions).

I believe that this error was introduced by version 2.0 of the acs package,
which was just released. I suspect that choroplethr is either not importing
something that it should be importing, or acs is not exporting something
that it should be exporting. For example, the problem can be fixed by
simply loading the acs package first:

library(acs)

get_state_demographics()



The acs package uses both S3 and S4, which I do not have much experience
with. I have been reading Hadley's excellent chapter on Namespaces
<http://r-pkgs.had.co.nz/namespace.html>, and tweaked various import
directives in the choroplethr package (the actual code that crashes is here
<https://github.com/arilamstein/choroplethr/blob/master/R/get_state_demograhpics.R#L42>).
But I am still not sure how to fix this problem.. Any help would be
appreciated.

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Re: [R-pkg-devel] “unable to find an inherited method” error in choroplethr package

2016-03-28 Thread arilamstein
Unfortunately I am still getting the same error:

install.packages(c("choroplethr", "acs"))
library(acs)
api.key.install("f8b2a6df01479981aef39577b3c4466f5a4c8274")
detach("package:acs", unload=TRUE)

library(choroplethr)
get_state_demographics()
Error in (function (classes, fdef, mtable)  :
unable to find an inherited method for function ‘geography’ for
signature ‘"matrix"’

Someone suggested that I import the acs class in my NAMESPACE. But even
after adding:

importClassesFrom(acs,acs)

I get the same error.


On Sun, Mar 27, 2016 at 11:52 AM, Uwe Ligges <
lig...@statistik.tu-dortmund.de> wrote:

> Has this been resolved now?
>
> I cannot reproduce the problem as I get:
>
> > library(choroplethr)
> >
> > ?get_state_demographics
> starting httpd help server ... done
> >
> > get_state_demographics()
> Error in (function (classes, fdef, mtable)  :
>   unable to find an inherited method for function ‘geography’ for
> signature ‘"logical"’
> In addition: Warning message:
> In acs::acs.fetch(geography = state_geo, table.number = "B03002",  :
>   'key' required to access Census API site for download;
>   See http://www.census.gov/developers/ to request a key
>   and/or use 'key=' (or run 'api.key.install()') to avoid this error.
>
>
> Best,
> Uwe Ligges
>
>
>
> On 25.03.2016 21:55, arilamst...@gmail.com wrote:
>
>> Recently the functionality in the choroplethr
>> <https://cran.r-project.org/web/packages/choroplethr/index.html> package
>> that depends on the acs
>> <https://cran.r-project.org/web/packages/acs/index.html> package has
>> stopped working. I've been able to narrow down the cause, but cannot
>> figure
>> out how to fix it. Any help would be appreciated. To reproduce the error
>> you can type:
>>
>> install.packages("choroplethr")
>>
>> library(choroplethr)
>>
>> ?get_state_demographics
>>
>> get_state_demographics()
>>
>> Error in (function (classes, fdef, mtable)  :
>>
>> unable to find an inherited method for function ‘geography’ for signature
>> "matrix"’
>>
>> (Note: you will need to set a census API key for this example to "work".
>> See here
>> <
>> https://cran.r-project.org/web/packages/choroplethr/vignettes/e-mapping-us-census-data.html
>> >
>> for instructions).
>>
>> I believe that this error was introduced by version 2.0 of the acs
>> package,
>> which was just released. I suspect that choroplethr is either not
>> importing
>> something that it should be importing, or acs is not exporting something
>> that it should be exporting. For example, the problem can be fixed by
>> simply loading the acs package first:
>>
>> library(acs)
>>
>> get_state_demographics()
>>
>> 
>>
>> The acs package uses both S3 and S4, which I do not have much experience
>> with. I have been reading Hadley's excellent chapter on Namespaces
>> <http://r-pkgs.had.co.nz/namespace.html>, and tweaked various import
>> directives in the choroplethr package (the actual code that crashes is
>> here
>> <
>> https://github.com/arilamstein/choroplethr/blob/master/R/get_state_demograhpics.R#L42
>> >).
>> But I am still not sure how to fix this problem.. Any help would be
>> appreciated.
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>
>>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Re: [R-pkg-devel] “unable to find an inherited method” error in choroplethr package

2016-03-28 Thread arilamstein
r instructions).
>>
>> I believe that this error was introduced by version 2.0 of the
>> acs package,
>> which was just released. I suspect that choroplethr is either
>> not importing
>> something that it should be importing, or acs is not exporting
>> something
>> that it should be exporting. For example, the problem can be
>> fixed by
>> simply loading the acs package first:
>>
>> library(acs)
>>
>> get_state_demographics()
>>
>> 
>>
>> The acs package uses both S3 and S4, which I do not have much
>> experience
>> with. I have been reading Hadley's excellent chapter on Namespaces
>> <http://r-pkgs.had.co.nz/namespace.html>, and tweaked various
>> import
>> directives in the choroplethr package (the actual code that
>> crashes is here
>> <
>> https://github.com/arilamstein/choroplethr/blob/master/R/get_state_demograhpics.R#L42
>> >).
>> But I am still not sure how to fix this problem.. Any help would
>> be
>> appreciated.
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-package-devel@r-project.org
>> <mailto:R-package-devel@r-project.org> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>
>>
>>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Re: [R-pkg-devel] “unable to find an inherited method” error in choroplethr package

2016-03-30 Thread arilamstein
> that depends on the acs
>>> <https://cran.r-project.org/web/packages/acs/index.html>
>>> package has
>>> stopped working. I've been able to narrow down the cause, but
>>> cannot figure
>>> out how to fix it. Any help would be appreciated. To reproduce
>>> the error
>>> you can type:
>>>
>>> install.packages("choroplethr")
>>>
>>> library(choroplethr)
>>>
>>> ?get_state_demographics
>>>
>>> get_state_demographics()
>>>
>>> Error in (function (classes, fdef, mtable)  :
>>>
>>> unable to find an inherited method for function ‘geography’ for
>>> signature
>>> "matrix"’
>>>
>>> (Note: you will need to set a census API key for this example to
>>> "work".
>>> See here
>>> <
>>> https://cran.r-project.org/web/packages/choroplethr/vignettes/e-mapping-us-census-data.html
>>> >
>>> for instructions).
>>>
>>> I believe that this error was introduced by version 2.0 of the
>>> acs package,
>>> which was just released. I suspect that choroplethr is either
>>> not importing
>>> something that it should be importing, or acs is not exporting
>>> something
>>> that it should be exporting. For example, the problem can be
>>> fixed by
>>> simply loading the acs package first:
>>>
>>> library(acs)
>>>
>>> get_state_demographics()
>>>
>>> 
>>>
>>> The acs package uses both S3 and S4, which I do not have much
>>> experience
>>> with. I have been reading Hadley's excellent chapter on
>>> Namespaces
>>> <http://r-pkgs.had.co.nz/namespace.html>, and tweaked various
>>> import
>>> directives in the choroplethr package (the actual code that
>>> crashes is here
>>> <
>>> https://github.com/arilamstein/choroplethr/blob/master/R/get_state_demograhpics.R#L42
>>> >).
>>> But I am still not sure how to fix this problem.. Any help would
>>> be
>>> appreciated.
>>>
>>>  [[alternative HTML version deleted]]
>>>
>>> __
>>> R-package-devel@r-project.org
>>> <mailto:R-package-devel@r-project.org> mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>>
>>>
>>>
>

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

[R-pkg-devel] Package broke with R 4.3.0

2023-06-27 Thread arilamstein
It appears that my R package choroplethr broke due to this change in R
4.3.0:

CHANGES IN R 4.3.0:

SIGNIFICANT USER-VISIBLE CHANGES:

Calling && or || with LHS or (if evaluated) RHS of length greater than one
is now always an error, with a report of the form

'length = 4' in coercion to 'logical(1)'
Environment variable R_CHECK_LENGTH_1_LOGIC2 no longer has any effect.

The specific line which broke is this:
https://github.com/arilamstein/choroplethr/blob/master/R/usa.R#L24

The bug can be reproduced like this:

zoom = c("arizona", "arkansas", "louisiana", "minnesota", "mississippi",
  "montana", "new mexico", "north dakota", "oklahoma", "pennsylvania",
  "tennessee", "virginia", "california", "delaware", "west virginia",
  "wisconsin", "wyoming", "alabama", "alaska", "florida", "idaho",
  "kansas", "maryland", "colorado", "new jersey", "north carolina",
  "south carolina", "washington", "vermont", "utah", "iowa",
"kentucky",
  "maine", "massachusetts", "connecticut", "michigan", "missouri",
  "nebraska", "nevada", "new hampshire", "new york", "ohio", "oregon",
  "rhode island", "south dakota", "district of columbia", "texas",
  "georgia", "hawaii", "illinois", "indiana")

if (zoom == "alaska" || zoom == "hawaii") {}
Error in zoom == "alaska" || zoom == "hawaii" :
  'length = 51' in coercion to 'logical(1)'

I have two questions:

1. Can someone explain why this change was introduced to the language?
2. Can someone tell me if there is a preferred, idiomatic way to rewrite my
code?

I came up with two solutions that work. The first checks whether zoom is of
length 1:

if ((length(zoom) == 1) && (zoom %in% c("alaska", "hawaii"))) { }

The second keeps the vector recycling, but then uses all to coerce the
vector to be a single value. In retrospect, I think I likely assumed that
this is what R < 4.3.0 was doing when the code worked. (But I wrote this
code many years ago, so I can't be sure!):

if (all(zoom == "alaska") || all(zoom == "hawaii")) {}

Thanks in advance.

Ari

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] New R CMD check warnings for html files

2023-06-30 Thread arilamstein
Background: An old package that I maintain on CRAN recently stopped working
due to changes in R 4.3.0. In a previous post (
https://stat.ethz.ch/pipermail/r-package-devel/2023q2/009268.html) people
here helped me find the best solution to the crash bug.

I would like to push this fix to CRAN as quickly as possible. However, when
I run R CMD check I now get a ton of warnings in what I assume is the
conversion of the man files from .Rd to .html files. I assume that CRAN
will reject the package due to the warnings. However, I don't really
understand the warnings, or why they are occurring now (they did not happen
before). Can someone here help me?

The last group of the warnings:

visualize_df_by_race_ethnicity_party.html:4:1
(visualize_df_by_race_ethnicity_party.Rd:5): Warning:  inserting
"type" attribute
visualize_df_by_race_ethnicity_party.html:12:1
(visualize_df_by_race_ethnicity_party.Rd:5): Warning: