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

The function paste()collates the arguments provided and returns one string that is a concatenation of all strings supplied, separated by a separator. This separator is supplied in the function via the argument sep. What is the default separator used in paste()?

Creating functions with a default value

Example: default value for function

c_surface <- function(radius = 2) { radius ∧2 *pi } c_surface(1) ## [1] 3.141593 c_surface() ## [1] 12.56637

4.7 Packages

One of the most important advantages of R is that it allows you to stand on the shoulders of giants. It allows you to load a library of additional functionality, so that you do not waste time writing and debugging something that has been solved before. This allows you to focus on your research and analysis.

Unlike environments like spreadsheets, R is more like a programming language that is extremely flexible, modular, and customizable.

4.7.1 Discovering Packages in R

Additional functions come in “packages.” To use them one needs to install the package first with the function install.packages(); this will connect to a server, download the functions and prepare them for use. Once installed on our computer, they can be loaded in the active environment with the function library()or require()

install.packages()

library()

require()

Example: loading the package DiagrammeR

# Download the package (only once): install.packages(‘DiagrammeR’) # Load it before we can use it (once per session): library(DiagrammeR)

The number of packages availabe increases fast. At the time of writing there are about 15 thousand packages available (see the next “Further information” section). We can of course not explain each package in just one book. Below we provide a small selection as illustration and in the rest of the book we will use a selection of 60 packages (which contain a few hundred upstream packages). The choice of packages is rather opinionated and personal. R is free software and there are always many ways to achieve the same result.

картинка 55Further information – Packages

More information about the packages as well as the packages themselves can be found on the CRAN server https://cran.r-project.org/web/packages.

Useful functions for packages

Below we show some useful functions - note that the output is suppressed.

# See the path where libraries are stored: .libPaths() # See the list of installed packages: library() # See the list of currently loaded packages: search()

картинка 56Further information – All available packages

R provides also functionality to get a list of all packages – there is no need to use a web-crawling or scraper interface.

# available.packages() gets a list:pkgs <- available.packages(filters = “duplicates”) colnames(pkgs) ## [1] “Package” “Version” ## [3] “Priority” “Depends” ## [5] “Imports” “LinkingTo” ## [7] “Suggests” “Enhances” ## [9] “License” “License_is_FOSS” ## [11] “License_restricts_use” “OS_type” ## [13] “Archs” “MD5sum” ## [15] “NeedsCompilation” “File” ## [17] “Repository” # We don't need all, just keep the name:pkgs <-pkgs[,‘Package’] # Show the results: print( paste(‘Today, there are’, length(pkgs), ‘packages for R.’)) ## [1] “Today, there are 15477 packages for R.” available.packages()

картинка 57Further information – All installed packages

We can use the function library()to get a list of all packages that are installed on our machine.

# Get the list (only names):my_pkgs <- library() $results[,1] ## Warning in library(): library ‘/usr/local/lib/R/site-library’ contains no packages # Show the results: print( paste(‘I have’, length(my_pkgs), ‘packages for R.’)) ## [1] “I have 282 packages for R.”

Alternatively, you can use the function installed.packages()

library()

installed.packages()

4.7.2 Managing Packages in R

In the previous section, we learned how to install a package, and got a flavour of the available packages. It is also a good idea to keep the repository of packages stable during a big project, but from time to time update packages aswell as R.Not only there are bug fixes, but also new features.

# See all installed packages: installed.packages()

картинка 58Note – Cold code in this section

While in the rest of the book, most code is “active” in this sense that the output that appears under a line or the plot that appears close to it are generated while the book was compiled, the code in this book is “cold”: the code is not executed. The reason is that the commands fromthis sectionwould produce long and irrelevant output. The listswould be long, because the author's computer has many packages installed, but also little relevant to you, because you have certainly a different configuration. Other commandswould even change packages as a side effect of compiling this book.

A first step in managing packages is knowing which packages can be updated.

# List all out-dated packages: old.packages()

Once we know which packages can be updated, we can execute this update:

# Update all available packages: update.packages()

If you are very certain that you want to update all packages at once, use the askargument:

# Update all packages in batch mode: update.packages(ask = FALSE)

During an important project, you will want to update just one package to solve a bug and keep the rest what as they are in order to reduce the risk that code needs to rewritten and debugged while you are struggling to keep your deadline. Updating a package is done by the same function that is used to install packages.

# Update one package (example with the TTR package): install.packages(“TTR”)

4.8 Selected Data Interfaces

Most analysis will start with reading in data. This can be done from many types of electronic formats such as databases, spreadsheet, CSV files, fixed width text-files, etc.

Reading text from a file in a variable can be done by asking R to request the user to provide the file name as follows:

t <- readLines( file.choose())

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

Интервал:

Закладка:

Сделать

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

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


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

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

x