STA1231

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

STA1231: STATISTICAL

COMPUTING I

Ibrahim Yusuf Ibrahim, Department of Mathematical


Sciences, Bayero University Kano.

Lecture 1: Basic Skill in R


R-programming
R programming is a programming language and software environment
used for statistical computing and graphics. It provides a wide variety of
statistical and graphical techniques, including linear and nonlinear
modeling, classical statistical tests, time-series analysis, clustering, and
more. R is widely used by statisticians, data scientists, and researchers
for data analysis and visualization. It is an open-source language, which
means it is freely available and can be extended by users through
packages and libraries. R has a large and active community that
contributes to its development and provides support through forums and
online resources.
Open R-Studio
When You open Rstudio, you should see four
Rstudio windows:

1. Source window: Holds a collection of your


code or “R script”.
2. Console Window: This is the area that allow
to instruct R what to do by executing
commands. (However, after you close the
session, command will be lost)
3. Environment and history window: You can
see objects in your working space and view
your command history.
4. Files, plots, packages, help window: You can
view file directories, view plots and packages,
and also access R help.
Comments
Recall when we used to
add headings to our
assignment in secondary
school in order to
remember?, Well, it is
good practice to add
comments to your R
scripts as well
Basic Numerical Operations in R
ADDITION

SUBTRACTION

MULTIPLICATION

DIVISION

Addition:

Let Simply add 1+2 in the Rscript.


Type in the following code, highlight
the code and and select ‘Run’

Output
Basic Numerical Operations in R Con’t
R script Result Shown here
Saving A Rscript
Please Sva your Rscript!

It is a good practice to save your R


script so that you can continue where
you left off just in case you need need to
leave the session or if you want to come
back to the code at a later time.

Click ‘file’ save as’


Saving A Rscript Con’t
After clicking ‘file’ and ‘save’

You will be taken to a window


that will allow you select where
to save the R-script and also how
to name the Rscript

We will call this Rscript


STA1231

Then, select ‘save’


Data Object in R
Scalar

Vectors

Factors

List

Data Frames
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t
Data Object in R Con’t

You might also like