Code Monkey home page Code Monkey logo

apa.cor's Introduction

apa.cor - A correlation matrix in R, using APA style

GitHub last commit

What it does:

This single-function package is designed to be a fast way of creating a correlation matrix from a dataframe that includes the needed variables. It also produces means, standard deviations and NHS significance tests at various levels, with an export function for the clipboard.

It is also a good tool of creating an S3 object that plugs in well into the papaja: Prepare APA Journal Articles with R Markdown package, to produce a correlation table afer the APA manuscript guidelines.

Installation

To install the latest (see latest changes below), type the following commands into the R console:

library(devtools)
devtools::install_github("GGLuca/apa.cor")

Example of Recommended Usage

To create a correlation matrix for the Agreeableness items from the bfidataset (psych package, 25 Personality items representing 5 factors):

library(tidyverse)    # load Tidyverse
library(psych)        # load package psych for the `bfi`dataset
library(apa.cor)

bfi %>% 
  select(A1:A5) %>% 
  apa.cor()
##       M   SD      1     2     3     4
## A1 2.41 1.41                         
## A2 4.80 1.17 -.34**                  
## A3 4.60 1.30 -.27** .49**            
## A4 4.70 1.48 -.15** .34** .36**      
## A5 4.56 1.26 -.18** .39** .50** .31**

Supplemental Argument

The function also has an export option export = TRUE, that copies the output into the clipboard, for further manipulation such a simple paste into Microsoft Word.

apa.cor(x, export = TRUE)

Better usage

Since the function outputs a proper S3 object, it is perfect for integrating it into the papaja package, be it to create html tables or better yet, beautifully formatted PDF files.

library(papaja)

bfi %>% 
  select(A1:A5) %>% 
  apa.cor() %>% 

apa_table(
  .,
  , caption = "Variable Means, Standard Deviations, and Correlations Between Agreeableness Items"
  , note = "This table was created with apa_table()."
  , escape = TRUE
)
(#tab:unnamed-chunk-4)

Variable Means, Standard Deviations, and Correlations Between Agreeableness Items

M SD 1 2 3 4
A1 2.41 1.41
A2 4.80 1.17 -.34**
A3 4.60 1.30 -.27** .49**
A4 4.70 1.48 -.15** .34** .36**
A5 4.56 1.26 -.18** .39** .50** .31**

Note. This table was created with apa_table().

ย 

apa.cor's People

Contributors

ggluca avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.