• 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
  • Our Programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • About
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • Statistical Resources
  • Contact
  • Blog
  • Login

Ten Data Analysis Tips in R: Answers to Webinar Questions

by guest contributer 1 Comment

by David Lillis, Ph.D.

We were recently fortunate to host a free The Craft of Statistical Analysis Webinar with guest presenter David Lillis.  As usual, we had hundreds of attendees and didn’t get through all the questions.  So David has graciously agreed to answer questions here.

If you missed the live webinar, you can download the recording here:  Ten Data Analysis Tips in R.

Q: Is the M=structure(.list(.., class = “data.frame) the same as M=data.frame(..)? Is there some reason to prefer to use structure(list, … ,) as opposed to M=data.frame?

A: They are not the same. The structure( .. .)  syntax is a short-hand way of storing a data set. If you have a data set called M, then the command dput(M) provides a shorthand way of storing the dataset. You can then reconstitute it later as follows: M <- structure( . . . .). Try it for yourselves on a rectangular dataset.  For example, start off with a data set called M, as follows:

V1   V2   V3   V4

1     2      1      5

5     3     2       5

3     4     3       5

4     5     4       2

5     6     5       5

5     7     6       5

Now enter:  dput(M). You can now store the resulting syntax on a page or send within an e-mail. A person receiving your email can re-construct the dataset with the object name, B, as follows:

B <-  structure(list(V1 = c(1, 5, 3, 4, 5, 5), V2 = c(2, 3, 4, 5, 6,

7), V3 = c(1, 2, 3, 4, 5, 6), V4 = c(5, 5, 5, 2, 5, 5)), .Names = c(“V1”,

“V2”, “V3”, “V4”), row.names = c(NA, -6L), class = “data.frame”)

B

Very handy!

 

Q: I understood all the commands you showed so far, except for scan(). Can you please explain what it is for and show an example?

A: The scan() command provides a method of reading data. Try the following:

D <- scan()

Then enter as many elements as you like, hitting return after each one and finally hitting return twice. Now type D at the command line to see the vector you have entered.

I use scan() in order to halt the execution of a programme until I have read any output.

 

Q: Can you please explain the difference between x & y and x&& y in logical condition evaluation?

In other words, what is the difference between ( scores > 3 & scores <5) on the one hand and ( scores > 3 && scores <5) on the other hand?

A: Always use a single & for vectors of length 2 or more elements. I imagine that you may never have to use && at all, except for vectors of length 1.  For a good explanation, see the following web-site:

http://sites.stat.psu.edu/~dhunter/R/html/base/html/Logic.html

 

Q: How important is R in the real world of big data? I want to become a data scientist and I’m wondering if you could give me any tips on programming packages I should learn.

A: R is well known in the world of Big Data and is increasing in popularity. A number of very useful resources are available for anyone undertaking data mining in R.

For example, Luis Torgo has just published a book called Data Mining with R – learning with case studies (Torgo, Luis. Data Mining with R. ), and presents a set of four case studies with accompanying data sets and code which the interested student can work through. Torgo’s book provides the usual analytic and graphical techniques used every day by data miners, including specialized visualization techniques, dealing with missing values, developing prediction models, and methods for evaluating the performance of your models.

Also of interest to the data miner is the Rattle (R Analytical Tool to Learn Easily) GUI. Rattle is a data mining facility for analyzing very large data sets. It provides many useful statistical and graphical data summaries, presents mechanisms for developing a variety of models, and summarizes the performance of your models.

Another web-site worth reading is the following:

http://www.revolutionanalytics.com/

 

Q: So the rev and the – sign appear to be interchangeable?

A: On reflection, I guess that they are interchangeable. I understand that the rev() command is going out of fashion, and that the best method is to use a minus sign where you are confident that this approach will work. I answered this particular question during the webinar, but at the time I was worried about the possibility that there are situations where the minus sign and the rev() command are not the same.

 

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 and is a frequent contributor to The Analysis Factor, including our blog series R is Not So Hard. 

Bookmark and Share

[Intro_to_R_Workshop]

 

Tagged With: data.frame(), R, scan(), structure()

Related Posts

  • Member Training: What’s the Best Statistical Package for You?
  • The Advantages of RStudio
  • What Really Makes R So Hard to Learn?
  • R is Not So Hard! A Tutorial, Part 22: Creating and Customizing Scatter Plots

Reader Interactions

Comments

  1. Epifunky says

    March 7, 2013 at 3:36 pm

    Hi Karen,

    Here is a free R textbook for psychological students (and other beginners) http://t.co/114dATu8 by David Navarro. Can be a good resource.

    Regards,

    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

  • Member Training: Analyzing Pre-Post Data

Upcoming Free Webinars

Poisson and Negative Binomial Regression Models for Count Data

Upcoming Workshops

  • Analyzing Count Data: Poisson, Negative Binomial, and Other Essential Models (Jul 2022)
  • Introduction to Generalized Linear Mixed Models (Jul 2022)

Copyright © 2008–2022 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.
SAVE & ACCEPT