Sie sind auf Seite 1von 80

Basics of R Programming and

Data Structures

By Shano Solanki
Asst. Prof., CSE,
NITTTR, Chandigarh
Beginning with R Programming
• After installation of R Console or RStudio you
will find a R prompt i.e. >
• We can write commands on R prompt and by
pressing enter output will be displayed after
execution.
• We can quit from R working environment by
typing q() or quit().
Installation of packages
> installed.packages()
This command can be used for seeing the list of
installed packages
> library(package)
This command is used for loading packages as
required
> help(mean)
This command is used for reading help on required
item say any function for ex: help on mean as shown
in above example
> search()
This command shows a list of packages (or objects)
that are loaded and available for use.
Arithmetic Operators in R
Arithmetic Operators in R
Operator Description
+ Addition
– Subtraction
* Multiplication
/ Division
^ Exponent
%% Modulus (Remainder from division)
%/% Integer Division

> x <- 5
<- is an assignment operator for assigning any value to R variable
and this can be used in place of ‘=‘ for doing assignment of
values.
Relational Operators in R
Relational Operators in R

Operator Description

< Less than


> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to
Logical Operators in R

Logical Operators in R

Operator Description

! Logical NOT

& Element-wise logical AND

&& Logical AND

| Element-wise logical OR

|| Logical OR
R as an calculator
> 3+9+12-7
[1] 17
> 12+17/2-3/4*2.5
[1] 18.625
> (12+17/2-3/4)*2.5
[1] 49.375
In maths sequence of operations can be
changed using parenthesis as in above
example
Some of the mathematical operations
available in R
> 3+9+12-7
[1] 17
> 12+17/2-3/4*2.5
[1] 18.625
> (12+17/2-3/4)*2.5
[1] 49.375
> pi
[1] 3.141593
> x=2
> y=3
> x^y
[1] 8
Some of the mathematical operations
available in R
> sqrt(x)
[1] 1.414214
> abs(x)
The log() command gives
[1] 2
> factorial(y)
you the natural log as
[1] 6 default unless you
 log(x,base=2) specify the base required
 [1] 1 as an additional
 log10(x) instruction
 [1] 0.30103
 log2(2)
 [1] 1
Storing the results of computation and
performing operations on stored values
> ans1=23+14/2-18+(7*pi/2)
> ans1
[1] 22.99557
> ans2=13+11+(17-4/7)
> ans2
[1] 40.42857
> ans1+ans2
[1] 63.42415
Some of the mathematical operations
available in R
> exp(4)
[1] 54.59815
> cos(x)
[1] -0.4161468
> sin(x)
[1] 0.9092974
> tan(x)
[1] -2.18504
> sin(45*pi/180)
[1] 0.7071068
Use the scan command for making
data
> data3 = scan()
1: 10 20 30
4: 40 50
6:
Read 5 items
> Data3
[1] 10 20 30 40 50
The scan command prompts you to enter your data.
The initial command creates a new data object
called data3 and initiates the data entry process.
Basic Commands in R
>myString <- "Hello, World!"
> print ( myString)
output [1] "Hello, World!“

• R is case sensitive, so take care while choosing


variable name or writing any function or
package name.
• We need not to declare variables in R.
String Manipulation : Concatenating Strings - paste()
function
• Many strings in R are combined using the paste() function.
It can take any number of arguments to be combined
together.
• Syntax
• The basic syntax for paste function is −
• paste(..., sep = " ", collapse = NULL) Following is the
description of the parameters used −
• ... represents any number of arguments to be combined.
• sep represents any separator between the arguments. It is
optional.
• collapse is used to eliminate the space in between two
strings. But not the space within two words of one string.
Paste Command
• a <- "Hello"
• b <- 'How'
• c <- "are you? "
• print(paste(a,b,c))
• print(paste(a,b,c, sep = "-"))
• print(paste(a,b,c, sep = "", collapse = ""))
• output
• [1] "Hello How are you? "
• [1] "Hello-How-are you? "
• [1] "HelloHoware you? "
Data Structures
in
R Programming
Basic Data Types

• For any programming language, It is needed to use


various variables to store the information
• Based on the data type, the operating system allocates
memory and decides what can be stored in the reserved
memory.
• Every individual data value has a data type that tells what
sort of value it is. The most common data types are
 numbers, which R calls numeric values,
 text, which R calls character values.
 Boolean
Data Structures (DS) in R

• Data Structures are containers to store and


retrieve data. Like stacks, queues, graphs and
trees.
• Data structures help us to store different types of
data in different formats.
• They are series of data elements that are
connected together so that they can be accessed
in a specific, well-defined way.
Data Structures (DS) in R

• The variables are assigned with R-Objects and the


data type of the R-object becomes the data type of
the variable
• The basic important data structures in R are :
• Vectors
• Matrices
• Arrays
• Factors
• Lists
• Dataframes
Data Structures (DS) in R

The basic data structures in R can be divided into two types

1. Homogeneous : All the elements in the data structure are of same


type (string, number, boolean etc)
2. Heterogeneous : The elements in the data structure can be of mixed
type.

Data Sstructure Type Dimensions

Vector Homogeneous 1
Matrix Homogeneous 2
List Heterogeneous 1
Array Homogeneous any
Data Frames Heterogeneous 2
Factors Homogeneous -
Vectors

A Vector is one dimensional data structure that stores


values of the same type (homogeneous)
A vector consisted of elements that are most commonly
Character, logical and Numeric
Members in a vector are called components.
They have the following properties:
• Type ,typeof, What it is
• Length, length(), how many elements it contains.
• Attributes, attributes(), additional arbitrary
metadata.

To create vector with more than one element, use


c() function which means to combine the elements
into a vector.
Vectors

# Create a vector.
capsicum <- c('red','green',"yellow")
print(capsicum)

# Get the class of the vector.


print(class(capsicum)) Executing the program....
[1] "red" "green" "yellow“
[1] "character"
Exercise
If vector x is having members 1,2,3 and vector y is having
members “chd”, ”Delhi”, ”Mumbai”. If we combine both the
vectors what will be the new vector?
Examples
x <- c(1,3,5,7,9,11)
y <- c(6.5,4.3,9.1,-8.5,0,3.6)
z <- c("dog","cat",”mouse”) --- character vectors
log_var <- c(TRUE, FALSE, T, F) -----logical vectors
Vectors can also have a names attribute, which allows one to refer to elements
by name.

> x <- c(a=1,b=3,c=5,d=7,e=9,f=11)


> names(x)
> [1] "a" "b" "c" "d" "e" "f"
Examples : Functions used for vectors
Length(x) -------Find the length of x vector
# [1] 6

typeof(x) -------Find the type of x vector


# [1] “double”

mode(x) -------Find the storage of x vector


# [1] “numeric”

class(x) -------Find the type of x vector


# [1] “numeric”

names(w) -------Gives names to the components of x


vector
# [1] “a” “b” “c ”
Creating a vector
> x <- c(1, 5, 4, 9, 0)
> typeof(x)
[1] "double“
> length(x)
[1] 5
> x <- c(1, 5.4, TRUE, "hello")
>x
[1] "1" "5.4" "TRUE" "hello“
> typeof(x)
[1] "character"
Creating a vector in another way
>y<--vector()
>y <- vector(length=2)
> y[1]=4
> y[2]=6
>y
[1] 4 6
Creating a vector using assignment
operator
• > x <- 1:7; x
• [1] 1 2 3 4 5 6 7
• > y <- 2:-2; y
• [1] 2 1 0 -1 -2
Recycling Rule in Vectors

If two vectors are of unequal length, the shorter one will be


recycled in order to match the longer vector.

For example, the following vectors u and v have different


lengths, when their sum is computed

> u = c(10, 20, 30)


> v = c(1, 2, 3, 4, 5, 6, 7, 8, 9)
>u+v
[1] 11 22 33 14 25 36 17 28 39
Recycling rule in vectors
Exercise: What happens when the length of the longer
vector is not a multiple of that of the shorter
x<-c(1,2,3)
> y<-c(10,20,30,40)
> x +y
[1] 11 22 33 41

Warning message:
In x + y : longer object length is not a multiple of shorter
object length
Vector Index
Vector values can be retrieved by using an index inside a single
square bracket "[]" operator. Vector index are 1- based

For example, Use the index position 3 for retrieving the third member.
> s = c("aa", "bb", "cc", "dd", "ee")
> s[3]
[1] "cc"

Negative Index

If the index is negative, it would strip the member whose position has the same
absolute value as the negative index. For example, the following creates a vector
slice with the third member removed.
> s[-3]
[1] "aa" "bb" "dd" "ee"

Out-of-Range Index
If an index is out-of-range, a missing value will be reported via the symbol NA.
> s[10]
[1] NA
Accessing vector elements
>x
[1] 0 2 4 6 8 10
> x[3] # access 3rd element
[1] 4
> x[c(2, 4)] # access 2nd and 4th element
[1] 2 6
> x[-1] # access all but 1st element
[1] 2 4 6 8 10
> x[c(2, -4)] # cannot mix positive and negative integers Error in
x[c(2, -4)] : only 0's may be mixed with negative subscripts
> x[c(2.4, 3.54)] # real numbers are truncated to integers
[1] 2 4
DELETE A VECTOR

>x
[1] -3 -2 -1 0 1 2
> x <- NULL
>x
NULL
> x[4]
NULL
We can delete a vector by simply assigning a null to it.
Some operations using Numeric
Vectors
> x<-c(10,12,3,5,28,14)
> sum(x)
[1] 72
> max(x)
[1] 28
> min(x)
[1] 3
> length(x)
[1] 6
> sort(x,descending=TRUE)
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
unused argument (descending = TRUE)
> sort(x,decreasing=TRUE)
[1] 28 14 12 10 5 3
Some operations using Numeric
Vectors
> sort(x)
[1] 3 5 10 12 14 28
> sort(x,decreasing=FALSE)
[1] 3 5 10 12 14 28
> mean(x)
[1] 12
> class(x)
[1] "numeric“
> x<-2
> sqrt(x)
> [1] 1.414214
Arithmetic operations using Numeric
Vectors: applied on all elements of an
vector
> x+5
[1] 15 17 8 10 33 19
> x-5
[1] 5 7 -2 0 23 9
> x*5
[1] 50 60 15 25 140 70
> x/2
[1] 5.0 6.0 1.5 2.5 14.0 7.0
Creating a Vector using assign and rep function

> assign("y",c(2,4,5,8,10,13,20))
>y
[1] 2 4 5 8 10 13 20
> rep(1:5,times=2)
[1] 1 2 3 4 5 1 2 3 4 5
> rep(1:5,each=2)
[1] 1 1 2 2 3 3 4 4 5 5
> rep(1:5,each=3)
[1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5
> z<-rep(1:5,each=3)
>z
[1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5
Creating a Character vector and logical vector

> colours=c("RED","ORANGE","GREEN","BLUE")
> colours
[1] "RED" "ORANGE" "GREEN" "BLUE"
> is.character(colours)
[1] TRUE
> a<-c(TRUE,FALSE,TRUE,NA)
>a
[1] TRUE FALSE TRUE NA
> b<-c(12,-4,3,10,-5)
> b<0
[1] FALSE TRUE FALSE FALSE TRUE
Creating a Vector using seq function

> a<-seq(1,20,by=2)
>a
[1] 1 3 5 7 9 11 13 15 17 19
> a<-seq(from=1,to=10,by=2)
>a
[1] 1 3 5 7 9
Mathematical operations between two numeric vectors

> r<-c(3,6,9,12,15);y<-c(5,4,3,2,1)
> t<-r+y
>t
[1] 8 10 12 14 16
> t<-r-y
>t
[1] -2 2 6 10 14
> t<-r*y
>t
[1] 15 24 27 24 15
Entering text as data
> scan(what='character')
1: shano
2: naveen
3: krishan
4: alpana
5:
Read 4 items
[1] "shano" "naveen" "krishan" "alpana"
Modifying a vector in R
>x
[1] -3 -2 -1 0 1 2
> x[2] <- 0; x # modify 2nd element
[1] -3 0 -1 0 1 2
> x[x<0] <- 5; x # modify elements less than 0
[1] 5 0 5 0 1 2
> x <- x[1:4]; x # truncate x to first 4 elements
[1] 5 0 5 0
Reading data using separator
> names= scan(sep=',',what='character')
1: shano, naveen, krishan, alpana
5:
Read 4 items
> names [1] "shano" " naveen" "krishan"
"alpana"
Matrices
Matrices
• Matrix is a two dimensional data structure an d it can be created by
specifying the number of rows and columns, and specifying the entries

• A matrix is a collection of data elements arranged in a two-dimensional


rectangular layout. The following is an example of a matrix with 2 rows and
3 columns.

• Dimension of the matrix can be defined by passing appropriate values for


nrow and ncol. Providing both the values is not necessary. If one is
provided, other will be inferred from length of the data

Example
> X <- matrix(c(1,2,3,4,5,6),nrow=2,ncol=3);
>X Columnwise
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
Matrices
Example
> A <- matrix(1:9,nrow=3,ncol=3,byrow=TRUE)
>A
[,1] [,2] [,3]
[1,] 1 2 3 Rowwise
[2,] 4 5 6
[3,] 7 8 9

Matrix can also be recycled as shown below

> A<- matrix(1,nrow=5,ncol=5)


>A
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 1 1
[2,] 1 1 1 1 1
[3,] 1 1 1 1 1
[4,] 1 1 1 1 1
[5,] 1 1 1 1 1
Matrices
An element at the mth row, nth column of A can be accessed by the expression A[m, n].

> A <- matrix(1:9,nrow=3,ncol=3, byrow=TRUE)


>A
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
> A[2,3]
[1] 6

The entire mth row A can be extracted as A[m, ].

> A[2,]
Similarly, the entire nth column A can be
[1] 4 5 6
extracted as A[ ,n].
> A[,3]
[1] 3 6 9
> A[ ,c(1,3)]
To extract more than one [,1] [,2]
rows or columns at a time. [1,] 1 3
[2,] 4 6
[3,] 7 9
Matrices
The transpose of a matrix by interchanging its columns and rows
with the function t .
>A
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
> t(A)
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9

dim() function is used to find the size of the matrix


> dim(A)
[1] 3 3
Treating a Vector As a One-Column Matrix
A matrix can be degenerated to a vector if it has only one column.
By applying
as.matrix()

>g<-c(6,2,9)
> a<- as.matrix(g)
>a
[,1]
[1,] 6
[2,] 2
[3,] 9
Adding/Deleting Elements of Vectors and Matrices
Vectors and matrices are of fixed length and dimensions. However,
they can be reassigned
> g<-c(6,2,9)
> g<-c(g,20)
>g
[1] 6 2 9 20

x<-matrix(c(1:9),nrow=3,ncol=3)
>x A row or column can be
[,1] [,2] [,3] added using rbind() and
[1,] 1 4 7 cbind() function
[2,] 2 5 8
[3,] 3 6 9
respectively.
> cbind(x, c(10,20,30))
[,1] [,2] [,3] [,4]
[1,] 1 4 7 10
[2,] 2 5 8 20
[3,] 3 6 9 30
> x<-matrix(c(1:9), nrow=3,ncol=3)
> x<-rbind(x, c(90,91,92))
>x
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
[4,] 90 91 92
p <- matrix(c(7,4,2), nrow=3, ncol=1)
>p
[,1]
[1,] 7
[2,] 4
[3,] 2
> x <- matrix(c(1:6),nrow=3,ncol=2)
>x
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> z <-cbind(p,x)
>z
[,1] [,2] [,3]
[1,] 7 1 4
[2,] 4 2 5
[3,] 2 3 6
>z
[,1] [,2] [,3]
[1,] 7 1 4
[2,] 4 2 5
[3,] 2 3 6
> q1
[,1]
[1,] 1
[2,] 2
[3,] 3
> q2=t(q1)
> q2
[,1] [,2] [,3]
[1,] 1 2 3
> hh <- rbind(z,q2)
> hh
[,1] [,2] [,3]
[1,] 7 1 4
[2,] 4 2 5
[3,] 2 3 6
[4,] 1 2 3
Arrays, List, Data Frames using
R

53
INTRODUCTION TO ARRAYS IN R

54
INTRODUCTION TO ARRAYS IN R

55
This array() function creates two matrices each of order 2 by 3 with 12
elements in total starting from 1 till 12. The first argument is for elements
of an array and the second argument dim sets the dimensions of an array.

Now we can see that an array of order 2 by 3 by 2 is created with the given
elements 1 to 12. Note that the product of the dimensions should always
match the number of elements in the array.
We can also assign this array to an object x using assign operator.

> array(c(1:12), dim=c(2,3,2))


> , , 1
> [,1] [,2] [,3]
> [1,] 1 3 5
> [2,] 2 4 6
> , , 2
> [,1] [,2] [,3]
> [1,] 7 9 11
> [2,] 8 10 12
> array(c(1:12), dim=c(2,3,2)) -> x

56
Finding the type and dimension of an array:
It is possible to find the type of elements in the array along with the type
of array using particular command in R.

To find the type of the array x which we have created earlier, is() function
displays the type of an array and elements which forms the array.

This dim()function helps us to find the dimensions of an array in R. It


displays the number of rows, columns and matrices in an array as
output.

> is(x)
> [1] "array" "structure" "vector"
> dim(x)
> [1] 2 3 2

57
Each element in an array will have unique position. For example
the element present in 1st row, 2nd column of the second
matrix will be having the position [1,2,2,].

Similarly, as matrix we can extract element, row, column and


matrix by mentioning the position after the array.

Some of the examples are as follows:


x[1,2,2] : To see (1,2)th element from 2nd matrix of array x.
x[1,2,] : To see (1,2)th elements from each two matrices of
array x.
x[1,,2] : To see 1st row from 2nd matrix of array x.
x[,2,2] : To see 2nd column of 2nd matrix of array x.
x[1,,] : To see 1st rows from each two matrices of array x.
x[,2,] : To see 2nd columns from each two matrices of array x.
x[,,2] : To see the 2nd matrix of array x.
58
LIST

59
Creating a list:
Suppose you want to store the information of a person like his name, wife's
name, no. of children and their ages, list is the data structure to be used.

This list() function creates a list with the given components which consists of
numeric vector and strings. A list may also contain a matrix, array etc. and can
be assigned to another variable also
> stu_list <- list(name="rahul",fathers_name="Aneesh
Gupta", num_subjects=3, sub_marks=c(70,80,85))
$name
[1] "rahul"
$fathers_name
[1] "Aneesh Gupta"
$num_subjects
[1] 3
$sub_marks
[1] 70 80 85
60
Assign a list to an object and extract a particular
component from a list :
Now let us assign this created list in an object ‘Lst’ by assign an operator.

Each element in a list will have unique position. To extract a single component
from a list, its position, or name of the component can be used.

Suppose you want to extract a particular component from a list, say “Rahul"
from the above created list, you may have to type either Lst[1] or Lst[['name']] or
Lst$name. We can also extract an particular sub component from an list, like
subject marks of first student in list.
> stu_list <- list(name="rahul",fathers_name="Aneesh Gupta",
num_subjects=3, sub_marks=c(70,80,85)) -> Lst
> Lst[['name']]
[1] "rahul"
> Lst[['fathers_name']]
[1] "Aneesh Gupta“
> Lst[4[1]]
$sub_marks
[1] 70 80 85
61
Data Frames

62
To access an existing dataframe:
Lets say we want to access the existing or in-built dataframe in R called
mtcars.
Just type the name of the dataframe and hit Enter.
Now we can see the dataframe with all the rows and columns. These row
names and column names are predefined in the built‐in dataframe called
mtcars in R.

63
To create a new dataframe :
Here we will show you an example of how to create a dataframe in R.
Suppose we want to create a dataframe with employee details by the vectors are
shown in the R console. data.frame() is the function to be used to create a
dataframe.

To get the dimension of a data frame we can use dim() function.


> dim(employ.data)

64
> name<-c("alpna","krishan",'naveen')
> age<-c(35,38,43)
> location<-
c("gurgaon","noida","faridabad") >
stu_rec<-data.frame(name,age,location)
> stu_rec
name age location
1 alpna 35 gurgaon
2 krishan 38 noida
3 naveen 43 faridabad
65
To get the top few or bottom few observations of a
dataframe:
Consider the inbuilt dataset mtcars we have seen. Now if we want to extract
only top few observations of the dataframe, we can use head() command .

Consider the inbuilt dataset mtcars we have seen. Now if we want to extract
only bottom few observations of the dataframe, we can use tail() command .

66
To edit the dataframe in R:
We can edit the dataframes in R easily using the edit() command.
Consider the dataset mtcars.
> edit(mtcars)

67
Some more commands
> getwd()
[1] "C:/Users/A/Documents“
> dir()
> List.files()
You can look at a directory and see which files
and folders are within it using dir() and list.files()
commands . By default it looks in the current
working directory.
> dir('C:/Users/A/Desktop')
Command to see the files/folders on desktop
Viewing previously loaded named
objects using ls() command
> ls()
[1] "A" "a_data_frame" "ans1" "ans2"
[5] "B" "data3" "i" "mystring“
[9] "names" "our.data" "pp" "V"
[13] "x" "y"
> ls(pattern='a')
[1] "a_data_frame" "ans1" "ans2" "data3" [5] "names" "our.data“
> ls(pattern='ns') [1] "ans1" "ans2"
> ls(pattern='^d')
[1] "data3"
> ls(pattern='^d|^a') [1] "a_data_frame" "ans1" "ans2" "data3“
> ls(pattern='g$') [1] "mystring" > ls(pattern='a.s') [1] "ans1" "ans2"
Viewing previously loaded named objects
containing character a, ns, starting with d
> ls(pattern='a')
[1] "a_data_frame" "ans1" "ans2" "data3"
[5] "names" "our.data"
> ls(pattern='ns')
[1] "ans1" "ans2"
> ls(pattern='^d')
[1] "data3“
Viewing previously loaded named objects
containing character starting with d or a, ending
with g, including a and s both in object names
> ls(pattern='^d|^a')
[1] "a_data_frame" "ans1" "ans2" "data3"
> ls(pattern='g$')
[1] "mystring"
> ls(pattern='a.s')
[1] "ans1" "ans2“
| pipe is used for or condition and ^ is used for
telling pattern starting with some character
Removing objects from R
> rm(list)
> remove(list)
Example of remove command for removing
object named “x”
> remove("x")
> ls()
[1] "A" "a_data_frame" "ans1" "ans2"
[5] "B" "data3" "i" "mystring"
[9] "names" "our.data" "pp" "V"
[13] "y"
Control Structures
These allow you to control the flow of execution of a
script typically inside of a function. Common ones
include:
– if, else
– for
– while
– repeat
– break
– next
– return
We don't use these while working with R interactively but
rather inside functions.
If else statement
if (condition)
{ # do something }
else
{ # do something else }

Example:
x <- 1:15
if (sample(x, 1) <= 10)
{ print("x is less than 10") }
else
{ print("x is greater than 10") }
For loop
• A for loop works on an iterable variable and
assigns successive values till the end of a
sequence.
for (i in 1:10) { >for(i in 1:10){
print(i) + print(i)} [1] 1
} [1] 2
for (i in 1:20) { [1] 3
[1] 4
if (i%%2 == 1) {
[1] 5
next [1] 6
} else { [1] 7
[1] 8
print(i) [1] 9
} [1] 10
}
Another example of for loop

x <- c("apples", "oranges", "bananas", "strawberries")


for (i in x) {
print(x[i])
}
for (i in 1:4) {
print(x[i])
}
for (i in seq(x)){
print(x[i])
}
for (i in 1:4) print(x[i])
repeat and break
repeat {
# simulations; generate some value have an
expectation if within some range,
# then exit the loop
if ((value - expectation) <= threshold) {
break
}
}
While loop

i <- 1
while (i < 10) {
print(i)
i <- i + 1
}
Some useful commands
• Press esc to come back to command prompt of R
if we want to forcefully end some command and
come back to command prompt
• R ignores spaces, so we can skip giving spaces
while writing mathematical expressions
> q() for exiting from R
> ?mean for checking help on mean
> help(mean) alternate method to check help on
mean
Thank You

Das könnte Ihnen auch gefallen