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

'apa_print' doesn't work for object of class "afex_aov" #361

Closed
alexholcombe opened this issue Apr 17, 2020 · 20 comments · Fixed by #367
Closed

'apa_print' doesn't work for object of class "afex_aov" #361

alexholcombe opened this issue Apr 17, 2020 · 20 comments · Fixed by #367
Assignees
Labels

Comments

@alexholcombe
Copy link
Contributor

Describe the bug
"No applicable method for 'apa_print' applied to an object of class "afex_aov"" even though it's mentioned in the manual here: https://crsh.github.io/papaja_man/reporting.html

To Reproduce

mtcar<- mtcars %>% mutate(rownum = row_number())

mt_anova <- afex::aov_ez(
  data = mtcar
  , dv = "mpg"
  , id = "rownum" #subj
  , between = c("cyl")
)
#This doesn't work even though it's mentioned in the manual here https://crsh.github.io/papaja_man/reporting.html
apa_anova <- papaja::apa_print(mt_anova)

Error in UseMethod("apa_print", x) : no applicable method for 'apa_print' applied to an object of class "afex_aov"

Expected behavior
Print object

@crsh
Copy link
Owner

crsh commented Apr 17, 2020

Hi Alex, I can reproduce this and I'll have to take a closer look when I find some time. It appears this is somehow related to the S3 method dispatch. It works for me when I either first load papaja or call the S3 method directly:

apa_anova <- papaja::apa_print.afex_aov(mt_anova) 

@mariusbarth
Copy link
Collaborator

Hi guys, I just figured out what the problem is: roxygen2 seems to have problems disambiguating S3 methods for apa_print(), which results in creating an erroneous NAMESPACE file, with the methods exported as separate functions. I'm just testing a possible solution, will keep you posted.

See also hadley Wickham's recent addition to his book mentioning this problem.

@crsh
Copy link
Owner

crsh commented May 13, 2020

Related: #250

@mariusbarth mariusbarth self-assigned this May 13, 2020
@mariusbarth mariusbarth linked a pull request May 13, 2020 that will close this issue
@shirdekel
Copy link

I'm still getting the same error as @alexholcombe (when using his reprex), even after installing from the development branch. However, the following works (as per @mariusbarth's comment):

apa_anova <- papaja:::apa_print.afex_aov(mt_anova)

Session Info
Session info ────────────────────────────
 setting  value                       
 version  R version 3.5.3 (2019-03-11)
 os       macOS Mojave 10.14.6        
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_AU.UTF-8                 
 ctype    en_AU.UTF-8                 
 tz       Australia/Sydney            
 date     2020-06-08  

RStudio version: 1.3.300

@mariusbarth
Copy link
Collaborator

Hi @shirdekel, thanks for reporting this!.
With R 3.5,, you would have to use the syntax papaja::apa_print.afex_aov(mt_anova). However, I think it's better to update R, because otherwise your code will break as soon as you update later.
Would be great if you could try updating R and tell me whether it works then.

@crsh
Copy link
Owner

crsh commented Jun 8, 2020

In my opinion, the best approach to avoid any of these problems is to load papaja via library("papaja") rather than calling apa_print via :: or :::.

@mariusbarth
Copy link
Collaborator

I'm right there with you!

@shirdekel
Copy link

@crsh, at the moment, even loading papaja first doesn't fix it for me. Will upgrade R, as @mariusbarth suggested and see if that helps.

@shirdekel
Copy link

Upgraded to R 4.0.1, and it works fine now. Thanks everyone!

@mariusbarth
Copy link
Collaborator

Perfect, thanks for your efforts!

crsh added a commit that referenced this issue Jun 8, 2020
@crsh
Copy link
Owner

crsh commented Jun 8, 2020

Thanks @shirdekel, I have updated the R dependency to >= 3.6 on the devel branch.

@intanwardhani
Copy link

Hello @crsh ! I'm new to papaja, so I used the example file from ECVP 2019 tutorial to see how it worked. I ran it on R 4.0.2, but I still got the aforementioned error. Below is the error message. I wonder where that went wrong.

Quitting from lines 319-375 (manuscript-v1.rmd) Error in UseMethod("apa_print", x) : no applicable method for 'apa_print' applied to an object of class "afex_aov"

@crsh
Copy link
Owner

crsh commented Jun 24, 2020

Are you using the current development version (remotes::install_github("crsh/papaja@devel"))?

@intanwardhani
Copy link

Oops, my bad! It works with the current development version. The pdf rendering works well, but the word rendering looks a bit awkward (as already addressed as a limitation) and always opens via Skype, for some reason... I wonder if that also happens to others and a new issue should be opened? Thanks for your prompt response!

@alexholcombe
Copy link
Contributor Author

alexholcombe commented Jun 24, 2020 via email

@alexholcombe
Copy link
Contributor Author

The Skype thing is definitely not related to papaja, I believe, as I also have the problem when knitting other RMarkdown documents.

@crsh
Copy link
Owner

crsh commented Jun 25, 2020

Thanks for confirming this. So this is either a more general issue with rmarkdown/knitr or pandoc. If you want to get to the bottom of this, you could try directly converting a Markdown document to Word with pandoc.

@mariusbarth mariusbarth added this to the First CRAN release milestone Jul 8, 2020
@hcp4715
Copy link

hcp4715 commented Jan 25, 2021

Hi, there,

I had an error when using 'apa_print.afex_aov()', but without problem when using apa_print().

I dowloaded the latest version of papaja, see below, and reproduced @alexholcombe 's code.

Session info:

 version  R version 4.0.3 (2020-10-10)
 os       Ubuntu 20.04.1 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8  
papaja         * 0.1.0.9997 2021-01-25 [1] Github (crsh/papaja@ef14546)    

The results were:

> apa_anova <- papaja::apa_print(mt_anova)
> apa_anova
$estimate
$estimate$cyl
[1] "$\\hat{\\eta}^2_G = .732$"


$statistic
$statistic$cyl
[1] "$F(2, 29) = 39.70$, $\\mathit{MSE} = 10.39$, $p < .001$"


$full_result
$full_result$cyl
[1] "$F(2, 29) = 39.70$, $\\mathit{MSE} = 10.39$, $p < .001$, $\\hat{\\eta}^2_G = .732$"


$table
A data.frame with 7 labelled columns:

  term estimate statistic df df.residual   mse p.value
1  Cyl     .732     39.70  2          29 10.39  < .001

term       : Effect 
estimate   : $\\hat{\\eta}^2_G$ 
statistic  : $F$ 
df         : $\\mathit{df}$ 
df.residual: $\\mathit{df}_{\\mathrm{res}}$ 
... (2 more labels)
attr(,"class")
[1] "apa_results" "list"       
> apa_anova <- papaja::apa_print.afex_aov(mt_anova)
Error: 'apa_print.afex_aov' is not an exported object from 'namespace:papaja'
> library(papaja)
> apa_anova <- apa_print.afex_aov(mt_anova)
Error in apa_print.afex_aov(mt_anova) : 
  could not find function "apa_print.afex_aov"

@mariusbarth
Copy link
Collaborator

mariusbarth commented Jan 25, 2021

Hi @hcp4715,

calling methods directly via papaja::apa_print.afex_aov() is not intended to work, you should just use apa_print(). See here for an explanation and more details.

@hcp4715
Copy link

hcp4715 commented Jan 25, 2021

Hi, @mariusbarth ,

thanks for your quick response!
good to know that using apa_print() it's the right way.

@crsh crsh closed this as completed Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants