Open lgluca opened 6 years ago
Hi Georg, thanks for the kind words. 🍻😋
Also, thanks you for sharing your function. I imagine this could be helpful for other users, too. Given that psych::corr.test()
returns a proper S3 object, it should be straight forward to to add support for these objects to apa_print()
. I'll add it to the todo list, but I'm currently holding new features because we are trying to prepare the first CRAN release. So it might be a while before I can add proper support. Until then, you could simply use papaja::printnum()
to format the correlations. Simply use the following line in your function:
rnd <- printnum(r, gt1 = FALSE, digits = 2)
wow. you just solved a problem i have been having for 48h. I'll update the function. (beer offering is still on the table, and whatever I can do to help with the package)
Guys, thanks for this extremely helpful function. I could offer tea from northern Germany in exchange. ;-) If you are here or in Hagen, please stop by.
However, I received an error because describe() doesn't return a data.frame and, consequently, round() had nothing to round. I changed the respective part to this:
round(data.frame(describe(x))[,3:4],2)
Thank you very much!
Hi
If i make changes (i.e., i insert this (round(data.frame(describe(x))[,3:4],2)) line into the function. I get the following the error:
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class ‘"describe"’ to a data.frame
Any other ways I could get this function written by Georg to work?
Eager to hear
Cheers prasad
hello, i encountered the same problem when outputted the results of corr.test(). The error looks like "Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : cannot coerce class "c("psych", "corr.test")" to a data.frame". How can I transfer the results into a data.frame?or how can i export the results to a .csv file? thank you for your help regards alice
I think this question would be well suited for StackOverflow. If you provide a reproducible example of the problem, I'd be happy to try to answer it over there.
Hi, @lgluca ! I'm writing a paper with multilevel methods using papaja, and I was looking for a function to create a correlation matrix for multilevel data with within-level and between-level correlations below/above the diagonal, respectively. I came across your function, which I thought was great! I hope you don't mind, but I copied your function and adapted it slightly to accommodate multilevel data.
@crsh : If this can be used in a future version of papaja, please feel free. My adaptations of @lgluca 's code might not be particularly elegant, but it works. Or seems to, at least.
Looks like many solutions have been found here. If anyone wants a package which will do a correlation table compatible with apa_table I've got one hosted on CRAN made for this. Once papaja is up on CRAN I'll write a method to make the process easier.
#install.packages("corx")
library(corx)
x <- corx(mtcars[,1:6],
triangle = "lower",
stars = c(0.05, 0.01, 0.001),
describe = c(`$M$` = mean, `$SD$` = sd))
papaja::apa_table(x$apa, # apa contains the data.frame needed for apa_table
caption = "Example corr matrix",
note = "* p < 0.05; ** p < 0.01; *** p < 0.001",
escape = F)
Looks great, thank you for sharing!
Hi there! I have been using papaja for a while now and i find it terrific! Thanks for all the work, and saving hours of my time! (If you want some bavarian beer, just PM an address:)
And now to my issue: i have been trying to create a function that creates a correlation half-matrix, takes the M and SDs of the variables involved and put it all together in an APA format. I think it is a good function (and you can have it and implement it if you think its worthy), but you can see from the test below with the apa_table() function, i am not able to delete the leading zeroes, nor to align the to decimals as the APA format requires. I have found nothing of the sort in papaja... A big thank you,
Georg
tests and example