Category Archives: MEG-DM 2013 Winter

Module “Data Management”, winter term 2013.

MEG- DM- L09

setwd (“C:/R”)

insert.row <- function(input.data.frame, row.line, row.content) { input.data.frame[(row.line+1):(nrow(input.data.frame)+1), ] <- input.data.frame[row.line:nrow(input.data.frame),] input.data.frame[row.line, ] <- row.content return(input.data.frame)}

S <- read.table(csv_example_in.csv,sep=”,”,header=TRUE,new.data.frame input.data.frame<- S[,c(1,2,4,9)],  as.POSIXct(strptime(“2013-01-01 00:26:00″, “%Y-%m-%d %H:%M:%S”))

row.line <- 3 row.content <- list(“2000-01-01 01:46:00″, “eat”, “fer0″, -10.5) new.data.frame <- insert.row(S[,c(1:2,4,9)], 3, row.content)

all.col.names <- colnames(S) colnames(my.data.frame)[1] <- “Datetime” colnames(my.data.frame)[2] <- “Timedifference” colnames(my.data.frame)[3] <- “Timezone” colnames(my.data.frame)[4] <- “PlotId” colnames(my.data.frame)[5] <- “B_01″

write.table(new.data.frame, “csv_exmaple_out_function.csv”, col.names=TRUE, sep=”\t”, quote=TRUE, dec=”,”)