Наиболее примитивный метод расчета на заданное число катионов.
Reference | |
---|---|
Input | wtp |
Results | pfu |
elements <- read.csv("constants_elements.csv",stringsAsFactors=F); oxides <- read.csv("constants_oxides.csv",stringsAsFactors=F); recalc.common_cation <- function (wtp_data, count=12, ...) { data <- wtp_data[,grep("_wtp", names(wtp_data))]; mass_factors <- c(); cat_counts <- c(); cat_names <- c(); for (wtname in names(data)) { oxname <- gsub('_wtp', "", wtname); oxconst = subset(oxides,oxide==oxname) catconst = subset(elements,element==oxconst$cation) anconst = subset(elements,element==oxconst$anion) mass_factors <- c(mass_factors, catconst$weight*oxconst$cation_count+anconst$weight*oxconst$anion_count); if (oxconst$cation_count > 0) cat_counts <- c(cat_counts, oxconst$cation_count) else cat_counts <- c(cat_counts, 1); cat_names <- c(cat_names, oxconst$cation); } data <- rowApply('/',data,mass_factors); data <- rowApply('*',data,cat_counts); data_sum_norm <- rowSums(data) / count; data <- data / data_sum_norm; names(data) <- paste0(cat_names,'_pfu'); return(cbind(Name=wtp_data$Name,data)); }