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

r - Program 4 Programs

The document contains several R programming examples demonstrating matrix operations, graphical displays of Poisson distribution, histograms, and pie charts. It includes code snippets for creating matrices, generating Poisson-distributed data, plotting histograms of student marks, and visualizing expenditure distribution with a pie chart. Each section provides a brief description of the data and the intended graphical representation.

Uploaded by

Preethi Victor
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)
3 views4 pages

r - Program 4 Programs

The document contains several R programming examples demonstrating matrix operations, graphical displays of Poisson distribution, histograms, and pie charts. It includes code snippets for creating matrices, generating Poisson-distributed data, plotting histograms of student marks, and visualizing expenditure distribution with a pie chart. Each section provides a brief description of the data and the intended graphical representation.

Uploaded by

Preethi Victor
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

1.

CREATE MATRIX AND PERFORM MATRIX OPERATIONS

PROGRAM :
A=matrix(c(1:9),nrow=3,byrow=TRUE)
B=matrix(c(1,3,4,5,6,7,8,9,1),nrow=3,byrow=TRUE)
print(A+B)
print(A-B)
print(A%*%B)
print(A/B)
print(A%%B)
2. GRAPHICAL DISPLAY OF POISSON DISTRIBUTION

PROGRAM :
# Set the seed for reproducibility
set.seed(123)
# Generate a poisson-distributed dataset
larbda <- 5 # Average rate of events
poisson_data <- rpois(100, larbda)
# Create a bar plot to visualize the probability mass function
barplot(table(poisson_data)/length(poisson_data),
col = "Skyblue",
main = "Poisson Distribution PMF",
xlab = "Number of Events",
ylab = "Probaility",
ylim = c(0,0.15))
#Add a red line reoresention the theoretical poisson PMF
3. HISTOGRAM

PROGRAM :
marks<-c(0,10,20,30,40,50,60)
num_students<-c(60,50,70,40,80,30)
hist(marks,breaks=seq(0,50,y=10),weights=num_students,xlab
="marks",ylab="Number of students", main + "Histogram of
marks")
4. PIE – CHART

PROGRAM :
# Data
Categories <- C("Agriculcure and rural development",
"Irrigation", "Energy","Transport and communication", "Social
service", "Industry")
Percentages <- C(12.9, 12.5, 27.2, 15.4, 16.1)

#Create pie chart


Pie(Percentages, tales = Categories, main = "Expenditure
Distribution")

You might also like