0% found this document useful (0 votes)
9 views4 pages

Maruel Data Visualization

Uploaded by

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

Maruel Data Visualization

Uploaded by

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

Excellence | Service | Leadership and Good Governance | Innovation | Social Responsibility | Integrity | Professionalism | Spirituality

Name: MARUEL J. VANZUELA_______________________ Score: _____


Course, Yr. & Sec.: BSME 2-A______________________ Date: 06-27-24____
Subject: Engineering Data Analysis

Assignment #2
DATA VISUALIZATION IN R

No Code / Syntax in R Output / Plot / Figure / Model


1. Loading # load data set
Built-in R data(mtcars)
Dataset # Print the first 10 rows
head(mtcars, 10)

2. Bar #CREATE Bar Graph


Graphs > ddata <-
(Vertical) table(mtcars$cyl)
> barplot(ddata)

3. Bar #CREATE Bar Graph


Graphs > ddata <-
(Horizontal) table(mtcars$cyl)
> barplot(ddata, horiz =
TRUE)

4. Bar ddata <-


Graphs with table(mtcars$cyl)
Legend > barplot(ddata, main =
"mtcars:
+ Number of Cylinders",
xlab = "No
+ of Cylinders", ylab =
+
"Frequency", legend =
+
rownames(ddata), col =
c("red",
+
"green", "blue"))
Excellence | Service | Leadership and Good Governance | Innovation | Social Responsibility | Integrity | Professionalism | Spirituality

5. hist(mtcars$mpg, xlab =
Histogram "Miles per
+ Gallon", ylab =
"Frequency", , col =
+ "blue", main
= "mtcars: Miles per
+ Gallon")

6. Pie ddata <- c(128, 40, 19)


Charts > llabels <- c("Cebu
City", "Lapu-Lapu
+ City", "Mandaue City")
> pie(ddata, llabels,
main = "DOH
+ Cebu Provnce Covid
Update(Feb 3,
+ 2021")

7 Pie Charts ddata <- c(128, 40, 19)


with > percent <-
Percentage round(ddata/sum(ddata)*1
00)
> llabels <-
paste(c("Cebu City",
"Lapu-Lapu
+ City", "Mandaue
City"),
+
"",percent,"%",sep="")
> pie(ddata, llabels,
col = rainbow(3), main =
+ "DOH Cebu
Province Covid
Update(Feb 3,
+ 2021")

8. Pie Chart ddata <- c(128, 40, 19)


using Plotrix percent <-
Library round(ddata/sum(ddata)*100)
llabels <- paste(c("Cebu
City", "Lapu-Lapu City",
"Mandaue
City"),
"",percent,"%",sep="")
pie3D(ddata, labels =
llabels,col = rainbow(3),
explode = 0.0, main =
"DOH Cebu Province
Covid Update(Feb 3, 2021")
Excellence | Service | Leadership and Good Governance | Innovation | Social Responsibility | Integrity | Professionalism | Spirituality

9. Density ddata <-


Data density(mtcars$mpg)
> plot(ddata, xlab =
"Miles per
+ Gallon", ylab =
"Frequency",main =
+ "Density
Data:: Miles per
Gallon")

10. Line ddata <- (mtcars$mpg)


Chart > plot(ddata, type =
"b", xlab = "Miles per
+ Gallon", ylab =
"Frequency", main =
"mtcars:
+ Line Chart")
Excellence | Service | Leadership and Good Governance | Innovation | Social Responsibility | Integrity | Professionalism | Spirituality

You might also like