Pirate plot: Advanced data visulisation using R , RID plot
HTML-код
- Опубликовано: 21 авг 2024
- #RID #datavisualization #rprogramming #pirateplot
In this video, i demonstrated use of pirate plot to as an advanced alternative to a barplot.
pirate plot is from Nathaniel Philips' "Yarrr" package. It shows raw data as points with adjusted opacity, data distribution as violin plots like beans, inference like 95% Ci as a rectangular inference box and descriptive statistics like mean or median as a conspicuous bar. All the required elements of an honest plot. All these elements discussed above can be customised for all the visual attributes.
Also this is a base R plot. It can be customised using base R plot functions.
install.packages("yarrr")
library(yarrr)
str(iris)
pirateplot(Sepal.Length~Species, iris,theme = 4)
text(1, 7.5, label=" Pirate plot shows RID")
?pirateplot
citation("yarrr")
library(tidyr)
library(dplyr)
iris_long = pivot_longer(iris, 1:4,names_to = "flowerpart", values_to = "len")
pirateplot(len~Species+flowerpart,iris_long)
Facebook page:
/ rajendrachoureisc
Mail Id:
rajuchoure@gmail.com
youtube playlist:
• R programming tutorials
Thanks
Thanks a lot for this appreciation. It helps a lot.
Ohhh, thanks for the video, was interesting.
Glad you enjoyed it!
Is it same as violin plot including boxplot???
No violin plot shows local density and boxplots shows quantities. Raw data is not showed. If we overlay raw data as points, then this becomes overplotting.
Pirate plot dp not show quantiles, it shiw median or mean and 95%CI. Local distribution using beans , jittered points are for raw data. Overplotting is avoided by not displaying quantiles.
sir, can u please tell how did you arranged your data for pirate plot, like what are the variables you have taken, just 5 or any other variables you have taken to draw a pirate plot
If you share head(data) or data to Rajuchoure@gmail.com, i may help you.
Hi sir, how to demonstrate a pirate plot for multiple (In X-Axist are Grade+Gender, Y-Axis is a cognitive aspect). What is the syntax?
pirateplot(cognitive~Grade+Gender, Data)
Sir, how to make a pirate plot from SPSS data? tell me. Thanks
# download data form
lo.unisa.edu.au/pluginfile.php/1020313/mod_book/chapter/106604/HLTH1025_2016.sav
# save daat in your working directory and set working directory
#use following code to get pirate plot
setwd("G:\\Rworks\\Spss data import")
library(foreign)
df
hello sir can you please tell me how can we add a secondary axis in the existing plot?
# I got this solution from r-graph-gallery.com/line-chart-dual-Y-axis-ggplot2.html
library(ggplot2)
data
@@DevResearch thank you sir
@@DevResearch it can be done in pirate plot also??
Thanks. How to make the plot shown in the time stamp 1:11
It is pirate plot with multiple subcategories in a categorical variable. Basically one numeric variable and two categorical variables are plotted using following syntax
pirateplot(num_var~ cat1+cat2, data)
The plot at 1.11 is using long table of iris data.
liibrary(tidyr)
iris_long= pivot_longer(iris, cols=1:4, names_to="flowerpart",values_to="len")
library(yarrr)
pirateplot(len~Species+flowerpart, iris_long)
@@DevResearch Thank you for the code. However, I am a newbie to wrap my head around this code :( Are we trying to pivot the data , what is the need of the package tidyr?
If possible, please plan a video on this. Finally I see I have come to channel where I see R is taught in a very straightforward way..
i have arranged my data according to iris where i am having one character and 3 variables but i am not getting bean and interference i am just getting raw data in the plot, can u pls help me in arranging data sir.
Studied data shared by you. It doesn't have replicate data in treatment-DAS combinations. Pirate plot is not possible.
@@DevResearch sir i have done plotting by adding replicati0ns till i cant get the beans and interference for the code, please, suggest a code for 2 characters and one variable. I have already emailed you back with the edited replicated data. Kndly, have a look sir.