-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Notas de clase y funciones nuevas * work on #3 * work on #3 * For #4 * Notas para #4 * Notas de clase CORRECTO #4 * para el issue #3
- Loading branch information
1 parent
dbf92fe
commit 8cbf6e9
Showing
8 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
colores_primarios <- tribble( | ||
~color_name, ~R, ~G, ~B, | ||
"Black" ,0,0,0, | ||
"White" ,255,255,255, | ||
"Red" ,255,0,0, | ||
"Lime" ,0,255,0, | ||
"Blue" ,0,0,255, | ||
"Yellow" ,255,255,0, | ||
"Aqua" ,0,255,255, | ||
"Fuchsia" ,255,0,255, | ||
"Silver" ,192,192,192, | ||
"Gray", 128,128,128, | ||
"Maroon" ,128,0,0, | ||
"Olive" ,128,128,0, | ||
"Green" ,0,128,0, | ||
"Purple" ,128,0,128, | ||
"Teal" ,0,128,128, | ||
"Navy" ,0,0,128 | ||
) %>% | ||
mutate(hex=rgb(R,G,B,maxColorValue = 255)) %>% | ||
mutate(value = hex_to_num(str_sub(hex,2,7)) %>% as.integer()) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
hex_to_num <- function( hex ){ | ||
# Aca falta check de validez del input | ||
paste0("0x", hex) %>% | ||
as.numeric() | ||
} | ||
|
||
to_RGB_df <- function(my_image){ | ||
mis_colores <- my_image %>% | ||
as.raster() %>% | ||
as.matrix() %>% | ||
as.vector() | ||
colores_df <- data.frame( | ||
R = str_sub(mis_colores,2,3), | ||
G = str_sub(mis_colores,4,5), | ||
B = str_sub(mis_colores,6,7) | ||
) | ||
colores_df %>% | ||
mutate( | ||
R=hex_to_num(R), | ||
G=hex_to_num(G), | ||
B=hex_to_num(B) | ||
) | ||
} | ||
|
||
convert_to_RGB_df <- function(filename){ | ||
my_image <- image_read(filename) | ||
mis_colores <- my_image %>% | ||
as.raster() %>% | ||
as.matrix() %>% | ||
as.vector() | ||
colores_df <- data.frame( | ||
R = str_sub(mis_colores,2,3), | ||
G = str_sub(mis_colores,4,5), | ||
B = str_sub(mis_colores,6,7) | ||
) | ||
colores_df %>% | ||
mutate( | ||
R=hex_to_num(R), | ||
G=hex_to_num(G), | ||
B=hex_to_num(B) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
foto_a_dataframe <- function(filename){ | ||
my_image <- image_read(filename) | ||
mis_colores <- my_image %>% | ||
as.raster() %>% | ||
as.matrix() %>% | ||
as.vector() | ||
colores_df <- data.frame( | ||
Red = str_sub(mis_colores,2,3), | ||
Green = str_sub(mis_colores,4,5), | ||
Blue = str_sub(mis_colores,6,7) | ||
) | ||
colores_df %>% | ||
mutate( | ||
R=hex_to_num(Red), | ||
G=hex_to_num(Green), | ||
B=hex_to_num(Blue) | ||
) -> tmp | ||
tmp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library(tidyverse) | ||
library(magick) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "Notas de la clase de 24 de noviembre del 2022" | ||
format: html | ||
editor: visual | ||
--- | ||
|
||
## Cargar todas las funciones de la capeta R | ||
|
||
```{r} | ||
my_files <- dir("R",full.names = TRUE) | ||
for(archivo in my_files){ | ||
source(archivo) | ||
cat("Procesando:", archivo, "\n") | ||
} | ||
``` |