• 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

  • Home
  • About
    • Our Programs
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Guest Instructors
  • Membership
    • Statistically Speaking Membership Program
    • Login
  • Workshops
    • Online Workshops
    • Login
  • Consulting
    • Statistical Consulting Services
    • Login
  • Free Webinars
  • Contact
  • Login

R is Not So Hard! A Tutorial, Part 1: Syntax

by guest 4 Comments

by David Lillis, Ph.D.

Many of you have heard of R (the R statistics language and environment for scientific and statistical computing and graphics). Perhaps you know that it uses command line input rather than pull-down menus. Perhaps you feel that this makes R hard to use and somewhat intimidating!

OK. Indeed, R has a longer learning curve than other systems, but don’t let that put you off! Once you master the syntax, you have control of an immensely powerful statistical tool.

Actually, much of the syntax is not all that difficult. Don’t believe me? To prove it, let’s look at some syntax for providing summary statistics on a continuous variable.

First, install R by going to the following web-site:

 http://cran.r-project.org/bin/windows/base/

 Now you can download R by clicking on the following link:

Download R for Windows

OK, so you have successfully downloaded R. Now you should have the R icon on your desktop. Click this icon to open R.

Now for a simple exercise.  Let’s take height to be a variable that describes the heights (in cm) of ten people. Copy and paste the following code to the R command line to create this variable.

height = c(176, 154, 138, 196, 132, 176, 181, 169, 150, 175)

 The variable is now stored in the R workspace. To view this variable, enter:

height

 Now, enter the following code at the command line and hit return after each piece of code. You will be surprised how easy this really is!

summary(height)

range(height)

mean(height)

sd(height)

max(height)

min(height)

length(height)

height[1]

height[3]

height[10]

So –  it really wasn’t that difficult after all. More about R later.

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: R, R download

Related Posts

  • Statistical Software Access From Home
  • Member Training: What’s the Best Statistical Package for You?
  • The Advantages of RStudio
  • What Really Makes R So Hard to Learn?

Reader Interactions

Comments

  1. Alan Mainwaring says

    March 28, 2017 at 10:30 pm

    Trying to dive into the command line via R is not easy for a generation of students who are brought up on GUI and clicking and pointing with a mouse.
    Some years ago I taught an introductory statistics course and managed to get the package R Commander to automatically pop up when students clicked on the R icon. With directed instruction I found R Commander like training wheels program for beginners of R. Sure its not like R Studio but for my bunch of students it gave them a set of training wheels, which after a while they can ween themselves off and start using the command line.
    I have found R a fantastic resource , combine it with R Commander and its a good way to start learning R.

    Reply
  2. Wolfcer says

    May 18, 2014 at 6:41 am

    Hi !

    Your post show exactely why R is difficult to learn. The people who want to learn R are mainly statisticians, and the first thing a statistician want to do with his data is never to compute a mean. For that purpose, you have a calculator or somethong like that (Excel, Matlab or Scipy).
    R syntax has too much odds characters (the “.” that means nothing, $, c, T, F, <-, <<-,…, etc), the syntax is inconsistent, the online tutorials rarely or never start by recoding or creating a variable, or computing a table, or how to use weights (we are in statisitics !), and the help files in R are helpless for a statistician (it is a kind of reference doc that show you the complexity of each function rather than a help doc that can help you to understand something).
    And there is one more thing : categoricals variables (factors in R language). It is very difficult to find help about them, just because R don't hold them very well. And this kind of variable is what make a difference between a numerical analysis package as Matlab, and a statistical package as SPSS or Stata.

    I spent many years to learn and use R and I can write a list of many things that made learning R and using it for serious statistical work very difficult.

    But, what is good, is that some people accept to work on that flaws in R ecosystem and are trying to resolve them, and one good example is the book "R in Action". This book shows you how to use R for statistics.

    Sorry for the english, it is my third language.

    Reply
    • Randall says

      September 10, 2014 at 9:12 am

      I agree that help files in R are difficult to understand without already having a sense of the program and what the functions do. It would be extremely difficult to learn R from those. On the other hand, there are some very good introductory R books. I think “Beginning R: The Statistical Programming Language” by Mark Gardener is very accessible. “Hands-On Programming with R” by Garrett Grolemund is another great choice. (They both have programming in the title. I am not a programmer, but I think learning to use R means you have to understand the syntax and how it is structured. Both books provide that at a very basic level.)

      I would say that at times the syntax is overlapping – you can do the same thing in different ways, but not inconsistent. I’m sure you are aware of this, but … T is just the abbreviation for TRUE, same for F. “c” is concatenate. It’s what you use to create a vector. “<-" is just the symbol for assigning a value to a name. If you look around on some basic websites rather than R help I think a lot of what you mentioned you can figure out pretty easily. "Quick-R" is a great site.

      Reply
    • Hazard G. Warren says

      January 25, 2016 at 3:57 pm

      I’m not sure most people trying to learn R are statisticians. There are probably a lot of students for whom R is part of statistics coursework or coursework in related fields, and a lot of working researchers and other people who need to evaluate what they are doing on the fly and are precluded by funding or time from summoning a statistician every time they need to work with or represent their data.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Please note that, due to the large number of comments submitted, any questions on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to a private forum and more resources 24/7.

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • January Member Training: A Gentle Introduction To Random Slopes In Multilevel Models

Upcoming Workshops

  • Logistic Regression for Binary, Ordinal, and Multinomial Outcomes (May 2021)
  • Introduction to Generalized Linear Mixed Models (May 2021)

Read Our Book



Data Analysis with SPSS
(4th Edition)

by Stephen Sweet and
Karen Grace-Martin

Statistical Resources by Topic

  • Fundamental Statistics
  • Effect Size Statistics, Power, and Sample Size Calculations
  • Analysis of Variance and Covariance
  • Linear Regression
  • Complex Surveys & Sampling
  • Count Regression Models
  • Logistic Regression
  • Missing Data
  • Mixed and Multilevel Models
  • Principal Component Analysis and Factor Analysis
  • Structural Equation Modeling
  • Survival Analysis and Event History Analysis
  • Data Analysis Practice and Skills
  • R
  • SPSS
  • Stata

Copyright © 2008–2021 The Analysis Factor, LLC. All rights reserved.
877-272-8096   Contact Us

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.