Skip to content

Commit

Permalink
Fixed problems
Browse files Browse the repository at this point in the history
  • Loading branch information
aakbarie committed May 22, 2015
1 parent 0334418 commit ab2d1f0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions from wide to long in R for NZ.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
library(tidyr)

meta_data = read.csv("C:\\Users\\Akbar Akbari Esfahan\\Google Drive\\Mikes\\Code-for-NZ\\layer_depth.csv",header=T)
setwd("C:\\Users\\Akbar Akbari Esfahan\\Google Drive\\Mikes\\Code-for-NZ")
meta_data = read.csv("C:\\Users\\Akbar Akbari Esfahan\\Google Drive\\Mikes\\Code-for-NZ\\Wide-to-Long-NZ\\layer_depth.csv",header=T)
setwd("C:\\Users\\Akbar Akbari Esfahan\\Google Drive\\Mikes\\Code-for-NZ\\Wide-to-Long-NZ")
files <- list.files(pattern=".csv")
files

Expand All @@ -10,31 +10,31 @@ create_f = function(file)
data = as.data.frame(lapply(file, read.csv,header=T))
dim(data)
temp1 = data[,1:24]
temp2 = meta_data[1:21,]
data_long <- gather(temp1, depth, resistivity, res1:res21)
data_long$depth = as.character(data_long$depth)

for(i in 1:length(meta_data[,1]))
{
data_long$Layer[data_long$depth == meta_data[i,3]] = meta_data[i,1]
data_long$Thick[data_long$depth == meta_data[i,3]] = meta_data[i,2]
data_long$depth[i]=data_long$DEM[i] - data_long$Thick[i]
data_long$Layer[data_long$depth == temp2[i,1]] = temp2[i,2]
data_long$Thick[data_long$depth == temp2[i,1]] = temp2[i,3]
data_long$cumThick[data_long$depth == temp2[i,1]] = temp2[i,4]
}
data_long$depth = data_long$DEM - data_long$cumThick
write.csv(data_long,paste(file,"_short.csv",sep=""),row.names=F)

write.csv(data_long,paste(file,"_short.csv"),row.names=F)
#For all res values
data_long <- gather(data, depth, resistivity, res1:res24)
data_long$depth = as.character(data_long$depth)

for(i in 1:length(meta_data[,1]))
{
data_long$Layer[data_long$depth == meta_data[i,3]] = meta_data[i,1]
data_long$Thick[data_long$depth == meta_data[i,3]] = meta_data[i,2]
data_long$depth[i]=data_long$DEM[i] - data_long$Thick[i]
data_long$Layer[data_long$depth == meta_data[i,1]] = meta_data[i,2]
data_long$Thick[data_long$depth == meta_data[i,1]] = meta_data[i,3]
data_long$cumThick[data_long$depth == meta_data[i,1]] = meta_data[i,4]
}


write.csv(data_long,paste(file,"_long.csv"),row.names=F)

data_long$depth = data_long$DEM - data_long$cumThick
write.csv(data_long,paste(file,"_long.csv",sep=""),row.names=F)
}

create_f("Morrill_block_test_75%(2)_voxler.csv")
Expand Down

0 comments on commit ab2d1f0

Please sign in to comment.