Skip to content

Commit

Permalink
final files
Browse files Browse the repository at this point in the history
  • Loading branch information
aakbarie committed May 14, 2015
1 parent 3ac43e0 commit 66d21fe
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Rproj.user
.Rhistory
.RData
13 changes: 13 additions & 0 deletions Code-for-NZ.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 8
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
41 changes: 41 additions & 0 deletions from wide to long in R.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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")
files <- list.files(pattern=".csv")
files

create_f = function(file)
{
data = as.data.frame(lapply(file, read.csv,header=T))
dim(data)
temp1 = data[,1:24]
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$depth[data_long$depth == meta_data[i,3]] = meta_data[i,2]
}

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$depth[data_long$depth == meta_data[i,3]] = meta_data[i,2]
}


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

}

create_f("Morrill_block_test_75%(2)_voxler.csv")
create_f("Morrill_block_test_75%(1)_voxler.csv")
create_f("Morrill_block_test_known_75%(2)_voxler.csv")
create_f("Morrill_block_test_known_75%(1)_voxler.csv")

0 comments on commit 66d21fe

Please sign in to comment.