Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Basics of R Programming

Rating
-
Sold
-
Pages
82
Uploaded on
02-03-2023
Written in
2022/2023

This document contains all the information about the introduction to R programming and its applications. The document contains all the information about data structures in R and their functions and how we can manage big data through this language

Show more Read less
Institution
Course

Content preview

R Programming

Robin Evans


Michaelmas 2014


This version: November 5, 2014


Administration

The course webpage is at

http://www.stats.ox.ac.uk/~evans/teaching.htm

Lectures are at 10am on Mondays and Wednesdays, and practicals at 9am
on Tuesdays and Thursdays; in reality, there will be rather a lot of overlap
between these two formats.
Please bring your own laptop to use during all classes, and ensure that you
have R working (see below). If you don’t have access to a laptop, let me
know and we will try to provide one.
I will hold office hours each week during Michaelmas term on Wednesdays
between 12pm and 1pm; my office is on the first floor of 2 SPR, room
204. I’m very happy to help with any difficulties or problems you are having
with R, but please take steps to help yourselves first (see below for a
list of resources).


Software

You should install R on your own computer at the first opportunity. Visit

http://cran.r-project.org/

for details. Ensure you have the latest version (as of the start of Michaelmas
2014, this was version 3.1.1). Try to spend some time getting used to the
basics of the software, including arithmetic operations and functions. There
are many excellent online tutorials for this purpose.

1

,Resources

A strength of R is its help files, which we will discuss. These are accessed
with the ? and ?? commands.
The internet has almost all the answers, and knows much more about R
than I do. If you have a problem, it’s extremely likely that someone will
have had the same difficulty already, and posted a question on an internet
forum.
Books are useful, though not required. Here are a some of them with brief
comments.

1. Venables, W.N. and Ripley, B.D. (2002) Modern Applied Statistics with
S. Springer-Verlag. 4th edition.
The classic text.

2. Chambers (2010) - Software for Data Analysis: Programming with R,
Springer.
One of few books with information on more advanced programming (S4,
overloading).

3. Wickham, H. (2014) Advanced R. Chapman and Hall.
A great new book on the more advanced features: a good follow up to this
class.

4. Crawley, M. (2007) The R Book. Wiley.
Very thorough.

5. Fox, J. (2002) A R and S-PLUS Companion to Applied Regression. Sage.
Does what it says.

6. Ligges, U. (2009) Programmieren mit R. Third edition. Springer.
In German(!)

7. Rizzo, M. L. (2008) Statistical Computing with R. CRC/Chapman &
Hall.
More computational – different examples to the other books.

8. Braun, W. J. and Murdoch, D. J. (2007) A First Course in Statistical
Programming with R. CUP.
Detailed and well written, but at a rather low level. A bit redundant given
the above.



2

, 9. Maindonald J. and Braun, W. J. (2003) Data Analysis and Graphics
using R Second or third edition CUP.
Advanced statistical graphics

10. Spector, P. (2008) Data Manipulation with R. Springer
Especially for data manipulation.

11. Dalgaard, P. (2009) Introductory Statistics with R. Second Edition. Springer.
Probably redundant given the above.


Getting the Most out of the Class

Learning R has much in common with learning a natural language: it’s easy
to get going with a few simple phrases, though you’ll find some idiosyn-
crasies in the syntax, and occasional aspects are downright illogical. Once
you’ve mastered these few difficulties, the only barrier to fluency is the vast
vocabulary of R: even in the basic packages there are many commands which
you will never use or understand, but the more you learn the more elegantly
you will be able to express yourself. There is a smaller core of ‘everyday’ lan-
guage which we will focus on, and which you will be expected to understand
in exams and practical assessments.
These lecture notes are intended for reference, and will (by the end of the
course) contain sections on all the major topics we cover. Lectures will not
follow the notes exactly, so be prepared to take your own notes; the practical
classes will complement the lectures, and you can be examined on anything
we study in either.
Don’t copy and paste the commands from this guide into R; you will find
it very hard to remember the details of the language and will have to look
everything up when you come to code something yourself.
Make sure you try the exercises, and understand the code involved in
each one; if something doesn’t make sense, use R’s help functions, ask a
classmate, try using internet resources, or ask me for help (preferably in
that order). Some exercises are marked with an asterisk (*), which means
they are a little more advanced than is necessary for the class.
If you find any mistakes or omissions in these notes, I’d be very grateful to
be informed.




3

, 1 Introduction

1.1 What R is good at

Statistics for relatively advanced users: R has thousands of packages, de-
signed, maintained, and widely used by statisticians.
Statistical graphics: try doing some of our plots in Stata and you won’t have
much fun.
Flexible code: R has a rather liberal syntax, and variables don’t need to be
declared as they would in (for example) C++, which makes it very easy to
code in. This also has disadvantages in terms of how safe the code is.
Vectorization: R is designed to make it very easy to write functions which
are applied pointwise to every element of a vector. This is extremely useful
in statistics.
R is powerful: if a command doesn’t exist already, you can code it yourself.


1.2 What R is not so good at

Statistics for non-statisticians: there is a steep learning curve, which puts
some people off. Try Stata, SAS or SPSS (if you must).
Numerical methods, such as solving partial differential equations; try Mat-
lab.
Analytical methods, such as algebraically integrating a function. Try Math-
ematica or Maple.
Precision graphics, such as might be useful in psychology experiments. Try
Matlab.
Optimization. Though it does have some very easy to use methods built-in.
Low-level, high-speed or critical code; use C, C++, Java or similar. (How-
ever note that such code can be called from R to give the ‘best of both
worlds’.


1.3 General Properties

R makes it extremely easy to code complex mathematical or statistical proce-
dures, though the programs may not run all that quickly. You can interface
R with other languages (C, C++, Fortran) to provide fast implementations
of subroutines, but writing this code (and making it portable) will typically
take longer. Where the advantage falls in this trade-off will depend upon


4

Written for

Institution
Course

Document information

Uploaded on
March 2, 2023
Number of pages
82
Written in
2022/2023
Type
Class notes
Professor(s)
Dr. sanjeev kumar sharma
Contains
All classes

Subjects

$9.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
saxenaaayush2000

Get to know the seller

Seller avatar
saxenaaayush2000 DAV University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions