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 #################### ##################################################