Practicing R for Statistical Computing (2023)

Practicing R for Statistical Computing R faqs

The book “Practicing R for Statistical Computing” is designed to provide a comprehensive introduction to R language for data presentation, manipulation, and statistical data analysis. The book covers fundamentals of data structures in R language such as vectors, matrices, arrays, and lists, along with techniques for exploratory data analysis, the transformation of the data, and its manipulation. The book explains basic statistical concepts and demonstrates their implementation including descriptive statistics, graphical representation of data, probability, popular probability distributions, and hypothesis testing. It also explores linear and non-linear modeling, model selection, and diagnostic tools available in R.

Practicing R for Statistical Computing

The book also covers flow control and conditional computation using ‘if’ conditions and loops. A useful discussion is also done about functions and resources for further learning. It provides an extensive list of functions grouped according to statistics classification, which can be helpful for both statisticians and R programmers. The use of different graphic devices, high-level and low-level graphical procedures, and adjustment of parameters are also explained. Throughout the book, R commands, functions, and objects are printed in different fonts for understanding and easy identification. The possible standard errors, warnings, and mistakes by users in the R language are also discussed and classified, and explanations on how to prevent them are given.

Chapter-wise downloadable R code files from Practicing R for Statistical Computing are:

Chapter 1: R Language: Introduction

Chapter 2: Obtaining and Installing R Language

Chapter 3: Using R as a Calculator

Chapter 4: Data Mode and Data Structure

Chapter 5: Working with Data

Chapter 6: Descriptive Statistics

Chapter 7: Probability and Probability Distributions

Chapter 8: Confidence Intervals and Comparison Tests

Chapter 9: Correlation & Regression Analysis

Chapter 10: Graphing in R

Chapter 11: Control Flow: Selection and Iteration

Chapter 12: Functions and R Resources

Chapter 13: Common Errors and Mistakes

Chapter 14: Functions for Better Programming

Chapter 15: This chapter lists the widely used built-in functions (No R code exists)

Chapter 16: This chapter lists several important R packages (No R code exists)

Authors:

Muhammad Aslam is Professor in the Department of Statistics at Bahauddin Zakariya University,

Muhammad Imdad Ullah is an Assistant Professor in the Department of Statistics at Ghazi University,

Muhammad Aslam is a Professor at the Department of Statistics at Bahauddin Zakariya University, Multan, Pakistan. He holds a Ph.D. in Statistics, a Master’s degree in Statistics, and a Post-Graduate Diploma in Computer Programming and Computing Statistics from the same university. He also completed his Post-Doctorate from the Institut de Mathematiques de Bourgogne, Dijon, France.

Professor Aslam’s research is mainly focused on regression analysis and statistical inference, with a particular interest in simulation studies using computer programming. With more than 25 years of teaching experience, he has published more than 120 research articles in several prestigious international journals. Nine research scholars have completed their Ph.D. degrees under his guidance. Muhammad Imdad Ullah, the co-author of this book, is among these scholars. 

Muhammad Imdad Ullah is an Assistant Professor at the Department of Statistics, Ghazi University, Dera Ghazi Khan, Pakistan. He received his Ph.D. degree from Bahauddin Zakariya University. He has also earned a Post-Graduate Diploma in Computer Programming and Computing Statistics. His Ph.D. work is about the development of R packages addressing linear regression models with the issue of multicollinearity. This work led to the development of three R packages—mctest, lmridge, and liureg —and three research articles based on these packages were published in The R Journal. His area of expertise includes computer programming and statistical computations. With over 14 years of teaching experience, he has authored 11 research publications.

Practicing R Language for Statistical Copmuting

Learn Statistics and Data Analysis

9 Ways to Get Help in R Language

In this article, we will discuss 9 ways to get help in R Language. R Language has a very useful and advanced help system that helps the R user to understand the R language and lets him know how programming should be done in the R language.

Get Help in R Language

To get help in R language you need to click the Help button on the toolbar of RGui (R Graphical User Interface) windows. If you have internet access on your PC you can type CRAN in Google and search for the help you need at CRAN.

Use of “?” for Help

On the other hand, if you know the name of the function, you need to type the question mark (?) followed by the name of the required function on the R command line prompt. For example to get help about “lm” function type ?lm and then press the ENTER key from the keyboard.
help(lm) or ?lm have the same search results in the R language.

help.start()

Getting General help in R write the following command at the R command prompt

help.start()

## Output
help.start()
starting httpd help server ... done
If nothing happens, you should open
‘http://127.0.0.1:13825/doc/html/index.html’ yourself
9 ways to get help in R Language

Sometimes it is difficult to remember the precise name of the function, but you know the subject on which you need help for example data input. Use the help.search function (without question mark) with your query in double quotes like this:

help.search("data input")

Press the ENTER key, you will see the names of the R functions associated with the query.  After that, you can easily use ?lm to get help in R.

Use of find(” “)

Getting help in R, find, and apropos are also useful functions. The find function tells you what package something is in: for example

find("cor") gives output that the cor in the stats package.

Use of apropos()

The apropos function returns a character vector giving the names of all objects in the search list that match your inquiry (potentially partial) i.e., this command lists all functions containing your string. For example

apropos("lm")

will give the list of all functions containing the string lm

Use of example()

example(lm) will provide an example of your required function that is in this case, an example of the function lm()

Online Help

There is a huge amount of information about R on the web. On CRAN you will find a variety of help/ manuals. There are also answers to FAQs (Frequently Asked Questions) and R News (contains interesting articles, book reviews, and news of forthcoming releases. The search facility of the site allows you to investigate the contents of the R documents, functions, and searchable mail archives.

You can search your required function or string in help manuals and archived mailing lists by using

RSiteSearch("read.csv")

Get Vignettes

vignette is an R jargon for documentation and is written in the spirit of sharing knowledge, and
assisting new users in learning the purpose and use of a package. To get some help in R try ?vignette. Vignettes are optional supplemental documentation, that’s why not all packages come with vignettes.

vignette()          # will show available vignettes
vignette("foo")     # will show specific vignette

Now you have learned about getting help in R, now you can continue with the other R tutorials. It is possible that you do not understand something discussed in the coming R tutorials. If this happens then you should use the built-in help system before going to the internet. In most cases, the help system of R Language will give you enough information about the required function that you have searched for.

Some Sources of R Help/ Manual/ Documentations

https://cran.r-project.org/manuals.html

https://cran.r-project.org/other-docs.html

https://www.r-project.org/help.html

https://cran.r-project.org/bin/windows/base/rw-FAQ.html

R Objects, Workspace, and .RData file

The post is about an introduction to workspace, R objects, and .Rdata file in R language.

R Language as Functional Language

The R program’s structure is similar to the programs written in other computer languages such as C or its successors C++ and Java. However, important differences between these languages and R are (i) R has no header files, (ii) most of the declarations are implicit, (iii) there are no pointers in R, and (iv) text and strings as vectors can be defined and manipulated directly.

R is a functional language. Most of the computation in R is handled using functions. The R language environment is designed to facilitate the development of new scientific computation tools.

R Objects

Everything (such as functions and data structure) in R is an object. To see the names of all R objects in the workspace, on the R command prompt just type,

ls()

objects() is an alternative to ls() function. Similarly, typing the name of any object on the R prompt displays (prints) the content of that object. As an example type q, mean, and lm, etc. on the R prompt.

R Workspace

It is possible to save individual objects or collections of objects into a named image file. The named image file has an extension of .RData. Some possibilities to save an object from R workspace are:

To save the content of R workspace into a file .RData, type

save.image()

To save objects in the file archive.RData, type

save.image(file = "archive.RData")

To save some required objects in data.RData, type

save(x, y, file = "data.RData")

These image files can be attached to make objects available in the next R session. For example.

attached ("arvhive.RData")
R workspace, R Objects

Note that when quitting, R offers the option of saving the workspace image. By default, the workspace is saved in an image file (.RData) in the working directory. The image file can be used in the next R session. Saving the workspace image will save everything from the current workspace. Therefore, use the rm() function to remove objects that are not further required in the next R session.

For further details about saving and loading R workspace visit: Save and Load R Workspace

Learn Statistics and Data Analysis