-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
134 lines (91 loc) · 4.69 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# MedLEA <img src="hexsticker/sticker.png" align="right" height="200"/>
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/MedLEA)](https://CRAN.R-project.org/package=MedLEA)
[![Downloads](http://cranlogs.r-pkg.org/badges/MedLEA)](https://cran.r-project.org/package=MedLEA)
<!-- badges: start -->
<!-- badges: end -->
The MedLEA package provides morphological and structural features of 471 medicinal plant leaves and 1099 leaf images of 31 species and 29-45 images per species.
## Installation
You could install the stable version on CRAN:
```r
install.packages("MedLEA")
```
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("SMART-Research/MedLEA")
```
## Visual representation of description of variables in the dataset
![](https://github.com/SMART-Research/MedLEA/blob/main/Leaf_image/img1.png)
![](https://github.com/SMART-Research/MedLEA/blob/main/Leaf_image/lf_sh.png)
![](https://github.com/SMART-Research/MedLEA/blob/main/Leaf_image/mr.png)
![](https://github.com/SMART-Research/MedLEA/blob/main/Leaf_image/simple_leaf_parts.png)
## Example
```{r example1}
library(MedLEA)
data("medlea")
head(medlea)
```
## Wordcloud of Family of the Medicinal Plants
```{r example3, warning=FALSE, message=FALSE}
library(ggplot2)
library(wordcloud2)
library(magrittr)
library(patchwork)
library(dplyr)
library(tm)
#unique(medlea$Family_Name)
text1 <- medlea$Family_Name
docs <- Corpus(VectorSource(text1))
docs <- docs%>% tm_map(stripWhitespace)
dtm <- TermDocumentMatrix(docs)
matrix <- as.matrix(dtm)
words <- sort(rowSums(matrix), decreasing = TRUE)
df <- data.frame(word = names(words), freq = words)
p1 <- wordcloud2(data = df, size = 0.9,color = 'random-dark', shape = 'pentagon')
p1
```
```{r example6, warning=FALSE, message=FALSE, echo=FALSE, eval=FALSE}
d11 <- as.data.frame(table(medlea$Arrangements))
names(d11) <- c('Arrangements_of_the_leaf', 'No_of_leaves')
d11 <- d11 %>% mutate(Percentage = round(No_of_leaves*100/sum(No_of_leaves),2))
ggplot(d11, aes(x= reorder(Arrangements_of_the_leaf, Percentage), y=Percentage)) + labs(y="Percentage", x="Arrangements of the leaf") + geom_bar(stat = "identity", width = 0.3) + ggtitle("Composition of sample by the Leaf Arrangement")+ geom_label(aes(label = paste0(Percentage, "%")), nudge_y = -6, size = 4, label.padding = unit(0.175,"lines")) + coord_flip()
```
## Composition of the Sample by Shape and Edge Type of Leaves
```{r example2, warning=FALSE, message=FALSE}
medlea <- filter(medlea, Arrangements == "Simple")
d11 <- as.data.frame(table(medlea$Shape))
names(d11) <- c('Shape_of_the_leaf', 'No_of_leaves')
p2 <- ggplot(d11, aes(x= reorder(Shape_of_the_leaf, No_of_leaves), y=No_of_leaves)) + labs(y="Number of leaves", x="Shape of the leaf") + geom_bar(stat = "identity", width = 0.6) + ggtitle("Composition of the Sample by the Shape Label") + coord_flip()
```
```{r example5, warning=FALSE, message=FALSE}
d11 <- as.data.frame(table(medlea$Edges))
names(d11) <- c('Edges', 'No_of_leaves')
#d11 <- d11 %>% mutate(Percentage = round(No_of_leaves*100/sum(No_of_leaves),0))
#ggplot(d11, aes(x= reorder(Shape_of_the_leaf, Percentage), y=Percentage)) + labs(y="Percentage", x="Shape of the leaf") + geom_bar(stat = "identity", width = 0.5) + geom_label(aes(label = paste0(Percentage, "%")), nudge_y = -3, size = 3.25, label.padding = unit(0.175,"lines")) + ggtitle("Composition of the Sample by the Shape Label") + coord_flip()
p3 <- ggplot(d11, aes(x= reorder(Edges, No_of_leaves), y=No_of_leaves)) + labs(y="Number of leaves", x="Edge type of the leaf") + geom_bar(stat = "identity", width = 0.6) + ggtitle("Composition of the Sample by the Edge Type") + coord_flip()
p2 + p3 + plot_layout(ncol = 1)
```
## Composition of the Sample by Shape and Edge type of Leaves in Simple Arrangement
```{r example4, warning=FALSE, message=FALSE}
medlea <- filter(medlea, Shape != "Scale-like shaped")
d29 <- as.data.frame(table(medlea$Shape,medlea$Edges))
names(d29) <- c('Shape','Edges','No_of_leaves')
d29$Edges <- factor(d29$Edges, levels = c("Smooth", "Toothed","Lobed","Crenate"))
ggplot(d29, aes(fill = Edges, x=Shape , y=No_of_leaves)) + labs(y="Number of leaves", x="Shape of the leaf") + geom_bar(stat = "identity", width = 0.5, position = position_dodge()) + coord_flip() + ggtitle("Composition of the sample by Shape Label and Edge type") + scale_fill_brewer(palette = "Set1")
```
## Load Medicinal Plant Images
```{r, comment=NA}
load_images()
```