This is my first time posting a question here and I'm kinda a newbie in R. So forgive me my errors posting it here.
Basicaly I have multiple excel files with meteorological data that is organized like this:
C1_Maio.csv OBS: I have the files C1_Maio, C1_Junho, C1_Julho (names in portuguese = May, June and July)
The all the files contains three different temperatures measurements and one for humidity (C1_Maio -> T1, T2, T3 and H)
I have 4 other excel files C2_Maio; C3_Maio; C4_Maio; C5_Maio following the same logic.
I'm trying to join all these files in sequence like this:2
So, to summarize, I need to join all C1_Maio, C1_Junho and C1_Julho in one continuous excel file. I tried to write a code (again a newbie here) and I don't know what im missing... When I merge them something is going on that it is messing with the data inside the csv file. Here is the code bellow with the descriptions:
# Packages
#install.packages(openxlsx)
#install.packages(tidyverse)
# Libraries
library("openxlsx")
library("tidyverse")
# Insertion of data from the Maio de Cadiretas sensors
C_1_Maio <- read.csv("D:/Carreira Acadêmica/Doutorado - UB/Projetos/HoliSoils/Areas de Estudo/Cadiretes/Dados/Sensores/2022-05-11/C-1.csv", header = FALSE, sep = ";")
# Insertion of data from the Junho de Cadiretas sensors
C_1_Junho <- read.csv("D:/Carreira Acadêmica/Doutorado - UB/Projetos/HoliSoils/Areas de Estudo/Cadiretes/Dados/Sensores/2022-06-29/C-1.csv", header = FALSE, sep = ";")
# Joining dataframes from different Cadiretas dates
C1_cad <- rbind(C_1_Maio, C_1_Junho)
#Here I need to find a way to join these two excel files based on datetime column. That is, these two files have a column that R calls it V2 that has the following format: 2021.07.02 07:45
#In this way, it would specify that where the observations of the May file end, those of June will begin.
#The problem is that these files are automatically generated by a program, so in the June file there may be observations that were measured in May, and it seems to me that due to errors in the program the measurements may be different. As in the following generic example:
#EX:
# A B C D E F G H I
#C1_Maio: 14 2021.07.02 11:00 4 23,1875 23,375 23,1875 461 202 0
#C1_Junho: 50 2021.07.02 11:00 4 24,7500 22,375 22,1975 461 202 0
#In short, I needed the data to follow the order established by the date and time of observation and if there are duplicate data for the same date and time, they should appear repeated without one replacing the other.
# Extracting the joined data to Excel in separate columns Cadiretes
cad_T1_C1 <- C1_cad[, c("V2","V4"), drop = FALSE]
cad_T2_C1 <- C1_cad[, c("V2","V5"), drop = FALSE]
cad_T3_C1 <- C1_cad[, c("V2","V6"), drop = FALSE]
cad_H_C1 <- C1_cad[, c("V2","V7"), drop = FALSE]
C1_TM_Cadiretes <- list('T1' = cad_T1_C1, 'T2' = cad_T2_C1, 'T3' = cad_T3_C1, 'Moisture' = cad_H_C1)
write.xlsx(C1_TM_Cadiretes,"C:\\Users\\Lenovo\\Desktop\\Holisoils data\\C1_TM_Cadiretes.xlsx")
# In this way what you would need is the Excel file generated to contain the data of "T1", "T2", "T3" and "Humidity" in separate sheets in the same CSV or Excel file