From 26ff706e5b8c248f5e7527b3277b64c3a6bdd6c6 Mon Sep 17 00:00:00 2001 From: Olivia <92395083+OliviaLorente-Casalini@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:09:49 +0200 Subject: [PATCH] final --- scripts_texto_nota.R | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts_texto_nota.R b/scripts_texto_nota.R index 3067c4a..7d8efed 100644 --- a/scripts_texto_nota.R +++ b/scripts_texto_nota.R @@ -3,12 +3,20 @@ library(palmerpenguins) library(tidyverse) +# exportar como csv ------------------------------------------------------- +# tidyverse +write_csv(penguins, "penguins1.csv") + +# R base +write.csv(penguins, "penguins2.csv") + + # readr ------------------------------------------------------------------- # leer archivos -penguins_tb <- read_csv("penguins.csv") +penguins_tb <- read_csv("penguins1.csv") # R base -penguins_df <- read.csv("penguins.csv") +penguins_df <- read.csv("penguins2.csv") # tibble ------------------------------------------------------------------ @@ -133,7 +141,7 @@ lapply(X = levels(penguins_df_mean_long_str_for$species), # pipe ------------------------------------------------------------------- # grafica de tendencia media anual de masa corporal para cada especie -plot_mass_island <- read_csv("penguins.csv") |> +plot_mass_island <- read_csv("penguins1.csv") |> group_by(year, species) |> summarise(body_mass_g = mean(body_mass_g, na.rm = TRUE)) |> ggplot(aes(x = year, y = body_mass_g, col = species)) + @@ -144,7 +152,7 @@ plot_mass_island <- read_csv("penguins.csv") |> plot_mass_island # R base -penguins_df <- read.csv("penguins.csv") +penguins_df <- read.csv("penguins2.csv") aggregated_data <- aggregate(body_mass_g ~ year + species, data = penguins, FUN = function(x) mean(x, na.rm = TRUE))