• Complain

Mailund - Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist

Here you can read online Mailund - Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA, year: 2017, publisher: Apress, genre: Business. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Mailund Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist
  • Book:
    Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2017
  • City:
    Berkeley;CA
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Rsum : Presenting best practices for data analysis and software development in R, this comprehensive book teaches you techniques for both data manipulation and visualization and shows you the best way for developing new software packages for R. --

Mailund: author's other books


Who wrote Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist? Find out the surname, the name of the author of the book and a list of all author's works by series.

Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Thomas Mailund 2017
Thomas Mailund Beginning Data Science in R 10.1007/978-1-4842-2671-1_1
1. Introduction to R Programming
Thomas Mailund 1
(1)
Aarhus, Denmark
We will use R for our data analysis so we need to know the basics of programming in the R language. R is a full programming language with both functional programming and object oriented programming features. Learning the language is far beyond the scope of this chapter and is something we return to later. The good news, though, is that to use R for data analysis, you rarely need to do much programming. At least, if you do the right kind of programming, you wont need much.
For manipulating dataand how to do this is the topic of the next chapteryou mainly just have to string together a couple of operations. Operations such as group the data by this feature followed by calculate the mean value of these features within each group and then plot these means. This used to be much more complicated to do in R, but a couple of new ideas on how to structure such data flowand some clever implementations of these in a couple of packages such as magrittr and dplyr has significantly simplified it. We will see some of this at the end of this chapter and more in the next chapter. First, though, you need to get a taste for R.
Basic Interaction with R
Start by downloading RStudio if you havent done so already ( . Well, except that you will be in an empty project while the figure shows (on the top right) that this RStudio is opened in a project called Data Science. You always want to be working on a project. Projects keep track of the state of your analysis by remembering variables and functions you have written and keep track of which files you have opened and such. Choose File New Project to create a project. You can create a project from an existing directory, but if this is the first time you are working with R you probably just want to create an empty project in a new directory, so do that.
Figure 1-1 RStudio Once you have opened RStudio you can type R expressions - photo 1
Figure 1-1.
RStudio
Once you have opened RStudio, you can type R expressions into the console, which is the frame on the left of the RStudio window. When you write an expression there, R will read it, evaluate it, and print the result. When you assign values to variables, and you will see how to do this shortly, they will appear in the Environment frame on the top right. At the bottom right, you have the directory where the project lives, and files you create will go there.
To create a new file, choose File New File. You can select several different file types. We are interested in the R Script and R Markdown types. The former is the file type for pure R code, while the latter is used for creating reports where documentation text is mixed with R code. For data analysis projects, I recommend using Markdown files. Writing documentation for what you are doing is really helpful when you need to go back to a project several months down the line.
For most of this chapter, you can just write R code in the console, or you can create an R Script file. If you create an R Script file, it will show up on the top left, as shown in Figure . You can evaluate single expressions using the Run button on the top-right of this frame, or evaluate the entire file using the Source button. For longer expressions, you might want to write them in an R Script file for now. In the next chapter, we talk about R Markdown, which is the better solution for data science projects.
Figure 1-2 RStudio with a new R Script file Using R as a Calculator You - photo 2
Figure 1-2.
RStudio with a new R Script file
Using R as a Calculator
You can use the R console as a calculator where you just type in an expression you want calculated, press Enter, and R gives you the result. You can play around with that a little bit to get familiar with how to write expressions in Rthere is some explanation for how to write them belowmoving from using R as a calculator in this sense to writing more sophisticated analysis programs is only a question of degree. A data analysis program is really little more than a sequence of calculations, after all.
Simple Expressions
Simple arithmetic expressions are written, as in most other programming languages, in the typical mathematical notation that you are used to.
1 + 2
## [1] 3
4 / 2
## [1] 2
(2 + 2) * 3
## [1] 12
It also works pretty much as you are used to. Except, perhaps, that you might be used to integers behaving as integers in a division. At least in some programming languages, division between integers is integer division, but in R, you can divide integers and if there is a remainder you will get a floating-point number back as the result.
4 / 3
## [1] 1.333333
When you write numbers like and , they are interpreted as floating-point numbers. To explicitly get an integer, you must write 4L and 3L .
class (4)
## [1] "numeric"
class (4L)
## [1] "integer"
You will still get a floating-point if you divide two integers, although there is no need to tell R explicitly that you want floating-point division. If you want integer division, on the other hand, you need a different operator, %/% :
4 %/% 3
## [1] 1
In many languages % is used to get the remainder of a division, but this doesnt quite work with R, where % is used to construct infix operators. So in R, the operator for this is %% :
4 %% 3
## [1] 1
In addition to the basic arithmetic operatorsaddition, subtraction, multiplication, division, and the modulus operator you just sawyou also have an exponentiation operator for taking powers. For this, you can use ^ or ** as infix operators:
2^2
## [1] 4
2^3
## [1] 8
2**2
## [1] 4
2**3
## [1] 8
There are some other data types besides numbers, but we wont go into an exhaustive list here. There are two types you do need to know about early, though, since they are frequently used and since not knowing about how they work can lead to all kinds of grief. Those are strings and factors.
Strings work as you would expect. You write them in quotes, either double quotes or single quotes, and that is about it.
"hello,"
## [1] "hello,"
'world!'
## [1] "world!"
Strings are not particularly tricky, but I mention them because they look a lot like factors, but factors are not like strings, they just look sufficiently like them to cause some confusion. I explain factors a little later in this chapter when you have seen how functions and vectors work.
Assignments
To assign a value to a variable, you use the arrow operators. So you assign the value to the variable x , you would write the following:
x <- 2
You can test that x now holds the value by evaluating x .
x
## [1] 2
And of course, you can now use x in expressions:
2 * x
## [1] 4
You can assign with arrows in both directions, so you could also write the following:
2 -> x
An assignment wont print anything if you write it into the R terminal, but you can get R to print it just by putting the assignment in parentheses.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist»

Look at similar books to Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist»

Discussion, reviews of the book Beginning Data Science in R Data Analysis, Visualization, and Modelling for the Data Scientist and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.