How to Use R with Other Statistical Software

12
Interfacing R with Other Software Arindam Basu MBBS MPH PhD School of Health Sciences, University of Canterbury [email protected]

description

A short lecture on how to use R with other software such as Stata and SPSS

Transcript of How to Use R with Other Statistical Software

Page 1: How to Use R with Other Statistical Software

Interfacing R with Other Software

Arindam Basu MBBS MPH PhDSchool of Health Sciences,University of Canterbury

[email protected]

Page 2: How to Use R with Other Statistical Software

This is R in RStudio

Page 3: How to Use R with Other Statistical Software

This is Stata

Page 4: How to Use R with Other Statistical Software

They Do Not Easily Speak …

Page 5: How to Use R with Other Statistical Software

Questions …

• Why Not?• Is there a Need to Let them Speak with Each

Other?• Can I work entirely in R while keeping my data

in Stata/Spss?• Can I work entirely in Stata while coding in R?

Page 6: How to Use R with Other Statistical Software

Why do I need to Integrate?

• I like R; my colleague likes X• Combine the flexibility and features of both

software …• Others?• Demonstrate R

Page 7: How to Use R with Other Statistical Software

Calling Stata Data into R

• Use “foreign” package

Page 8: How to Use R with Other Statistical Software

Calling R into SPSS

• Install R plug-in from – http://www.ibm.com/developerworks/spssdevcen

tral• You can use SPSS GUI following installation, or

use SPSS syntax to get your work done

Page 9: How to Use R with Other Statistical Software

SPSS Syntax to Call R in SPSS

Page 10: How to Use R with Other Statistical Software

Running R from Within Stata

• Use the “File” command to create the file to write R code

• Invoke a shell using “shell” command within Stata

• In Mac, OK to write “R”• In Windows, Use the /Path/to/R.exe

Page 11: How to Use R with Other Statistical Software
Page 12: How to Use R with Other Statistical Software

Talking Points

• It is relatively easy to use R flexibly with other software such as Stata and SPSS

• Similar routines exist for SAS, JMP, and Statistica• The Package “Foreign” is very useful, but for large

data sets, consider “memisc” package• With Other software, in most cases with R

installed, invoking shell is effective • For More information, see

http://r4stats.com/articles/calling-r/