R For College Mathematics and Statistics
eBook - ePub

R For College Mathematics and Statistics

Thomas Pfaff

  1. 326 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

R For College Mathematics and Statistics

Thomas Pfaff

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

R for College Mathematics and Statistics encourages the use of R in mathematics and statistics courses. Instructors are no longer limited to ``nice'' functions in calculus classes. They can require reports and homework with graphs. They can do simulations and experiments. R can be useful for student projects, for creating graphics for teaching, as well as for scholarly work. This book presents ways R, which is freely available, can enhance the teaching of mathematics and statistics.

R has the potential to help students learn mathematics due to the need for precision, understanding of symbols and functions, and the logical nature of code. Moreover, the text provides students the opportunity for experimenting with concepts in any mathematics course.

Features:



  • Does not require previous experience with R


  • Promotes the use of R in typical mathematics and statistics course work


  • Organized by mathematics topics


  • Utilizes an example-based approach


  • Chapters are largely independent of each other

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que R For College Mathematics and Statistics est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  R For College Mathematics and Statistics par Thomas Pfaff en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Économie et Statistiques pour les entreprises et l'Ă©conomie. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2019
ISBN
9781000006971
1
Getting Started
If you do not have R on your desktop then download it now from https://www.r-project.org/. When you click on download R, you will first be asked to choose a CRAN mirror, a location to download the software from, and then will be to a page to choose between Windows, Mac, or Linux. Following the Download R for Windows link will take you to the page for Windows that has a download R for the first time link. After that link you will be directed to a page with a download link at the top. Following the Download R for (Mac) OS X link takes you to a download R for Mac OS X page. Click on the first link on the left under the Latest release header. Linux users can follow the Download R for Linux link. In all cases you can search for videos if you are having difficulties loading R.
When you open R you will see the R Console box with > prompt. Take a few moments and play with R as a calculator with * as multiplication and for exponents. For example we calculate 2^6*3*643.
R Code
> 2^6*3*643
[1] 123456
Throughout this text these boxes will represent the R code and its output. Now that you are comfortable using the R console we want to stop using it as our primary input method as scripts are preferred. Open up a new script (document for Macs) by going to File -> New script. A new window opens with the name Untitled – R Editor. Save this file to a location of your choosing and name it FirstScript and note that it is a .R filetype. The R Editor allows you to type your commands and edit them before you run them in the R console. The file can also be saved for future reference and reuse.
Working in the R Editor
‱ Text following # will be ignored by R. This is how you add comments to your commands so that you can easily read them later.
‱ Ctrl + R (Command Return with a Mac) will send the current line in the editor to the console. Similarly, any highlighted commands in the editor will be sent to the console when you press Ctrl + R.
‱ A + sign in the R console means that R is expecting something more. For example you might be missing a parenthesis or bracket. To get out and back to the > prompt use the Esc key.
‱ Recognize that your toolbar and submenu options depend on which window, console or editor, is selected.
Here are two quick examples to get started, but first a few conventions of this book. R code is taken from the console and so lines of code are preceded by >. If a line does not have a > then the line above was broken and started a new line to fit the page. It is meant to be part of the single line started above and preceded by >. A line that starts with a + is, in fact, a separate line of code, but is part of a larger collection of code. The code in this book uses color, but to see the color you will need to run the code as this book is in black and white.
The first example, graphs the function f (x) = x3 – 3x2 – 9x + 2 on the interval [−4, 6]. To do this, we first define the function. The syntax sets f equal to function(x), a function with variable x, with the expression defined enclosed in braces. Note that * is necessary to represent multiplication. Entering 9x will generate an error as it must be 9*x. The curve function here has five input elements separated by a comma. The first is the function to be graphed. The next two define the x-axis interval for the graph. The first three entries are not optional and must be in this order. The next two elements are optional and can be in any order. We set lwd=2 for the line width and col to red, in quotes, for the color of the graph. A grid is added with grid. The first two elements, NULL, set the grid lines to the tick marks given by the graph created with curve. There are other options here that can be used. The last entry sets the color of the grid lines, with a default of gray. To add another function to the graph, curve can be used again, but the option add=TRUE must be included. To learn more about curve and grid run ?curve or ?grid, which will open a webpage with details about the functions. In general, a question mark followed by a command will open an R documentation page with details about the command.
R Code
> f=function(x){x^3-3*x^2-9*x+2}
> curve(f,-4,6,lwd=2,col="red")
> grid(NULL,NULL,col="black")
Image
The next example begins by generating a random data set of size 150 from a random normal distribution with mean 0 and standard deviation 1. The data returned by rnorm is set to the variable example. At this point example is a vector of length 150. We use summary to return the five number summary plus the mean of the data set example. Note, that the data set is randomly generated so results will differ. Use set.seed(42) to get the same results. We can use sd(example) for the standard deviation and boxplot(data) to create a boxplot of the data.
R Code
> example=rnorm(150,0,1)
> summary(example)
Min. 1st Qu. Median Mean 3rd Qu. Max.
−2.99309 −0.61249 −0.04096 −0.02874 0.64116 2.70189
For an example of a t-test, we test the data example with an alternative of ÎŒ < 0. The function t.test() is used. The first entry is the data and is not optional. The other three inputs set the value of ÎŒ0 to 0, the alternative hypothesis to less than, and the confidence level to 0.90. The default ÎŒ0 is 0 so this isn’t necessary here. The default alternative is two-sided and the options for alternative are two.sided, less, and greater and must be in quotes. The default confidence level is 0.95. To learn more about these functions run?t.test or ?boxplot, for example.
R Code
> t.test(example,mu=0,alternative="less", conf.level=0.90)
One Sample t-test
data: example
t = -0.35007, df = 149, p-value = 0.3634
alternative hypothesis: true mean is less than 0
90 percent confidence interval:
-Inf 0.07694166
sample estimates:
mean of x
-0.02874049
At this point, you should feel free to explore the chapters. The next section is specifically for importing data into R that you may not need at the moment. Depending on your interests, two good chapters to turn to next are Chapter 2, Functions and Their Graphs or one of the basic statistics chapters, Chapters 11, 12, or 13. One last tip: Some chapters use a package. A package can be thought of as an add-on to R that does something more than the base distribution. There are over 10,000 packages for R. To use a package, it must first be downloaded, which only has to be done once. To download a package, make sure the console window is highlighted and use the package menu along the top. You will first need to select as CRAN location, as is done when loading R, and then select the package. Search load package in R if there are any difficulties. When you want to use a particular package run library(name), which you will see in this book anytime a package is used.
1.1 Importing Data into R
One of the strengths of R is statistical computing, but entering large data sets directly into R is not a common practice. Typically, for colleges mathematics and statistics courses, your data will come from a spreadsheet and you will want to import that data into R. The example below assumes that a csv file has been created, likely from Excel, from the Arctic Sea Ice data from Appendix B.
Importing a csv File
‱ Make sure your csv file is free of commas and apostrophes within cells, has only one tab, and you have deleted unnecessary cells. Also, your first cell cannot be named ID.
‱ With the Console window selected go to File -> Change dir
 and select the folder that contains the csv file. In a Mac, Change Dir is under Misc.
‱ Enter the command DataName=read.table(“File Name.csv”, header=TRUE, sep=“,”). Here DataName gives the data a name within the R environment. Choose a meaningful name. Note header=TRUE tells R that you have column nam...

Table des matiĂšres

Normes de citation pour R For College Mathematics and Statistics

APA 6 Citation

Pfaff, T. (2019). R For College Mathematics and Statistics (1st ed.). CRC Press. Retrieved from https://www.perlego.com/book/1513929/r-for-college-mathematics-and-statistics-pdf (Original work published 2019)

Chicago Citation

Pfaff, Thomas. (2019) 2019. R For College Mathematics and Statistics. 1st ed. CRC Press. https://www.perlego.com/book/1513929/r-for-college-mathematics-and-statistics-pdf.

Harvard Citation

Pfaff, T. (2019) R For College Mathematics and Statistics. 1st edn. CRC Press. Available at: https://www.perlego.com/book/1513929/r-for-college-mathematics-and-statistics-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Pfaff, Thomas. R For College Mathematics and Statistics. 1st ed. CRC Press, 2019. Web. 14 Oct. 2022.