Professional Documents
Culture Documents
D.A Lab Assignment-05: Input
D.A Lab Assignment-05: Input
A LAB ASSIGNMENT-05
{NAME:RUDRASISH MISHRA} | {SECTION:IT-8} | {ROLL NO:1906649}
Q1). Explore any 5 built-in dataset and perform the following for each
dataset
● Display the summary
● Display the structure
● Display the first 5 rows
● Display the number of rows
● Display the number of columns
SOLUTION:
data(USArrests)
summary(USArrests)
View(USArrests)
str(USArrests)
head(USArrests, 5)
nrow(USArrests)
ncol(USArrests)
OUTPUT:
1.LINE CHARTS:
INPUT:
cars_649 <- c(1, 3, 6, 4, 9)
plot(cars_649)
plot(cars_649, type = "o")
plot(cars_649, type="o", col="blue")
plot(cars_649,type = "o", col = "black", xlab = "Month",
ylab = "Unit Produced")
trucks_649 <- c(1, 5, 7, 5, 5)
lines(trucks_649, type = "o", col = "blue")
OUTPUT:
2.DOT PLOTS:
INPUT:
OUTPUT:
3.BAR PLOT:
INPUT:
OUTPUT:
4.BOX PLOT:
INPUT:
OUTPUT:
5.HISTOGRAM:
INPUT:
input_649 <- table(Arthritis$Improved)
print(head(input_649))
barplot(input_649, main="Simple Bar Plot",
xlab="Improvement", ylab="Frequency")
OUTPUT:
6.PIE CHART:
INPUT:
city_649 <- c(23, 56, 20, 63)
label_649 <- c("FRANCE", "USA", "CHINA", "INDIA")
piepercent_649<- round(100 * city_649 / sum(city_649), 1)
pie(city_649, label_649 = piepercent_649,
main = "City pie chart", col = rainbow(length(city_649)))
legend("topright", c("FRANCE", "USA", "CHINA", "INDIA"),
cex = 0.5, fill = rainbow(length(city_649)))
OUTPUT:
7.SCATTER PLOT:
INPUT:
input_649 <- mtcars[, c('wt', 'mpg')]
plot(x_649 = input_649$wt, y_649 = input_649$mpg,
x_649lab = "Weight",
y_649lab = "Milage",
x_649lim = c(1.5, 4),
y_649lim = c(10, 25),
main = "Weight vs Milage"
)
OUTPUT:
den_649 = density(mtcars$mpg)
plot(den_649,main=" Kernel Density of Miles Per Gallon")
polygon(den_649, col="red", border="blue")
OUTPUT:
OUTPUT:
library(ggplot2)
library(dplyr)
library(gapminder)
data_649 <- gapminder %>% filter(year=="2007") %>%
dplyr::select(-year)
ggplot(data_649, aes(x=gdpPercap, y=lifeExp, size = pop)) +
geom_point(alpha=0.7)
OUTPUT: