• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Analysis Factor

The Analysis Factor

Statistical Consulting, Resources, and Statistics Workshops for Researchers

  • our programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • statistical resources
  • blog
  • about
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • contact
  • login

OptinMon 34 - Getting Started with R

Member Training: R for Menu Users Software Tutorial

by TAF Support 

In this nearly 6-hour tutorial you will learn menu-based R libraries so you can use R without having to fuss with R code. These libraries don’t cover everything R can do, but they do quite a bit and can set you up to make running R much easier.

[Read more…] about Member Training: R for Menu Users Software Tutorial

Tagged With: menu-based libraries, R software, Statistical Software

Related Posts

  • Member Training: Introduction to Stata Software Tutorial
  • Member Training: Introduction to SPSS Software Tutorial
  • Member Training: What’s the Best Statistical Package for You?
  • R Is Not So Hard! A Tutorial, Part 7: More Plotting in R

Member Training: What’s the Best Statistical Package for You?

by guest contributer 

Choosing statistical software is part of The Fundamentals of Statistical Skill and is necessary to learning a second software (something we recommend to anyone progressing from Stage 2 to Stage 3 and beyond).

You have many choices for software to analyze your data: R, SAS, SPSS, and Stata, among others. They are all quite good, but each has its own unique strengths and weaknesses.

[Read more…] about Member Training: What’s the Best Statistical Package for You?

Tagged With: AMOS, JMP, Jupyter, Linux, MPlus, python, R, S, SAS, SPSS, SQL, Stata, Statistical Software

Related Posts

  • Statistical Software Access From Home
  • Ten Ways Learning a Statistical Software Package is Like Learning a New Language
  • SPSS, SAS, R, Stata, JMP? Choosing a Statistical Software Package or Two
  • Tricks for Using Word to Make Statistical Syntax Easier

The Advantages of RStudio

by Kim Love  6 Comments

There are multiple ways to interface with R. Some common interfaces are the basic R GUI, R Commander (the package “Rcmdr” that you use on top of the basic R GUI), and RStudio.

When I first started to learn to use R, I was bound and determined to use the basic R GUI.

As someone who was already used to programming in SAS, I wasn’t looking for a [Read more…] about The Advantages of RStudio

Tagged With: programming, R, R objects, R packages, RStudio, Statistical Software

Related Posts

  • What Really Makes R So Hard to Learn?
  • Member Training: What’s the Best Statistical Package for You?
  • R Programming Video: 15 Tips for The Beginner
  • R Is Not So Hard! A Tutorial, Part 11: Creating Bar Charts

What Really Makes R So Hard to Learn?

by Kim Love  1 Comment

If you are like I was for a long time, you have avoided learning R.

You’ve probably heard that there’s a steep learning curve. Or noticed that the available documentation is not necessarily user-friendly.

Frankly, both things are true, to some extent.

R is Open-Source

The best and worst thing about R is that it is open-source. So there is no single [Read more…] about What Really Makes R So Hard to Learn?

Tagged With: programming, R, R is not so hard, R objects, R packages, Statistical Software

Related Posts

  • The Advantages of RStudio
  • Member Training: What’s the Best Statistical Package for You?
  • R Programming Video: 15 Tips for The Beginner
  • R Is Not So Hard! A Tutorial, Part 11: Creating Bar Charts

R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots

by guest contributer  1 Comment

by David Lillis, Ph.D.

In our last post, we calculated Pearson and Spearman correlation coefficients in R and got a surprising result.

So let’s investigate the data a little more with a scatter plot.

We use the same version of the data set of tourists. We have data on tourists from different nations, their gender, number of children, and how much they spent on their trip.

Again we copy and paste the following array into R.


T <- structure(list(COUNTRY = structure(c(3L, 3L, 3L, 3L, 1L, 3L, 2L, 3L, 1L, 3L, 3L, 1L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 1L, 1L, 3L,
1L, 2L), .Label = c("AUS", "JAPAN", "USA"), class = "factor"),GENDER = structure(c(2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L), .Label = c("F", "M"), class = "factor"), CHILDREN = c(2L, 1L, 3L, 2L, 2L, 3L, 1L, 0L, 1L, 0L, 1L, 2L, 2L, 1L, 1L, 1L, 0L, 2L, 1L, 2L, 4L, 2L, 5L, 1L), SPEND = c(8500L, 23000L, 4000L, 9800L, 2200L, 4800L, 12300L, 8000L, 7100L, 10000L, 7800L, 7100L, 7900L, 7000L, 14200L, 11000L, 7900L, 2300L, 7000L, 8800L, 7500L, 15300L, 8000L, 7900L)), .Names = c("COUNTRY", "GENDER", "CHILDREN", "SPEND"), class = "data.frame", row.names = c(NA, -24L))


T
attach(T)

plot(CHILDREN, SPEND)

[Read more…] about R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots

Tagged With: col, main, pch, plots, plotting, R, scatter, xlab, xlim, ylab, ylin

Related Posts

  • R Graphics: Plotting in Color with qplot Part 2
  • Doing Scatterplots in R
  • R Graphics: Plotting in Color with qplot
  • Graphing Non-Linear Mathematical Expressions in R

R is Not So Hard! A Tutorial, Part 21: Pearson and Spearman Correlation

by guest contributer  Leave a Comment

by David Lillis, Ph.D.

Let’s use R to explore bivariate relationships among variables.

Part 7 of this series showed how to do a nice bivariate plot, but it’s also useful to have a correlation statistic.

We use a new version of the data set we used in Part 20 of tourists from different nations, their gender, and number of children. Here, we have a new variable – the amount of money they spend while on vacation.

First, if the data object (A) for the previous version of the tourists data set is present in your R workspace, it is a good idea to remove it because it has some of the same variable names as the data set that you are about to read in. We remove A as follows:

rm(A)

Removing the object A ensures no confusion between different data objects that contain variables with similar names.

Now copy and paste the following array into R.

T <- structure(list(COUNTRY = structure(c(3L, 3L, 3L, 3L, 1L, 3L, 2L, 3L, 1L, 3L, 3L, 1L, 2L, 2L, 3L, 3L, 3L, 2L, 3L, 1L, 1L, 3L,
1L, 2L), .Label = c("AUS", "JAPAN", "USA"), class = "factor"),GENDER = structure(c(2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L), .Label = c("F", "M"), class = "factor"), CHILDREN = c(2L, 1L, 3L, 2L, 2L, 3L, 1L, 0L, 1L, 0L, 1L, 2L, 2L, 1L, 1L, 1L, 0L, 2L, 1L, 2L, 4L, 2L, 5L, 1L), SPEND = c(8500L, 23000L, 4000L, 9800L, 2200L, 4800L, 12300L, 8000L, 7100L, 10000L, 7800L, 7100L, 7900L, 7000L, 14200L, 11000L, 7900L, 2300L, 7000L, 8800L, 7500L, 15300L, 8000L, 7900L)), .Names = c("COUNTRY", "GENDER", "CHILDREN", "SPEND"), class = "data.frame", row.names = c(NA, -24L))

T
attach(T)

Do tourists with greater numbers of children spend more? Let’s calculate the correlation between CHILDREN and SPEND, using the cor() function.

R <- cor(CHILDREN, SPEND)
[1] -0.2612796

We have a weak correlation, but it’s negative! Tourists with a greater number of children tend to spend less rather than more!

(Even so, we’ll plot this in our next post to explore this unexpected finding).

We can round to any number of decimal places using the round() command.

round(R, 2)
[1] -0.26

The percentage of shared variance (100*r2) is:
100 * (R**2)
[1] 6.826704

To test whether your correlation coefficient differs from 0, use the cor.test() command.

cor.test(CHILDREN, SPEND)
Pearson's product-moment correlation
data: CHILDREN and SPEND
t = -1.2696, df = 22, p-value = 0.2175
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.6012997 0.1588609
sample estimates:
cor
-0.2612796

The cor.test() command returns the correlation coefficient, but also gives the p-value for the correlation. In this case, we see that the correlation is not significantly different from 0 (p is approximately 0.22).

Of course we have only a few values of the variable CHILDREN, and this fact will influence the correlation. Just how many values of CHILDREN do we have? Can we use the levels() command directly? (Recall that the term “level” has a few meanings in statistics, once of which is the values of a categorical variable, aka “factor“).

levels(CHILDREN)
NULL

R does not recognize CHILDREN as a factor. In order to use the levels() command, we must turn CHILDREN into a factor temporarily, using as.factor().

levels(as.factor(CHILDREN))
[1] "0" "1" "2" "3" "4" "5"

So we have six levels of CHILDREN. CHILDREN is a discrete variable without many values, so a Spearman correlation can be a better option. Let’s see how to implement a Spearman correlation:

cor(CHILDREN, SPEND, method ="spearman")
[1] -0.3116905

We have obtained a similar but slightly different correlation coefficient estimate because the Spearman correlation is indeed calculated differently than the Pearson.

Why not plot the data? We will do so in our next post.

*****

See our full R Tutorial Series and other blog posts regarding R programming.

About the Author: David Lillis has taught R to many researchers and statisticians. His company, Sigma Statistics and Research Limited, provides both on-line instruction and face-to-face workshops on R, and coding services in R. David holds a doctorate in applied statistics.

Bookmark and Share

Tagged With: as.factor(), cor(), cor.test(), levels, Pearson Correlation, R, round(), Spearman correlation

Related Posts

  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots
  • R Graphics: Plotting in Color with qplot Part 2
  • Doing Scatterplots in R
  • R Graphics: Multiple Graphs and par(mfrow=(A,B))

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 7
  • Go to Next Page »

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • Member Training: The Link Between ANOVA and Regression

Upcoming Workshops

    No Events

Upcoming Free Webinars

TBA

Quick links

Our Programs Statistical Resources Blog/News About Contact Log in

Contact

Upcoming

Free Webinars Membership Trainings Workshops

Privacy Policy

Search

Copyright © 2008–2023 The Analysis Factor, LLC.
All rights reserved.

The Analysis Factor uses cookies to ensure that we give you the best experience of our website. If you continue we assume that you consent to receive cookies on all websites from The Analysis Factor.
Continue Privacy Policy
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT