\[RECONOCIMIENTO~ OPTICO~ DE~ CARACTERES\]
#install.packages()
library(dplyr)
library(magick)
library(tesseract)
library(tidyverse)
Pasos para convertir una imagen tipo tabla en un data frame.
df <- "https://i.stack.imgur.com/V9lWV.png" %>%
image_read() %>%
image_resize('2000x') %>%
image_convert(type = 'Grayscale') %>%
image_trim(fuzz = 40) %>%
image_write(format = 'png', density = '300x300') %>%
tesseract::ocr() %>%
strsplit('\n') %>%
getElement(1) %>%
`[`(-1) %>%
{sub('Time 2', 'Time_2', .)} %>%
{read.table(text = .)} %>%
setNames(c('Time_factor', 'Tree #', 'Species', 'Fragment',
'Linear Extension(mm)', 'Colour'))
Tabla
library(DT)
datatable(df)
df$Time_factor <- as.factor(df$Time_factor)
Hacemos una grafica con el data frame obtenido
library(ggplot2)
ggplot(df, aes(x=Time_factor , y=`Linear Extension(mm)`, fill=Colour)) +
geom_col() +
scale_fill_manual(values = c("blue ","brown","yellow")) +
theme_light() +
labs(title="Linear Extension in to Times")