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

Rajendra Choure
Rajendra Choure
38.9 هزار بار بازدید - 3 سال پیش - #ggplot2
#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:
Facebook: RajendraChoureISC

Mail Id:
[email protected]

youtube playlist:
R programming tutorials

#Code used in this tutorial ( You can copy-paste 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~x-1,se=0)+
 geom_smooth(aes(y=rep2),method="lm",formula=y~x-1,se=0,color="red")+
 geom_smooth(aes(y=rep3),method="lm",formula=y~x-1,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~x-1,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~x-1,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")
3 سال پیش در تاریخ 1400/11/09 منتشر شده است.
38,977 بـار بازدید شده
... بیشتر