Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
85 views16 pages

Programming in R For Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen

This document discusses different sources for getting help when using R for data science. It describes several internal help functions in R like ? and example() to provide documentation on specific functions. It also discusses external documentation resources such as manuals, cheat sheets, mailing lists, websites like Stack Overflow, books, and contacting local R user groups for help. The document encourages users to utilize the extensive documentation and active user community available for R.

Uploaded by

MdMorshedulHaque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views16 pages

Programming in R For Data Science Anders Stockmarr, Kasper Kristensen, Anders Nielsen

This document discusses different sources for getting help when using R for data science. It describes several internal help functions in R like ? and example() to provide documentation on specific functions. It also discusses external documentation resources such as manuals, cheat sheets, mailing lists, websites like Stack Overflow, books, and contacting local R user groups for help. The document encourages users to utilize the extensive documentation and active user community available for R.

Uploaded by

MdMorshedulHaque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Introduction

Programming in R for Data Science


Anders Stockmarr, Kasper Kristensen, Anders Nielsen

A first session

> x<-rnorm(100)
> head(x)
[1] -0.2596588 -0.5439287 -0.3976459 -0.8051366 -0.8854298
[6] -0.1317834
> mean(x)
[1] 0.04613127
> sd(x)
[1] 1.013185
> min(x)
[1] -3.207916
> max(x)
[1] 2.550923

R as a calculator

Basic operations

> 2+2
[1] 4
> 7*17
[1] 119
> sqrt(9)
[1] 3
> 3^3
[1] 27
> log(7)
[1] 1.94591
> log10(7)
[1] 0.845098

Precision

> sin(pi/2)
[1] 1
> pi
[1] 3.141593
> options(digits=22)
> pi
[1] 3.1415926535897931

Infinity or not defined, and missings

> 1/0
[1] Inf
> 2*Inf
[1] Inf
> -1/0
[1] -Inf
> 0/0
[1] NaN
> c(1,2,3,NA,5)
[1]

3 NA

> mean(c(1,2,3,NA,5))
[1] NA

Assignments to variables

> x <- 5
> x
[1] 5
> # x=5 can be used; not recommended
> x*x
[1] 25
> y <- x+5
> ls()
[1] "x" "y"
> rm(x)
> ls()
[1] "y"

Getting help

Different sources

The internal help functions

Manuals

Cheat sheets

Mailing lists

Google

http://stackoverflow.com/

Books

Local R users

Internal help function

If we know what function we need help with, then type:


> ?mean
# shorthand for help(mean)

If we just want to see an example


> example(mean)

Often we dont know exactly what we are looking for


> ??"fitting linear model"
# shorthand for
>
# help.search("fitting linear model")

Manuals

Available on-line http://www.r-project.org, but main ones are also


part of the installation, type:
> help.start()

An Introduction to R and R Data Import/Export are worth looking at.

Cheat sheet

May be useful to mount near you desk when starting with R

Several can be found at http://cran.r-project.org/other-docs.html

Mailing lists

R has an extremely active user base.

The mailing lists are very helpful, you can access many at
https://www.r-project.org/mail.html... but users prefer that you
read and think before you pose questions.

Also they easily smell if you are asking for an answer to a homework
question.

The archive is a goldmine of knowledge


http://tolstoy.newcastle.edu.au/R/.

Do you know stack overflow?

Main site at: http://stackoverflow.com/

Find tags and R

The rating often gives you a high quality answer

Example http://stackoverflow.com/questions/9508518/
why-are-these-numbers-not-equal

Books

There are many

Here is a list of 150 R books:


http://www.r-project.org/doc/bib/R-books.html

Most are fairly specialized

Local R users

By far the optimal source of information.

Not only are they close by, but on top of explanations, they may even
provide you with a piece of code that nearly does the job.

Remember this when someones comes to you for R help.

You might also like