Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for formula with character vector of length > 1 #222

Closed
juliasilge opened this issue May 25, 2020 · 4 comments
Closed

Warning for formula with character vector of length > 1 #222

juliasilge opened this issue May 25, 2020 · 4 comments

Comments

@juliasilge
Copy link

I am seeing some warnings in the tests for tidytext because of the way this line is set up:

formula <- as.formula(as.character(formula)[c(1,3)])

The warning is:

Warning message:
Using formula(x) is deprecated when x is a character vector of length > 1.
  Consider formula(paste(x, collapse = " ")) instead. 

Looks like this was considered a bug fix in R 4.0:

formula(x) with length(x) > 1 character vectors, is deprecated now. Such use has been rare, and has ‘worked’ as expected in some cases only. In other cases, wrong x have silently been truncated, not detecting previous errors.

@stragu
Copy link

stragu commented Jul 16, 2020

All three examples from stm::estimateEffect() have the same warning:

library(stm)
#> stm v1.3.5 successfully loaded. See ?stm for help. 
#>  Papers, resources, and other materials at structuraltopicmodel.com
prep <- estimateEffect(c(1) ~ treatment, gadarianFit, gadarian)
#> Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
#>   Consider formula(paste(x, collapse = " ")) instead.
prep <- estimateEffect(1:3 ~ treatment, gadarianFit, gadarian)
#> Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
#>   Consider formula(paste(x, collapse = " ")) instead.
prep <- estimateEffect(1 ~ treatment*s(pid_rep), gadarianFit, gadarian)
#> Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
#>   Consider formula(paste(x, collapse = " ")) instead.

Created on 2020-07-16 by the reprex package (v0.3.0)

I'm seeing the same in ordinal::clmm() when using a long formula, not sure if that helps figuring it out:

library(ordinal)
data(wine)
# no warning:
mm <- clmm(rating ~ temp + contact + (1|judge),
           data = wine)
names(wine)[2] <- "a_very_very_very_very_very_long_name"
# warning:
mm <- clmm(a_very_very_very_very_very_long_name ~ temp + contact + (1|judge),
           data = wine)
#> Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
#>   Consider formula(paste(x, collapse = " ")) instead.

Created on 2020-07-16 by the reprex package (v0.3.0)

Looking very odd to me!

@ghost
Copy link

ghost commented Aug 15, 2020

Just echoing stragu with regard to the warning in ordinal::clmm.

This model

m <- clmm(JUDGMENT ~ 1 + NATIVE_LG * AGREEMENT + EMPHPRON + NEGATION + (1|SUBJECT), data=x)

runs fine but throws a warning message

Using formula(x) is deprecated when x is a character vector of length > 1.
  Consider formula(paste(x, collapse = " ")) instead.`

but if the last predictor is deleted, then it works without problems:

m <- clmm(JUDGMENT ~ 1 + NATIVE_LG * AGREEMENT + EMPHPRON + (1|SUBJECT), data=x)

Not sure how that bug fix even pertains to this issue ... weird

@stragu
Copy link

stragu commented Aug 15, 2020

Hi @stgries ! If you want to chat about clmm() specifically, I reported the issue here, just so you know: runehaubo/ordinal#34
Cheers

@bstewart
Copy link
Owner

Got this fixed. Sorry development has been on hold for a bit everyone. Thanks @juliasilge for flagging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants