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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать

Example: Using strings

a <-“Hello” b <-“world” paste(a, b, sep = “, “) ## [1] “Hello, world” c <-“A ‘valid’ string” paste()

картинка 42Note – Paste

In many cases we do not need anything between strings that are concatenated. We can of course supply an empty string as separator ( sep = “), but it is also possible to use the custom function pate0():

paste0(12, ‘%’) ## [1] “12%”

past0()

Formatting with

format()

In many cases, it will be useful to format a date or number consistently and neatly in plot and tables. The function format()is a great tool to start formatting.

format()

Function use for format()

format(x, trim = FALSE, digits = NULL, nsmall = 0L, justify = c(“left”, “right”, “centre”, “none”), width = NULL, na.encode = TRUE, scientific = NA, big.mark = “”, big.interval = 3L, small.mark = “”, small.interval = 5L, decimal.mark = getOption(“OutDec”), zero.print = NULL, drop0trailing = FALSE, …)

x is the vector input.

digits is the total number of digits displayed.

nsmall is the minimum number of digits to the right of the decimal point.

scientific is set to TRUE to display scientific notation.

width is the minimum width to be displayed by padding blanks in the beginning.

justify is the display of the string to left, right or center.

Formatting examples

a <-format(100000000,big.mark=” “, nsmall=3, width=20, scientific=FALSE, justify=“r”) print(a) ## [1] “ 100 000 000.000”

картинка 43Further information – format()

More information about the format-function can be obtained via ?formator help(format).

Other string functions

nchar(): returns the number of characters in a string

nchar()

toupper(): puts the string in uppercase

toupper()

tolower(): puts the string in lowercase

tolower()

substring(x,first,last): returnsa substring from x starting with the “first” and ending with the “last”

substring()

strsplit(x,split): splitthe elements of a vector into substrings according to matches of a substring “split.”there is also a family of search functions: grep(),

strsplit()

grep()

grepl(),

grepl()

regexpr(),

regexpr()

gregexpr(),

gregexpr()

and regexec()

regexec()

that supply powerful search and replace capabilities.

sub()

sub()

will replace the first of all matches and gsub()

gsub()

will replace all matches.

4.4 Operators

While we already encountered operators in previous sections when we introduced the data types, here we give a systematic overview of operators on base types.

operators

4.4.1 Arithmetic Operators

arithmetic – operators

Arithmetic operators act on each element of an object individually.

operator – arithmetic

v1 <- c(2,4,6,8) v2 <- c(1,2,3,5) v1 +v2 # addition## [1] 3 6 9 13 v1 -v2 # subtraction## [1] 1 2 3 3 v1 *v2 # multiplication## [1] 2 8 18 40 v1 /v2 # division## [1] 2.0 2.0 2.0 1.6 v1 %%v2 # remainder of division## [1] 0 0 0 3 v1 %/%v2 # round(v1/v2 -0.5)## [1] 2 2 2 1 v1 ∧v2 # v1 to the power of v2## [1] 2 16 216 32768

addition

substraction

multiplication

division

power

картинка 44Warning – Element-wise operations in R

While the result of the sum will not surprise anyone, the result of the multiplicationmight come as a surprise for users of matrix oriented software such as Mathlab or Octave for example. In R an operations is always element per element – unless explicitly requested. For example, the dot-product can be obtained as follows.

v1 %*%v2 ## [,1] ## [1,] ss 68

4.4.2 Relational Operators

Relational Operators compare vectors element by element

relational operators

operator – relational

v1 <- c(8,6,3,2) v2 <- c(1,2,3,5) v1 >v2 # bigger than## [1] TRUE TRUE FALSE FALSE v1 <v2 # smaller than## [1] FALSE FALSE FALSE TRUE v1 <=v2 # smaller or equal## [1] FALSE FALSE TRUE TRUE v1 >=v2 # bigger or equal## [1] TRUE TRUE TRUE FALSE v1 ==v2 # equal## [1] FALSE FALSE TRUE FALSE v1 !=v2 # not equal## [1] TRUE TRUE FALSE TRUE

bigger than

smaller than

bigger or equal

equal

not equal

4.4.3 Logical Operators

Logical Operators combine vectors element by element. While logical operators can be applied directly on composite types, theymust be able to act on numeric, logical or complex types in order to produce understandable results.

operator – logical

v1 <- c(TRUE, TRUE, FALSE, FALSE) v2 <- c(TRUE, FALSE, FALSE, TRUE) v1 &v2 # and## [1] TRUE FALSE FALSE FALSE v1 |v2 # or## [1] TRUE TRUE FALSE TRUE !v1 # not## [1] FALSE FALSE TRUE TRUE v1 &&v2 # and applied to the first element## [1] TRUE v1 ||v2 # or applied to the first element## [1] TRUE v1 <- c(TRUE,FALSE,TRUE,FALSE,8,6 +3i, -2,, NA) class(v1) # v1 is a vector or complex numbers## [1] “complex” v2 <- c(TRUE) as.logical(v1) # coerce to logical (only 0 is FALSE)## [1] TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE NA v1 &v2 ## [1] TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE NA v1 |v2 ## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

картинка 45Note – Numeric equivalent and logical evalutation

Note that numbers different from zero are considered as TRUE, but only zero is considered as FALSE. Further, NA is implemented in a smartway. For example, in order to assess TRUE & NAwe need to know what the second element is, hence it will yield NA. However, TRUE | NAwill be true regardless what the second element is, hence R will show the result.

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

Интервал:

Закладка:

Сделать

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

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


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

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

x