Philippe J. S. De Brouwer - The Big R-Book

Здесь есть возможность читать онлайн «Philippe J. S. De Brouwer - The Big R-Book» — ознакомительный отрывок электронной книги совершенно бесплатно, а после прочтения отрывка купить полную версию. В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: unrecognised, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

The Big R-Book: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «The Big R-Book»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Introduces professionals and scientists to statistics and machine learning using the programming language R Written by and for practitioners, this book provides an overall introduction to R, focusing on tools and methods commonly used in data science, and placing emphasis on practice and business use. It covers a wide range of topics in a single volume, including big data, databases, statistical machine learning, data wrangling, data visualization, and the reporting of results. The topics covered are all important for someone with a science/math background that is looking to quickly learn several practical technologies to enter or transition to the growing field of data science. 
The Big R-Book for Professionals: From Data Science to Learning Machines and Reporting with R Provides a practical guide for non-experts with a focus on business users Contains a unique combination of topics including an introduction to R, machine learning, mathematical models, data wrangling, and reporting Uses a practical tone and integrates multiple topics in a coherent framework Demystifies the hype around machine learning and AI by enabling readers to understand the provided models and program them in R Shows readers how to visualize results in static and interactive reports Supplementary materials includes PDF slides based on the book’s content, as well as all the extracted R-code and is available to everyone on a Wiley Book Companion Site
is an excellent guide for science technology, engineering, or mathematics students who wish to make a successful transition from the academic world to the professional. It will also appeal to all young data scientists, quantitative analysts, and analytics professionals, as well as those who make mathematical models.

The Big R-Book — читать онлайн ознакомительный отрывок

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «The Big R-Book», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

To modify an existing variable, one can use the edit()function edit()

edit(x)

картинка 16Warning – Using CLI tools

The edit function will open the editor that is defined in the options. While in RStudio, this is a specially designed pop-up window with buttons to save and cancel, in the command line interface (CLI) this might be vi. The heydays of this fantastic editor are over and you might never have seen it before. It is not really possible to use vi without reading the manual (e.g. via the man vicommand on the OS CLI or an online tutorial). To get out of vi, type: [ESC]:q![ENTER]. Note that we show the name of a key within square brackets and that all the other strings are just one keystroke each.

Batch mode

R is an interpreted language and while the usual interaction is typing commands and getting the reply appear on the screen, it is also possible to use R in batch mode.

batch mode

functions

1 create a file test.R

2 add the content print(“Hello World”)

3 run the command line Rscript test.R

4 now, open R and run the command source(“test.R”)

source()

1 add in the file

my_function <- function(a,b) { a +b }

1 now repeat step 4 and run my_function(4,5)

In this section we will present you with a practical introduction to R, it is not a formal introduction. If you would like to learn more about the foundations, then we recommend the documentation provided by the R-core team here: https://cran.r-project.org/doc/manuals/r-release/R-lang.pdf.

4.2. Variables

As any computer language, R allows to use variables to store information. The variable is referred to by its name. Valid names in R consist of numbers and characters. Evenmost special characters can be used.

variables

In R, variables

can contain letters as well as “_” (underscore) and “.” (dot), and

variables must start with a letter (that can be preceded with a dot).

For example, my_var.1and my.Cvarare valid variables, but _myVar, my%varand 1.varare not acceptable.

Assignment

Assignment can be made left or right:

assignment

x.1 <-5 x.1 +3 ->.x print(.x) ## [1] 8

R-programmers will use the arrow sign <-most often, however, R allows left assignment with the =sign.

x.3 =3.14 x.3 ## [1] 3.14

There are also occasions that we must use the =operator. For example, when assigning values to named inputs for functions.

v1 <- c(1,2,3,NA) mean(v1, na.rm = TRUE) ## [1] 2

There are more nuances and therefore, we will come back to the assignment in Chapter 4.4.4 “ Assignment Operators ” on page 78. These nuances are better understood with some more background, and for now it is enough to be able to assign values to variable.

Variable Management

With what we have seen so far, it is possible to make already simple calculations, define and modify variables. There is still a lot to follow and it is important to have some basic tools to keep things tidy. One of such tools is the possibility to see defined variables and eventually remove unused ones.

# List all variables ls() # hidden variable starts with dot ls(all.names = TRUE) # shows all # Remove a variable rm(x.1) # removes the variable x.1 ls() # x.1 is not there any more rm(list = ls()) # removes all variables ls()

картинка 17Note – What are invisible variables

A variable whose name starts with a dot (e.g. .x) is in all aspects the same as a variable that starts with a letter. The only difference is that the first will be hidden with the standard arguments of the function ls().

ls()

rm()

4.3 Data Types

As most computer languages, R has some built-in data-types. While it is possible to do certain things in R without worrying about data types, understanding and consciously using these base-types will help you to write bug-free code that is more robust and it will certainly speed up the debugging process. In this section we will highlight the most important ones.

4.3.1 The Elementary Types

There is no need to declare variables explicitly and tell R what type the variable will be before using it. R will assign them a class whenever this is needed and even change the type when our code implies a change.

class()

long

complex numbers

string

# Booleans can be TRUE or FALSE:x <-TRUE class(x) ## [1] "logical" # Integers use the letter L (for Long integer):x <-5L class(x) ## [1] "integer" # Decimal numbers, are referred to as ‘numeric’:x <-5.135 class(x) ## [1] "numeric" # Complex numbers use the letter i (without multiplication sign):x <-2.2 +3.2i class(x) ## [1] "complex" # Strings are called ‘character’:x <-"test" class(x) ## [1] "character"

картинка 18Warning – Changing data types

While R allows to change the type of a variable, doing so is not a good practice. It makes code difficult to read and understand.

# Avoid this:x <-3L # x defined as integerx ## [1] 3 x <-"test" # R changes data typex ## [1] "test"

So, keep your code tidy and to not change data types.

Dates

Working with dates is a complex subject. We explain the essence of the issues in Section 17.6 “ Dates with lubridate ” on page 407. For now, it is sufficient to know that dates are one of the base types of R.

date

# The function as.Data coerces its argument to a dated <- as.Date( c("1852-05-12", "1914-11-5", "2015-05-01")) # Dates will work as expectedd_recent <- subset(d, d > as.Date("2005-01-01")) print(d_recent) ## [1] "2015-05-01"

as.Date()

subset()

картинка 19Further information –More about dates

Make sure to read Section 17.6 “ Dates with lubridate ” on page 407 for more information about working with dates as well as the inevitable problems related to dates.

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «The Big R-Book»

Представляем Вашему вниманию похожие книги на «The Big R-Book» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «The Big R-Book»

Обсуждение, отзывы о книге «The Big R-Book» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x