From 8e0733d03e93ccaae15324cfc978ba378393ad99 Mon Sep 17 00:00:00 2001 From: Taha Ahmed Date: Sun, 20 Mar 2011 22:39:58 +0100 Subject: [PATCH] Added function LinearBaseline(). --- common.R | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/common.R b/common.R index c5288b9..00f106b 100644 --- a/common.R +++ b/common.R @@ -3,6 +3,7 @@ # Taha Ahmed, Jan 2011 # CONTENTS +# >>>> LinearBaseline # >>>> int2padstr # >>>> It2charge # >>>> ProvideSampleId @@ -15,6 +16,33 @@ +################################################## +################ LinearBaseline ################## +################################################## +LinearBaseline <- function (potential, current, iplim) { + ## Arguments: + ## potential: full half-cycle, potentials + ## current: full half-cycle, currents + ## iplim: interpolation limits along x (potential) + ## Value: + ## A dataframe with two columns, potential and current + ## (of the calculated baseline) + # Construct potential-current dataframe + sweep <- data.frame(potential = potential, current = current) + # + sweep.iplim <- subset(subset(sweep, potential > iplim[1]), potential < iplim[2]) + sweep.baseline <- data.frame(potential = approxExtrap(sweep.iplim$potential, + sweep.iplim$current, xout = sweep$potential, method = "linear")$x, + current = approxExtrap(sweep.iplim$potential, sweep.iplim$current, + xout = sweep$potential, method = "linear")$y) + sweep.data <- data.frame(potential = sweep.baseline$potential, + current = sweep.baseline$current) + return(sweep.data) +} + + + + ################################################## ################## int2padstr #################### ##################################################