Wednesday, January 18, 2023

Basic Graphs in R

 

1. Histogram

x<-rnorm(50)

hist(x) # plot the histogram of those values.

2. Modification Histogram

hist (x,main="Hello histogram!!!",col="red")

3. Scatter plot

y<-rnorm(50)

#plot a scatter plot

# Control x-axis and y-axis labels

plot (x,y,main="scatterplot of random samples",

     ylab="y values",xlab="x values")





4. Box plot

boxplot (x,y, main="boxplots of random samples")


5. Bar Plot

barplot(height=perc,

        names.arg=c("CpGi","exon","CpGi","exon"),

        ylab="percentages",main="imagine %s",

        col=c("red","red","blue","blue"))

legend("topright",legend=c("test","control"),

       fill=c("red","blue"))



6. Combine different plots on one page

par(mfrow=c(1,2)) # 

# make the plots
hist(x,main="Hello histogram!!!",col="red")
plot(x,y,main="scatterplot",
        ylab="y values",xlab="x values")





No comments:

Post a Comment