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. *

Epifunky says

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,