#Example-1 data(“longley”) barplot(GNP ~ Year, data = longley)

#Example-2 barplot(cbind(Employed, Unemployed) ~ Year, data = longley)

#Example-3 op <- par(mfrow = 2:1, mgp = c(3,1,0)/2, mar = .1+c(3,3:1)) summary(d.Titanic <- as.data.frame(Titanic)) barplot(Freq ~ Class + Survived, data = d.Titanic, subset = Age == “Adult” & Sex == “Male”, main = “barplot(Freq ~ Class + Survived, *)“, ylab =”# {passengers}“, legend.text = TRUE) # Corresponding table : (xt <- xtabs(Freq ~ Survived + Class + Sex, d.Titanic, subset = Age==”Adult”))

data(“Titanic”) class(Titanic)

////// data(“Titanic”)

barplot(rbind(male, female) ~ Class, data = Titanic, beside = TRUE, legend = TRUE, main = “Bar Plot of Class by Gender”, xlab = “Class”, ylab = “Count”)

#Example-4 par(op) # Default method require(grDevices) # for colours tN <- table(Ni <- stats::rpois(100, lambda = 5)) r <- barplot(tN, col = rainbow(20)) #- type = “h” plotting is ’bar’plot lines(r, tN, type = “h”, col = “blue”, lwd = 2)

Load the Titanic dataset

data(“Titanic”)

Alternatively, print the entire dataset

print(Titanic)

load(longley) print(longley)