0% found this document useful (0 votes)
17 views3 pages

ISYS3447 - Week 3 Notes

Uploaded by

duong duong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

ISYS3447 - Week 3 Notes

Uploaded by

duong duong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

RMIT Classification: Trusted

Descriptive Analytics: Bivariate R Commands & Functions

Categorical Variable

Some main Functions

table() develops a table.

table(dataset$column) develops as frequency table for one variable.

table (dataset$column, dataset$column) develops cross-tabulation for two


variables.

prop.table(table) converts numbers inside a table to percentage (relative


frequency).

barplot() returns a bar plot.

Example:

Bar Chart:

t1 <- table(dataset$column, dataset$column)


t1
t2 <- prop.table(t1)
t2
barplot(t1,
xlab = "insert x axis name",
ylab = "insert y axis name",
legend = TRUE,
col = c("Gold", "Gold3", "Orange", "Orange3"),
beside = TRUE)

Quantitative Variables

Scatter Chart:

plot(dataset$column, dataset$column,
xlab = "insert x axis name", xlim=c(x1,x2),
ylab= "insert y axis name", ylim=c(x1,x2),
main = "insert main title",
col = "choose a color")

Covariance

-1-
RMIT Classification: Trusted

cov(dataset$column, dataset$column)

Correlation Coefficient

cor(dataset$column, dataset$column)

Returning Columns and Rows

head(dataset)
dataset[row,column] returns a single value.
dataset[row,] returns a row.
dataset[,column] returns a column.
dataset[c(rowx,rowy),] returns a more than one row.
dataset[,c(columnx,columny)] returns a more than one column.
dataset[c(rowx:rowy),] returns a range of rows.
dataset[,c(columnx:columny)] returns a range of columns.
dataset[dataset$column == “name of the item”] returns a specific value.
dataset[dataset$column >= “name of the item”] returns some specific
values.

Supplementary Functions

Arithmetic Operators in R

+ Addition

– Subtraction

* Multiplication

/ Division

^ Exponent

%% Modulus (Remainder from division)

-2-
RMIT Classification: Trusted

%/% Integer Division

Relational Operators in R

< Less than

> Greater than

<= Less than or equal to

>= Greater than or equal to

== Equal to

!= Not equal to

Logical Operators in R

! Logical NOT

& Element-wise logical AND

&& Logical AND

| Element-wise logical OR

|| Logical OR

Assignment Operators in R

<-, <<-, = Leftwards assignment

->, ->> Rightwards assignment

-3-

You might also like