- Take an Extra 30% Off Any Book: Use promo code HOLIDAY30 at checkout to get an extra 30% off any book for a limited time. Excludes Kindle eBooks and Audible Audiobooks. Restrictions apply. Learn more
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your email address or mobile phone number.
Building on the success of the author’s bestselling Statistics: An Introduction using R, The R Book is packed with worked examples, providing an all inclusive guide to R, ideal for novice and more accomplished users alike. The book assumes no background in statistics or computing and introduces the advantages of the R environment, detailing its applications in a wide range of disciplines.
The R Book is aimed at undergraduates, postgraduates and professionals in science, engineering and medicine. It is also ideal for students and professionals in statistics, economics, geography and the social sciences.
Excerpts from Chapter 4 of The R Book
Chapter 4: Level Set Trees and Code
Learn how to make a volume plot and a barycenter plot, and calculate level set trees with the algorithm LeafsFirst, which is implemented in function ``leafsfirst''. This function takes as an argument a piecewise constant function object.
We consider the density shown in the 2D three-modal density, and calculate first a piecewise constant function object representing this function, and then calculate the level set tree.
N<-c(35,35) # size of the grid pcf<-sim.data(N=N,type="mulmod") # piecewise constant function lst.big<-leafsfirst(pcf) # level set treeWe may make the volume plot with the command ''plotvolu(lst)''. However, it is faster first to prune the level set tree, and then plot the reduced level set tree. Function ''treedisc'' takes as the first argument a level set tree, as the second argument the original piecewise constant function, and the 3rd argument ''ngrid'' gives the number of levels in the pruned level set tree. We try the number of levels ngrid=100.
Now we may make a volume plot with the function ''plotvolu''.
We draw barycenter plots with the function ''plotbary''.
plotbary(lst,coordi=2) # 2nd coordinate
Note: We may find the number and the location of the modes with the ''modecent'' function, which takes as argument a level set tree. Function ''locofmax'' takes as argument a piecewise constant function and calculates the location of the maximum.
modecent(lst) locofmax(pcf)The 3D tetrahedron example
We consider the 3-dimensional example. The calculation is much more time consuming this time.
N<-c(32,32,32) # the size of the grid pcf<-sim.data(N=N,type="tetra3d") # piecewise constant function lst.big<-leafsfirst(pcf) # level set tree lst<-treedisc(lst.big,pcf,ngrid=200) # pruned level set tree plotvolu(lst,modelabel=FALSE) # volume plot plotvolu(lst,cutlev=0.010,ptext=0.00045,colo=TRUE) # zooming coordi<-1 # coordinate, coordi = 1, 2, 3 plotbary(lst,coordi=coordi,ptext=0.0006) # barycenter plot
This time we have used parameter ''cutlev'' to make a zoomed volume plot. When this parameter is given, then only the part of the level set tree is shown which is above the value ''cutlev''. Typically it is better to zoom in to the volume plot by cutting the tails of the volume function away. This is achieved by the parameter ''xlim''. We may us for example the following command to make a ``vertically zoomed'' volume plot.
Additional parameters which we have used are the ''modelabel'', which is used to suppress the plotting of the mode labels, ''ptext'', which lifts the mode labels with the given amount, and ''colo'', which colors the graph of the volume function to make a comparison with the barycenter plots easier.The 4D pentahedron example
We consider the 4-dimensional example.
N<-c(16,16,16,16) pcf<-sim.data(N=N,type="penta4d") lst.big<-leafsfirst(pcf) lst<-treedisc(lst.big,pcf,ngrid=100) plotvolu(lst,modelabel=F) # volume plot plotvolu(lst,cutlev=0.0008,ptext=0.00039,colo=TRUE) # zooming coordi<-1 # coordinate, coordi = 1, 2, 3, 4 plotbary(lst,coordi=coordi,ptext=0.0003) # barycenter plot
"There is a tremendous amount of information in the book, and it will be very helpful … .This is a potentially very useful book." (Journal of Applied Science, December 2008)
"…if you are an R user or wannabe R user, this text is the one that should be on your shelf. The breadth of topics covered is unsurpassed when it comes to texts on data analysis in R." (The American Statistician, Aug 2008)
"The R Book; provides the first comprehensive reference manual for the R language." (Statistica 2008)
"…a 950-page comprehensive reference manual for what is perhaps becoming the most powerful and flexible statistical software environment…" (CHOICE, December 2007)
‘The High-level software language of R is setting standards in quantitative analysis. And now anybody can get to grips with it thanks to The R Book…’ (Professional Pensions, 19th July 2007)
"There is a tremendous amount of information in the book, and it will be very helpful … .This is a potentially very useful book." (Journal of Applied Science, Dec 2008)
Great desktop reference book. I used this book regularly when I was learning R. Good code examples for basic to more advanced applications.Published 10 months ago by electricquad
Perhaps needs an update, but I have it as desk reference for core R function. There is a similar book from the O'Reilly series, but this one is hardcover and won't fall apart so... Read morePublished 14 months ago by Dirk Dittmer
I have the 2nd edition. And Holy Cow! Is this book unorganized. Section 1.1.1 (the first full paragraph) suggest that beginners start by studying Chapters 3-6 first. Read morePublished 17 months ago by ItIsMe
People with limited statistical expertise will be misled by some of the comments and expositions in this book. Read morePublished on July 22, 2013 by Dr J. R. Sedcole
When the book claims that it is for absolute beginners of R and no prior knowledge is required, how do you explain the author introducing functions without first explaining them,... Read morePublished on July 17, 2013 by NerdsRUs
As a computer scientist, I am often faced with learning something about a new language. What I really need is an introduction to the syntax and semantics of the language before... Read morePublished on June 21, 2013 by Solemn Humor
The new edition is coming out, so don't buy this old version. R has been updated some, and the interface the book describes does not quite match the interface of the software you... Read morePublished on January 12, 2013 by D. Haft
This is a good book, but I did not find aplication in ecology and nothing about vegan package. Besides, the part about multivariance analysis there is not NMDS or DCA. Read morePublished on October 21, 2012 by Pedro