1. Installation

The RStudio installer should be downloaded from the official website of the project. RStudio can be installed on Personal Computer, and on a Linux-managed server. Below we are talking about the version of the program for personal computers.

RStudio installers are available for all the most common operating systems, including Windows XP/Vista/7, Mac OS X 10.5, Debian 6+/Ubuntu 10.04 and Fedora 13. Select the appropriate file from the list and download it. Installation is standard, without any special features.

2. Working with the Console

2.1. general information

The RStudio Console (Console) provides whole line options that make working with R easy and productive. Mastering these options, along with the features available in the Source (Code Editor) and History (History) panels, can more than repay the time spent on learning.

2.2. Code completion

RStudio supports automatic code completion using the Tab key. For example, if there is an object in the workspace called pollResults , then you can type poll , press Tab, and RStudio will automatically complete the name of this object. Similarly, you can get tooltips for functions by entering their names. For example, entering the name of the sub function and pressing Tab, we get the following:

Code completion also works for function arguments; for example, if you type subset( and press Tab, you get:

2.3. Return to previous commands

When working with R, there is always a need to re-execute one or another command that has already been executed before. Like the standard R console, the RStudio console supports the ability to navigate through previously executed commands using the arrow keys.

You can also use the keyboard shortcut Ctrl+Up (Command-Up on Mac computers) to view a list of recently executed commands and to select a specific command from this list:

The same keyboard shortcut is also suitable for quickly searching for previously called functions that have a specific prefix in their names. For example, to search for functions that have plot in their names, just type plot and press Ctrl+Up:

2.4. Console window title

There are several additional options in the title bar of the Console window:

  • Show working directory.
  • Possibility to interrupt current calculations.
  • Minimizing and maximizing the Console window in relation to the Code Editor (Source) panel (using the buttons in the right upper corner or double-clicking on the window title).

2.5. Hotkeys

Ctrl+L - Clears the Console window from text

Esc - interrupts calculations

3. Editing and executing code

3.1. general information


The RStudio code editor includes a range of productivity options, such as code highlighting, code completion, multi-file editing, and search and replace. certain parts code.

In addition, RStudio has the flexibility to execute code directly from the editor window. For many users, this is the preferred way to work with R. Running commands from the Code Editor window instead of command line Consoles make it easier to replay the same commands and allow you to "pack" such commands into a single function for later use.

3.2. File Management


RStudio supports syntax highlighting and other specialized options for working with the code of the following file types:

  • R scripts
  • Sweave documents
  • TeX documents
To create a new file, use the menu File -> New:

To open an existing file, you must use the menu File -> Open or Open Recent (for opening a file, with which work has been done recently). If several files are open at the same time, a quick transition from one document to another is performed using the corresponding tabs at the top of the code editor window. To navigate between a large number of open files, use the >> icon in the upper right part of the Editor window; you can also use the View -> Switch to menu.



3.3. Code Completion

As noted above when working with the Console, RStudio supports automatic code completion using the Tab key. For example, if there is an object in the workspace called pollResults , then you can type poll , press Tab, and RStudio will automatically complete the name of this object.


3.4. Finding and replacing parts of code

The RStudio Code Editor has the ability to find and replace parts of text you need. To perform this operation, you must use the keyboard shortcut Ctrl + F or the menu section Edit -> Find and Replace. At the top of the editor window there is a button in the form of a magnifying glass - pressing it also opens a dialog box in which search parameters are set.



3.5. Automatic creation of functions

The RStudio code editor can parse a selection of text and automatically convert it into a function for reuse later. All "free" variables in the highlighted code (that is, objects that are referenced but not created within the selection) will be converted to function arguments:

3.6. Code commenting

To comment on selected parts of the code (or to remove comments) use the menu item Edit -> Comment/Uncomment Lines (see also the figure below):

3.7. Code execution

RStudio supports code execution directly from the Editor window (executed commands are sent to the Console, where the result of their execution also appears).

To execute the current line of code, you can use the Ctrl+Enter key combination or the Run Line(s) button located at the top of the Editor window:


There are two possibilities for executing multiple lines of code at the same time:

  • Select the required lines and press Ctrl+Enter (or use the Run Line(s) button located at the top of the Editor window);
  • Press Ctrl+Shift+Enter to execute all lines in the script.

3.8. Hotkeys

Ctrl+Shift+N - create a new document

Ctrl+O - open document

4. Code navigation

4.1. general information

RStudio includes a number of options that allow you to quickly navigate through R code. Learning these options can lead to a significant increase in work efficiency, as well as a better understanding of the code written by others.

4.2. Jump to a file or function

If you know the name of the script file or the name of the function, you can quickly find it using the Go to File/Function search box in the main toolbar of RStudio:


The "Go to File/Function" option works by constantly indexing the code you create. The specific files to be indexed are defined as follows:

  • If any RStudio project is active: all files in the folder of this project are indexed;
  • If the project is not active: All open projects are indexed this moment files with R-scripts.

Hotkeys for calling the Go to File/Function option: Ctrl+

4.3. Jump to function definition

Thanks to the ongoing indexing of R code (see above), RStudio can also help you find the definition of any function. To jump to the function code, hover over its name (you don't have to select it in full) and select the Go to Function Definition command:

You can also jump to a function definition in the following ways:

  • Using hotkey F2.
  • Using Ctrl + click on the function name.
  • Using the Code Editor or the Console.

It is possible to jump to the definition of not only your own functions, but also functions from any R package. Function code from additional R packages is displayed in a special Browser source code(Source Viewer pane) and is read-only.

4.4. Script navigation

There are several ways to navigate code stored as a script in a separate file:

  • The "Go to File/Function" option discussed above allows you to search within open file with a script
  • The Jump to Line command is used to jump to a specific line in the script.

You can also use the options from the corresponding menu (Code Tools):



4.5. Two way code navigation

When navigating through code (especially when navigating from one function to another in succession), it often becomes necessary to quickly return to the previous place where you edited the code. RStudio keeps a list of these edits and allows you to move from one to another in any direction using the Back (Back) and Forward (Forward) commands (available from the Edit menu (Editing), as well as in the upper left corner of the Code Editor window). The Back and Forward commands allow you to repeat the following actions:

  • Opening a document (or switching between bookmarks)
  • Jump to function definition
  • Jump to a specific line of code
  • Jumping to a function using the Function menu
The Back and Forward commands can be invoked using the keyboard shortcuts Ctrl+F9 / Ctrl+F10 (Cmd+F9 / Cmd+F10 on Mac computers).

5. Using command history

5.1. general information

At runtime, RStudio creates a database of all the commands that the user enters into the Console. You can view this database using the History panel.

5.2. Command history overview

The History tab in one of the service panels of RStudio is used to view the history of previously executed commands. Commands are displayed in the order they were executed (recent commands are at the bottom of the list) and grouped by time:

5.3. Search in command history

In the upper right corner of the list of previously executed commands there is a field for entering search queries(e.g. plot ). Search conditions can be specified by entering several words separated by spaces (for example, the name of some data table):



Once you find the command you need, you can also view other commands that were running around the same time. To do this, click on the arrow located to the right of the execution time of the corresponding command:

5.4. Command execution

Commands in the History panel can be selected and used in two ways (according to the names of the two buttons in the upper left part of the panel):

  • Send to Console - Sends the selected commands to the Console. Note, however, that commands sent to the Console will not be executed until the Enter key is pressed.
  • Send to Source - Sends the selected commands to the active Code Editor document. If the Editor does not currently have any active open documents, a new unnamed document will be created.

In the list of previously executed commands, it is possible to select one or more lines:


6. Working directories and workspaces

6.1. general information

Considering how R handles .RData files and its workspaces by default, it makes sense to organize work in such a way that files from different projects are stored in different folders. The material presented below describes the possibilities available in RStudio for organizing such a work model.

6.2. Default working directory


Similar to the standard version of R, RStudio follows the "original working directory" principle. Typically, this is the user's home folder. When starting RStudio, the following happens:

  • Executes the .Rprofile file (if any) from the source working folder.
  • Loads the .RData file (if any) from this folder into the R workspace.
  • Perform other actions described in the service file R startup.

If changes have been made to the workspace, a dialog box will appear when RStudio exits, asking if the workspace should be saved as a .RData file in the current working folder. This behavior can be changed in the RStudio settings (menu Tools -> Options -> R General) as follows:

  • Change Initial working directory
  • Activate/Deactivate automatic download.RData file from the original R working folder (Restore .RData into workspace at startup)
  • Choose whether to save the .RData file always (Always), never (Never), or ask about saving when shutting down (Ask).

6.3. Changing the working directory

The current working directory is displayed at the top of the Console window. There are several ways to change the working directory:

  • use function setwd()
  • Use the menu section Tools -> Change Working Dir...
  • On the Files tab select More -> Set As Working Directory

Be aware of the possible consequences of changing the working directory:

  • Available in code relative links files will become invalid.
  • When finished, the .RData file will be saved to a new folder.

Since these side effects can lead to code execution errors, it is recommended that you start from the folder corresponding to the current project and do not change it until the session ends.

If all files relevant to a particular project are stored in the same folder, it makes sense to make it the source folder for R. Methods for doing this will vary depending on operating system. However, on all platforms, installing RStudio associates it with .RData , .R , and other R-related files. When opening such files, RStudio will automatically set the working folder to the one in which the file being opened is stored. However, keep in mind that if RStudio is already running, opening new files associated with it will not change the working directory.

The following commands can be used to save a workspace to the R working folder or load a space from a working folder during an active RStudio session:

Keep in mind that the load() function will add the loaded workspace to the current one. Therefore, if there are objects with the same name in the active and loadspaces, then the objects in the loadspace will replace the objects with the same name in the activespace. This may lead to undesirable consequences. Therefore, before loading a new workspace, it may make sense to clear the active space. This can be done with the following command:


The Workspace tab also has options to perform the operations described above:

  • Loads a project and displays its name in the Projects toolbar (located in the far right corner of the program's working window).
  • 7.3. Working with projects

    Opening a project

    There are several ways to open projects:

    • Using the Open Project command, available from the Projects tab of the main menu and toolbar, to navigate to a previously created project file (for example, MyProject.Rproj).
    • Selecting a project from the list of recently edited projects (this option is also available from the Projects tab of the main menu and from the toolbar).
    • Double click on the project shortcut file (see above).

    When you open a project in RStudio, the following steps are performed:

    • A new R session is started;
    • Commands are executed from the service file.Rprofile (if there is one in the main project folder);
    • The .Rhistory file is loaded from the project folder into the History panel and is used to navigate through previously executed commands;
    • The project directory becomes the R working directory;
    • The Code Editor opens previously edited scripts with R-code.
    • This resets other RStudio settings (such as active bookmarks, window separators, etc.) to the state they were in before the project was last closed.

    Project Exit

    When you select the Quit R command from the File section of the main menu, the Close Project command from the Project toolbar, or simply open new project, the following happens:

    • The .RData and/or .Rhistory files are written to the project folder (if the current program settings allow it);
    • The list of scripts included in the project is saved so that you can open them next time;
    • Saves other RStudio settings (see above);
    • The current R session ends.

    Working with multiple projects at the same time

    You can work on multiple projects at the same time by simply running the appropriate number of copies of RStudio. This can be done in two ways:

    • Use the Open Project in New Window command, located in the Project section of the main menu.
    • Open multiple projects from the file browser by clicking on the appropriate shortcuts.
    Setting up projects

    There are several options to customize the behavior of each specific project in RStudio. These options are available by the Project Options command from the Project section of the program's main menu:


    Bookmark General (General): Using this tab, you can change the global settings for the behavior of projects. If you do not need to change them, leave the value Default (Default). The following options are available:
    • Restore .RData into workspace at startup - Loads the .RData file (if any) from the original R working directory. If the .RData file is large, this option is best set to "No". This will significantly reduce the program startup time.
    • Save workspace to .RData on exit - saving the workspace as a .RData file when exiting the program. Possible options: "Default" (global settings are used), "Yes" (Yes), "No" (No) and "Ask" (Ask). Note that if the workspace has not been modified, you will not be prompted to save the changes, even if the "Ask" value is set.
    • Always save history (even when not saving .RData) - allows you to make sure that the .Rhistory file with the command history is always saved, even if you choose not to save the .RData file when you exit the program.
    Bookmark Editing(Editing):
    • Index R source files - allows you to make R-code scripts from a specific project indexed for code navigation (see above). Normally this option should be enabled, but if there are "thousands" of files in the project folder, this option can be disabled to avoid slowing down the program.
    • Insert spaces for tab - sets the action of the Tab key, i.e. how many spaces should appear when it is pressed.
    • Text encoding - sets the text encoding in script files. Files whose encoding does not match the specified one can still be opened and correctly recognized when using the Reopen with Encoding command from the File menu.
    Version Control Tab(Version Control):
    • Version control system - allows you to specify the system that will be used for version control. RStudio automatically detects the presence of version control by scanning the .git or .svn folder. Accordingly, this setting should not be changed. Reasons for making changes may include:
    1. The project has both a .git folder and a .svn folder, and you want to specify unambiguously which control system should be used.
    2. The project is not linked to any version control system and you want to add a logical git repository (the equivalent of running git init from the project's root folder).
    • Origin - display the origin of the version control system.

    When working with an R script, you may want to update it automatically. The “taskscheduleR” package helps to set up a schedule to run an R script in the Windows Task Schedule daily, weekly, every N minutes, after Windows startup and so on.

    1. Install “taskscheduleR” package library(devtools) install.packages("devtools") install_github("jwijffels/taskscheduleR") library(taskscheduleR)

      We use the "devtools" package, which allows you to download and install packages directly from GitHub.

    2. Further, to configure the launch of the script, you can use either interactive configuration through the form, or by writing a couple of lines of code.

    Setting up an R script schedule in Task Scheduler via Addins:

    Setting up an R script schedule through the functions of the taskscheduleR package:

    Package features:

    • Get a list of all tasks in Windows Task Scheduler
    • Delete task from Windows Task Scheduler
    • Add an R script run task
      • The following schedules are available: 'ONCE', 'MONTHLY', 'WEEKLY', 'DAILY', 'HOURLY', 'MINUTE', 'ONLOGON', 'ONIDLE'
    ## Specify the name of the R script file for subsequent work with it myscript<- system.file("extdata", "helloworld.R", package = "taskscheduleR") ## Запуск скрипта разово через 35 секунд taskscheduler_create(taskname = "myscript", rscript = myscript, schedule = "ONCE", starttime = format(Sys.time() + 35, "%H:%M")) ## Запуск скрипта ежедневно в 10:15, начиная с завтрашнего дня ## Важно: необходимо поменять формат даты, если он не совпадает с тем, что стоит на компьютере (пример: %m/%d/%Y) taskscheduler_create(taskname = "myscriptdaily", rscript = myscript, schedule = "DAILY", starttime = "10:15", startdate = format(Sys.Date()+1, "%d/%m/%Y")) ## Запуск скрипта каждую неделю в 10:15 по понедельникам taskscheduler_create(taskname = "myscript_mon", rscript = myscript, schedule = "WEEKLY", starttime = "10:15", days = "MON") ## Запуск каждые 5 минут, начиная с 10:15 taskscheduler_create(taskname = "myscript_5min", rscript = myscript, schedule = "MINUTE", starttime = "10:15", modifier = 5) ## Получить data.frame со всеми задачами tasks <- taskscheduler_ls() str(tasks) ## Удалить задачи taskscheduler_delete(taskname = "myscript") taskscheduler_delete(taskname = "myscriptdaily") taskscheduler_delete(taskname = "myscript_,mon") taskscheduler_delete(taskname = "myscript_5min") taskscheduler_delete(taskname = "myscript_withargs_a") taskscheduler_delete(taskname = "myscript_withargs_b")

    What we pay attention to:

    • Date format. It must match the date format on the computer. Otherwise, we will get either an error in setting the script launch schedule, or a completely different date.
    • Computer activity. The computer must be turned on when the script is run.
    • Availability of other script schedules. When setting up a new schedule with the same name, the previous schedule is deleted.

    You can use system() and Rscript to run a script as an asynchronous background process:

    system( "Rscript -e "source(\"your-script.R\")"", wait = FALSE ) ... save.image ("script-output.RData" ) cat ("Script completed\n\n" )

    Hope this helps!

    I want to execute an R script in the background from the R console.

    From the console, I usually run the R script as source ("~/.active-rstudio-document"). I need to wait until the script is finished to continue working. Instead, I want R to run in the background while I I can continue working in the console.Also I need to be notified somehow when R terminates the source command.Is this possible in R?

    This can be quite helpful, as we often see work taking a long time.

    PS - I want the original script to run in the same memory space, not the new one. So solutions like fork, system etc won't work for me. I see if I can run the R script as a separate thread and not a separate process.

    R is a popular open source programming language that specializes in statistical calculations and graphs. It is widely used by statisticians to develop statistical software and perform data analysis. One of the strengths of R is its extensibility. Users can create and publish their own packages. R The community is very active, with custom statistical packages for specific areas of science being added all the time. What makes R applicable in many areas.

    CRAN (Comprehensive R Archive Network) is a set of sites (mirrors) that host many packages, and R distributions themselves. You can download R from any of them, but we will use RStudio.

    In this guide, you will learn how to install and configure R on Ubuntu 14.04. Most of the instructions will work for other operating systems, only a few commands need to be changed. Everything about everything should take you no more than 10-15 minutes.

    Of course, we will need Ubuntu 14.04, since the article and 1 Gigabyte of RAM in the system are designed for it. If there is not enough memory, you need to mount a swap partition.

    All commands are executed as a normal user, if root access is needed, we use sudo.

    System preparation

    We will use APT (Advanced Packaging Tool) to install R. It uses a special file to store a list of sources from which packages will be downloaded. This is /etc/apt/sources.list. If we want to get the latest version of R, then we need to add the correct repository to the sources list. To do this, add the following line to /etc/apt/sources.list, in Ubuntu 14.04 it will look like this, but for other versions it will be different:

    sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'

    The repository for your OS version can be found there

    To install packages from this repository into APT, we need to add its public key. In Ubuntu, CRAN is signed with a key with ID E084DAB9. Add it to the system:

    gpg -keyserver keyserver.ubuntu.com -recv-key E084DAB9

    And then in apt:

    gpg -a -export E084DAB9 | sudo apt key add -

    R installation

    Now that APT is configured correctly, we can move on to the installation.

    First we need to update the list of available packages, as we have changed the sources:

    sudo apt-get update

    Now we can install R. The y flag automatically confirms the installation of the program:

    sudo apt-get -y install r-base

    You now have the latest version of R installed on your system. You can test it by running:

    You will see something similar to this:

    R version 3.2.1 (2015-06-18) - "World-Famous Astronaut"
    Copyright (C) 2015 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)

    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under certain conditions.
    Type ‘license()’ or ‘licence()’ for distribution details.

    Natural language support but running in an English locale

    R is a collaborative project with many contributors.
    Type ‘contributors()’ for more information and
    ‘citation()’ on how to cite R or R packages in publications.

    Type 'demo()' for some demos, 'help()' for on-line help, or
    'help.start()' for an HTML browser interface to help.
    Type 'q()' to quit R.

    You are now in the interactive R console and can execute any R commands. To exit, use the function:

    > q(save = "no")

    Installing R packages from CRAN

    By default, R installs several standard packages, but you may want to install additional packages. To do this, you need at least 1 GB of RAM.

    As mentioned earlier, CRAN hosts not only R itself, but also many additional packages. To install or update packages from CRAN, you must use the R install.packages() function. For example, if you want to install a package, use the following command:

    > install.packages("package")

    It is worth noting that the package will be installed only for the current user and will not be available to others.

    You can also install the R package for all users, for this you need to use superuser rights. As an example, let's install the shiny package, which is very popular among R web application developers. One way to install a package as root is to log in as root, start R, and call the install.packages() function. But this is not recommended. We can just run the R command with sudo. The repo parameter specifies which repository the package will be downloaded from.

    sudo su - -c "R -e \"install.packages('shiny', repos = 'http://cran.rstudio.com/')\""

    The package will now be available to all users. Let's check. Run R:

    Download the package:

    > library(shiny)

    As you can see, the command did not generate any errors. Now close R:

    > q(save = "no")

    Installing the DevTools Package

    Packages hosted on CRAN can be installed with the install.packages() function, but there are many more packages hosted on GitHub. To install R packages from Github, you need to use the DevTools package. Let's install it. The package requires the three libraries libcurl4-gnutils-dev, libxml2-dev , and libssl-devc to work, install them:

    sudo apt-get -y install libcurl4-gnutls-dev libxml2-dev libssl-dev

    Now you can install devtools. Don't forget that it needs to be set for all users as described above.

    sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""

    The devtools installation will take a few minutes.

    Installing R packages from GitHub

    Now that DevTools is installed, we can install any package from GitHub using the install_github() function. Just like installing from CRAN, you must run the command as root to install packages for all users. Let's try installing shinyjs from GitHub which adds functionality to the shiny package. A package on GitHub is identified by its author and name:

    sudo su - -c "R -e \"devtools::install_github('daattali/shinyjs')\""

    Let's check if shinyjs is installed correctly by downloading it. Run R:

    Try downloading shinyjs:

    > library (shinyjs)

    you already know how to close the R interpreter:

    > q(save = "no")

    Next steps

    You now have a fully working R language interpreter installed and configured on your system. For more information, you can visit

    To create a variable (for example, x) and assign a value to it (for example, 1234) you just need to enter the command x=1234 . Now in any expressions the variable name (in our case x) will be automatically replaced by the value (in our case it is 1234).

    To find out the value of a variable, just enter the name of the variable, and R will return its value. It will look like this:
    > x=1234
    > x
    1234

    By assigning a new value to a variable, you can use the old value, that is, create constructions like
    >a=5
    > a
    5
    > a=a+3
    > a
    8

    It is important to know that variable names can consist of Latin letters of both cases, numbers and underscores (for example, the following names are allowed: a, x, x1, a_x, O_o, the_Variable_with_Long_Name, a459x4h36J4lbgT62). In this case, the first character must be a letter! Finally, case matters, meaning RainForest and RainFOrest are different variables.

    Vectors, or how to work with data series?

    What are vectors in R?

    Let's say we have a group of 5 people and we need to store their ages. You can create five variables, for example
    > age_1=25
    > age_2=20
    > age_3=9
    > age_4=44
    > age_5=37
    However, it is more convenient to create one variable in which to place all 5 values. Such a series of data, united by one name, stored in a certain order, is an array of data, or a vector.

    Assign("age",c(25,20,9,44,37))
    or abbreviated: age

    Now, each individual element can be called by its serial number in the series, for example, the fourth element can be obtained like this:
    > age
    44
    With such individual elements, you can perform all the same operations as with ordinary numbers.

    The append function, or how to add elements to an existing vector?

    Let's say another person appeared in our group, whose age is 31 years old. We can recreate the age vector, but now with six elements instead of five. However, there is another way - to use the append function:
    > append(age,31)
    25 20 9 44 37 31
    Note that we could insert multiple values ​​by remembering the c() function:
    > append(age,c(31,33,35))
    25 20 9 44 37 31 33 35

    The function also allows you to insert elements anywhere in the vector using the after parameter. By default, after=length(x) is set, which means elements are added to the end. But let's say we want to insert our sixth person after the second:
    > append(age, 31, after=2)
    25 20 31 9 44 37

    Operations with vectors, or what can be done with vectors?

    You can operate on all elements of the vector at the same time. So adding a number to a vector is equivalent to adding that number to each element of the vector. Or, for example, to display how many decades each person from our example lived, you can do this:
    > age/10
    2.5 2.0 0.9 4.4 3.7

    Similarly with addition, subtraction and other operations described in paragraph about

    How to compare vectors, elements of vectors?

    Let's say we need to find out which elements of the vector (let it be the same age) are greater than a certain number (for example, which of our small sample is an adult). R for each element will tell if the condition is true, i.e. TRUE (true) or FALSE (not true). It will look something like this:
    >age
    25 20 31 9 44 37
    > age >= 18
    TRUE TRUE FALSE TRUE TRUE

    But you may need to get one answer, for example, is it true that all elements match the condition? or are there any elements matching the condition at all? To do this, we use two functions, respectively, all() and any()

    all(x1,x2,...,xn) - answers the question, is it true that all conditions (x1, x2, ... and xn) are true? that is, it is a logical conjunction. For example:
    > all (age >= 7, age TRUE
    # indeed, all subjects are not younger than seven and younger than sixty
    > all (age >=18, 1 > 0)
    FALSE
    # although the unit, of course, is greater than zero, but among our subjects there is one nine-year-old, therefore it is not true

    any(x1,x2,...,xn) - will answer the question, is there at least one of the conditions (x1, x2, ..., xn) correct? that is, it is a logical disjunction. Example:
    > any (age >=18, 1 > 0)
    TRUE

    Finally, two vectors can be compared with each other. But for this it is necessary either that the length of the larger one is a multiple of the length of the smaller one, or that the lengths are equal. Examples:
    > a > a > b
    FALSE FALSE FALSE TRUE TRUE

    How to set a sequence of numbers?

    • operator:
    • seq(from,to,by,length,along) - creates a sequence starting from from, ending with to step by. You can specify the length of the series with the length parameter, or equate the length to another vector along . Arguments: from, to, by, length, along (same length as...)
    • rep(a, times, each) - repeat the vector a times times or each times each element of a. Arguments: vector, times, each

    Sorting

    • sort(v,increasing) - sorts the vector v; increasing - boolean, true - ascending, false - descending, you can write increasing=decreasing;
    • order()