It was never so easy to get YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

Learn to plot Data Using R and GGplot2: Import manipulate graph and customize the plot graph

Follow
Rajendra Choure

#ggplot2 #rprogramming #datavisulisation #tidyr #dplyr

In this video i explained the procedure to get publication ready plot.
Data import, data frame, how to understand the data in data frame, how to plot basic ggplot( scatter plot as example). how to add smooth line, adding labels title, subtitle, caption, axis label, getting long table using pivot longer function, summarizing data using dplyr function summarize and gather, how to modify the code to get different plot types like boxplot, violin pot have been explained.


Facebook page:
  / rajendrachoureisc  

Mail Id:
[email protected]

youtube playlist:
   • R programming tutorials  

#Code used in this tutorial ( You can copypaste from this downward.)
data file link : https://drive.google.com/file/d/1JPJu...

setwd("D:/Rworks/datatoplot") # Change working directory to directory where your data file is saved
getwd()

df = read.csv("polyphenolassay.csv")

df

summary(df)
str(df)

plot(df)

install.packages("ggplot2")

library(ggplot2)

ggplot(df, aes(conc,rep1))+
geom_point()+
geom_point(aes(y=rep2),color="red")+
geom_point(aes(y=rep3),color="green")+
geom_smooth(method="lm",formula=y~x1,se=0)+
geom_smooth(aes(y=rep2),method="lm",formula=y~x1,se=0,color="red")+
geom_smooth(aes(y=rep3),method="lm",formula=y~x1,se=0,color="green")+
theme_classic()+
labs(title="Estimation of Polyphenol Content",subtitle="Folin Dennis Method",caption="Exepriment conducted as biochemistry lab",
x="Concentration of polyphenol in mcg/ml",y="OD795nm")

install.packages("tidyr")

library(tidyr)

df_long= pivot_longer(df,cols=2:4,names_to = "rep",values_to = "OD795")

df_long
str(df_long)

ggplot(df_long, aes(conc,OD795,color= rep))+
geom_point()+
geom_smooth(method="lm",formula=y~x1,se=0)+
theme_classic()+
labs(title="Estimation of Polyphenol Content",subtitle="Folin Dennis Method",caption="Exepriment conducted as biochemistry lab",
x="Concentration of polyphenol in mcg/ml",y="OD795nm")

install.packages("dplyr")

library(dplyr)

I have removed the pipes as angled brackets are not allowed in description
df_summary= group_by(df, conc)
df_summary= summarise(df_summary, mean_OD795=mean(OD795))

ggplot(df_summary, aes(conc,mean_OD795))+
geom_point()+
geom_smooth(method="lm",formula=y~x1,se=0)+
theme_classic()+
labs(title="Estimation of Polyphenol Content",subtitle="Folin Dennis Method",caption="Exepriment conducted as biochemistry lab",
x="Concentration of polyphenol in mcg/ml",y="OD795nm")

ggplot(df_long, aes(rep,OD795,color= rep))+
geom_boxplot()+
theme_classic()+
labs(title="Estimation of Polyphenol Content",subtitle="Folin Dennis Method",caption="Exepriment conducted as biochemistry lab",
x="Concentration of polyphenol in mcg/ml",y="OD795nm")

ggplot(df_long, aes(rep,OD795,color= rep))+
geom_violin()+
geom_jitter()+
theme_classic()+
labs(title="Estimation of Polyphenol Content",subtitle="Folin Dennis Method",caption="Exepriment conducted as biochemistry lab",
x="Concentration of polyphenol in mcg/ml",y="OD795nm")

posted by zuklopfens2