Лабораторное занятие № 1. Презентация

Содержание

Слайд 2

Vasily V. Grinev. Introduction to R Programming

LIST OF PRACTICAL TASKS

Task by task.
Task

Vasily V. Grinev. Introduction to R Programming LIST OF PRACTICAL TASKS Task
#1: Installation of R on Windows.
Task #2: Basic administration of R.
Task #3: Handling with R workspace.
Task #4: Life cycle of native R files.
Task #5: Getting help on R issues.
Duration.
Eighty minutes (in total) per group of students.

Слайд 3

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

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #1: Installation of R

https://cran.r-project.org/ Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK #1: Installation
on Windows

Start page of CRAN

Слайд 4

R for Windows

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #1: Installation

R for Windows Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK
of R on Windows

Слайд 5

R for Windows

Vasily V. Grinev. Introduction to R Programming

Download R 4.1.1

R for Windows Vasily V. Grinev. Introduction to R Programming Download R
for Windows

PRACTICAL TASK #1: Installation of R on Windows

Слайд 6

R for Windows

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #1: Installation

R for Windows Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK
of R on Windows

Слайд 7

R Console

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #2: Basic administration

R Console Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK #2: Basic administration of R
of R

Слайд 8

RStudio

Vasily V. Grinev. Introduction to R Programming

https://rstudio.com/

PRACTICAL TASK #2: Basic administration of

RStudio Vasily V. Grinev. Introduction to R Programming https://rstudio.com/ PRACTICAL TASK #2: Basic administration of R
R

Слайд 9

RStudio

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #2: Basic administration of

RStudio Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK #2: Basic administration of R
R

Слайд 10

RStudio

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #2: Basic administration of

RStudio Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK #2: Basic administration of R
R

Слайд 11

.Renviron

Vasily V. Grinev. Introduction to R Programming

> Sys.getenv()

APPDATA C:\Users\Гринев\AppData\Roaming
...
COMPUTERNAME ГРИНЕВ-ПК
...
HOME C:\Users\Гринев\Documents
HOMEDRIVE C:
HOMEPATH \Users\Гринев
LOCALAPPDATA C:\Users\Гринев\AppData\Local
...
R_HOME D:/Software/R-4.1.1
R_LIBS_USER C:\Users\Гринев\Documents/R/win-library/4.1
...
TEMP C:\Users\6416~1\AppData\Local\Temp
TMP C:\Users\6416~1\AppData\Local\Temp
...
USERNAME Гринев

PRACTICAL TASK #2: Basic administration

.Renviron Vasily V. Grinev. Introduction to R Programming > Sys.getenv() … APPDATA
of R

Слайд 12

.Renviron

Vasily V. Grinev. Introduction to R Programming

C:\Users\user_name\Documents
TMP = 'D:\Software\R-4.1.1\Temp'
APPDATA = 'D:\Software\R-4.1.1\AppData'
LOCALAPPDATA =

.Renviron Vasily V. Grinev. Introduction to R Programming C:\Users\user_name\Documents TMP = 'D:\Software\R-4.1.1\Temp'
'D:\Software\R-4.1.1\AppData\Local'
TEMP = 'D:\Software\R-4.1.1\AppData\Local\Temp'
HOME = 'D:\Software\R-4.1.1\Documents'
R_LIBS_USER = 'D:\Software\R-4.1.1\library\user‘
> Sys.getenv("TEMP")
[1] "C:\\Users\\6416~1\\AppData\\Local\\Temp"
> Sys.getenv("TEMP")
[1] "D:\\Software\\R-4.1.1\\AppData\\Local\\Temp"

PRACTICAL TASK #2: Basic administration of R

Слайд 13

R version

Vasily V. Grinev. Introduction to R Programming

PRACTICAL TASK #2: Basic administration

R version Vasily V. Grinev. Introduction to R Programming PRACTICAL TASK #2: Basic administration of R
of R

Слайд 14

Vasily V. Grinev. Introduction to R Programming

R version

PRACTICAL TASK #2: Basic administration

Vasily V. Grinev. Introduction to R Programming R version PRACTICAL TASK #2: Basic administration of R
of R

Слайд 15

R version

Vasily V. Grinev. Introduction to R Programming

Calling of current R version

R version Vasily V. Grinev. Introduction to R Programming Calling of current
from command console.
> R.Version()$version.string
[1] "R version 4.1.1 (2021-08-10)"
Updating R from command console using the package installr. The main work horse of this package is function updateR(). This function performs the following: finding the latest R version, downloading it, running the installer, deleting the installation file, copy and updating old packages to the new R installation.
### Installing the package
> install.packages(pkgs="installr")
### Loading the package
> suppressMessages(expr=library(package=installr))
### Using the package
> updateR()
CRAN cran.r-project.org/web/packages/installr/index.html
Tutorial r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package

PRACTICAL TASK #2: Basic administration of R

Слайд 16

R version

Vasily V. Grinev. Introduction to R Programming

Old versions of R at

R version Vasily V. Grinev. Introduction to R Programming Old versions of
https://cran.r-project.org/bin/windows/base/old

PRACTICAL TASK #2: Basic administration of R

Слайд 17

Basic definitions

Vasily V. Grinev. Introduction to R Programming

The workspace is current R

Basic definitions Vasily V. Grinev. Introduction to R Programming The workspace is
working environment. It includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace that is automatically reloaded the next time R is started.
Some standard commands for managing R workspace:
### Get work directory
> getwd()
[1] "C:/Users/Гринев/Documents"
### Set custom work directory
> setwd(dir="D:/Vasily Grinev")
> getwd()
[1] "D:/Vasily Grinev“
### List the objects in the current workspace
> ls()
character(0)

PRACTICAL TASK #3: Handling with R workspace

Слайд 18

Vasily V. Grinev. Introduction to R Programming

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64

Vasily V. Grinev. Introduction to R Programming > sessionInfo() R version 4.1.1
(64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
system code page: 1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.1

Session info

PRACTICAL TASK #3: Handling with R workspace

Слайд 19

Vasily V. Grinev. Introduction to R Programming

Options are global parameters that affect

Vasily V. Grinev. Introduction to R Programming Options are global parameters that
the way in which R computes and displays its results. Just one example:
> options("digits")
$digits
[1] 7
> 3/4.5
[1] 0.6666667
### The names of the options
> names(x=options())
[1] "add.smooth" "askYesNo"
[3] "browserNLdisabled" "CBoundsCheck"
[5] "check.bounds" "citation.bibtex.max"
[7] "continue" "contrasts"
[9] "defaultPackages" "demo.ask"
[11] "deparse.cutoff" "device"
[13] "device.ask.default" "digits"
[15] "echo" "editor"
[17] "encoding" "example.ask“

Options

PRACTICAL TASK #3: Handling with R workspace

Слайд 20

Vasily V. Grinev. Introduction to R Programming

### View current (default) options settings
>options()
$add.smooth
[1]

Vasily V. Grinev. Introduction to R Programming ### View current (default) options
TRUE
$askYesNo
function (msg, ...)
{
flush.console()
ans <- winDialog("yesnocancel", msg)
switch(ans, YES = TRUE, NO = FALSE, NA)
}


$browserNLdisabled
[1] FALSE

PRACTICAL TASK #3: Handling with R workspace

Options

Слайд 21

Vasily V. Grinev. Introduction to R Programming

> options("digits")
$digits
[1] 7
> getOption(x="digits")
[1] 7
### Re-settings

Vasily V. Grinev. Introduction to R Programming > options("digits") $digits [1] 7
of option value
> options(digits=4)
> 3/4.5
[1] 0.6667
> options(digits=20)
> 3/4.5
[1] 0.66666666666666663

PRACTICAL TASK #3: Handling with R workspace

Options

Слайд 22

Vasily V. Grinev. Introduction to R Programming

> saveRDS(object=my_R_object, # R object to serialize
file="my_R_object.rds") # the

Vasily V. Grinev. Introduction to R Programming > saveRDS(object=my_R_object, # R object
name of the file where the
# R object is saved to
> readRDS(file="my_R_object.rds") # the name of the file where the
# R object is read from

Native R files

PRACTICAL TASK #4: Life cycle of native R files

Слайд 23

Vasily V. Grinev. Introduction to R Programming

dget() – reads in active memory of

Vasily V. Grinev. Introduction to R Programming dget() – reads in active
single R object from the R text file;
load() – reads the R environment objects;
readRDS() – reads a single R object from *.RDS file.
dput() – write an R object to a text file or connection;
dump() – write R objects into a text file;
save() – write an object of the R environment into a text file;
save.image() – write a current R workspace in .rdata file;
saveRDS() – write a single R object to a file.

Built-in functions

PRACTICAL TASK #4: Life cycle of native R files

Слайд 24

stat.ethz.ch/R-manual/R-devel/doc/html/packages.html

Vasily V. Grinev. Introduction to R Programming

Packages in the standard R library

PRACTICAL

stat.ethz.ch/R-manual/R-devel/doc/html/packages.html Vasily V. Grinev. Introduction to R Programming Packages in the standard
TASK #5: Getting help on R issues

Слайд 25

Vasily V. Grinev. Introduction to R Programming

Package description page

https://stat.ethz.ch/R-manual/R-devel/library/base/html/00Index.html

PRACTICAL TASK #5: Getting

Vasily V. Grinev. Introduction to R Programming Package description page https://stat.ethz.ch/R-manual/R-devel/library/base/html/00Index.html PRACTICAL
help on R issues

Слайд 26

Vasily V. Grinev. Introduction to R Programming

Function description page

https://stat.ethz.ch/R-manual/R-devel/library/base/html/abbreviate.html

PRACTICAL TASK #5: Getting

Vasily V. Grinev. Introduction to R Programming Function description page https://stat.ethz.ch/R-manual/R-devel/library/base/html/abbreviate.html PRACTICAL
help on R issues

Слайд 27

R documentation

Vasily V. Grinev. Introduction to R Programming

https://www.rdocumentation.org/

PRACTICAL TASK #5: Getting help

R documentation Vasily V. Grinev. Introduction to R Programming https://www.rdocumentation.org/ PRACTICAL TASK
on R issues

Слайд 28

R community: blogs and blog aggregators

Vasily V. Grinev. Introduction to R Programming

R community: blogs and blog aggregators Vasily V. Grinev. Introduction to R
(https://www.r-bloggers.com)
R-Bloggers is a blog aggregator of content contributed by bloggers who write about R.
(https://community.rstudio.com)
RStudio Community is a blog aggregator for all things R and RStudio.
(https://blog.revolutionanalytics.com/about.html)
Revolutions is a blog dedicated to news and information of interest to members of the R community
(https://www.r-exercises.com/)
R-exercises aims to help people develop and improve their R programming skills.
(https://r-analytics.blogspot.com/)
Этот блог посвящен языку программирования и системе статистических вычислений R.

PRACTICAL TASK #5: Getting help on R issues

Слайд 29

Vasily V. Grinev. Introduction to R Programming

### List of installed packages
> attr(installed.packages()[,

Vasily V. Grinev. Introduction to R Programming ### List of installed packages
1], "names")
### Get help on a package
> ?base
> library(help="base")
### Get help on a function
> ls(pos="package:base")
> ?sqrt
> ??abs
### Get help on an operator
> ?"+"
> ??"+"

Internal R documentation

PRACTICAL TASK #5: Getting help on R issues

Имя файла: Лабораторное-занятие-№-1.-Презентация.pptx
Количество просмотров: 32
Количество скачиваний: 0