Skip to content

Instantly share code, notes, and snippets.

@geofis
Created February 28, 2019 13:09
Show Gist options
  • Save geofis/74748e22e161d9c71210641d95615fd5 to your computer and use it in GitHub Desktop.
Save geofis/74748e22e161d9c71210641d95615fd5 to your computer and use it in GitHub Desktop.
Bind CSV files of river particle axes length into a single one
#Working directory
wd <- '/home/jr/Documentos/clases_UASD/sem201901/datos_campo/'
alumnas <- list.dirs(wd, full.names = F, recursive = F)
csvfiles <- sapply(
alumnas,
function(x){
fuente <- list.files(
paste0(
wd,
x
),
full.names = T,
pattern = '*.csv'
)
fuente <- grep('gnumeric', fuente, invert = T, value = T)
csvfile <- read.csv(fuente, check.names = F, stringsAsFactors = F)
return(csvfile)
},
simplify = F
)
csvfiles <- bind_rows(
csvfiles,
.id = 'alumna'
)
csvfiles
csvfiles$`tipo de roca` <- tolower(csvfiles$`tipo de roca`)
csvfiles$`unidad geomorfológica` <- tolower(csvfiles$`unidad geomorfológica`)
csvfiles$lugar <- gsub('los pilones', 'Los Pilones', csvfiles$lugar)
csvfiles$lugar <- gsub('Las carreras', 'Las Carreras', csvfiles$lugar)
csvfiles$responsables <- gsub('ANA', 'Ana', csvfiles$responsables)
write.csv(
csvfiles,
paste0(
wd,
'joined_csv_files.csv'
),
row.names = F
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment