I download data and I made some changes to it and then I'm putting it into an excel file that looks like this, but without the titles called: "Transport" and "Workplaces":
Until now my code looks like this:
rm(list = ls())
setwd("C:/Users/tuv_1/Desktop/Copia CA/Coronavirus")
library(readr)
Basetotal<- read.csv("C:/Users/tuv_1/Desktop/Copia CA/Coronavirus/Global_Mobility_Report.csv")
attach(Basetotal)
library(tidyverse)
Datos<-Basetotal %>% filter(sub_region_1 == "", metro_area == "") %>% pivot_wider(
id_cols = date,
names_from = country_region,
values_from = c(transit_stations_percent_change_from_baseline, workplaces_percent_change_from_baseline))
Datos <- Datos[,c("date","transit_stations_percent_change_from_baseline_Colombia","transit_stations_percent_change_from_baseline_Costa Rica","transit_stations_percent_change_from_baseline_El Salvador","transit_stations_percent_change_from_baseline_Honduras","transit_stations_percent_change_from_baseline_Panama","workplaces_percent_change_from_baseline_Colombia","workplaces_percent_change_from_baseline_Costa Rica","workplaces_percent_change_from_baseline_El Salvador","workplaces_percent_change_from_baseline_Honduras","workplaces_percent_change_from_baseline_Panama")]
colnames(Datos) <- c("Fecha","Colombia","Costa Rica","El Salvador","Honduras","Panamá","Colombia","Costa Rica","El Salvador","Honduras","Panamá")
Datos$Fecha<-as.Date(Datos$Fecha)
library(writexl)
write_xlsx(Datos,"C:/Users/tuv_1/Desktop/Copia CA/Coronavirus/Global Mobility.xlsx")
I don't know how to upload the data into the second row so I can have the subtitles "Transport" and "Workplaces" and also, I don't know how to put those two titles that include every 5 countries. Can someone help me? As you can see, I'm just a beginner. Thanks!