Skip to content

Commit

Permalink
Merge pull request #42 from tianshu129/test
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
tianshu129 authored Jul 8, 2020
2 parents d90d214 + da13d9e commit 765c6f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: foqat
Type: Package
Title: Field observation quick analysis tookit
Version: 1.0.1
Version: 1.0.2
Author: Tianshu Chen
Maintainer: Tianshu Chen <[email protected]>
Description: A quick analysis toolkits for atmospheric field observation.
Expand Down
13 changes: 9 additions & 4 deletions R/ofp.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ ofp <- function(df, unit = "ugm", t = 25, p = 101.325, colid = 1){
colnm_df = colnames(df)[2:ncol(df)]
chemicalnames = ifelse(substr(colnm_df, 1, 1) == "X", sub("^.", "", colnm_df), colnm_df)
chemicalnames = gsub("\\.", "-", chemicalnames)
#if i-
chemicalnames = gsub("\\i-", "iso-", chemicalnames)
#build name_df
name_df = data.frame(name = chemicalnames,CAS = NA, Source = NA, Matched_Name = NA, MIR = NA, MW = NA, stringsAsFactors = FALSE)

Expand All @@ -47,6 +49,9 @@ ofp <- function(df, unit = "ugm", t = 25, p = 101.325, colid = 1){
}else if(result_test[2] == "Search Results"){
name_df[i,2]="More than 1 result"
name_df[i,3]=""
}else if(grepl("structure unspecified",result_test[2])){
name_df[i,2]="structure unspecified in NIST"
name_df[i,3]=""
}else{
result_test<-web%>%html_nodes("li")%>%html_text()
result_test<-strsplit(result_test[21], ": ")
Expand All @@ -57,11 +62,11 @@ ofp <- function(df, unit = "ugm", t = 25, p = 101.325, colid = 1){

#match mir by different sources
##by NIST
a=lapply(name_df$CAS[which(name_df$Source=="NIST")], function(i) grep(i, datacas$`CAS`))
a=lapply(name_df$CAS[which(name_df$Source=="NIST"&!is.na(name_df$CAS))], function(i) grep(i, datacas$CAS))
a=unlist(lapply(a,function(x) if(identical(x,integer(0))) ' ' else x))
name_df$MIR[which(name_df$Source=="NIST")] = datacas$New[as.numeric(a)]
name_df$Matched_Name[which(name_df$Source=="NIST")] = datacas$Description[as.numeric(a)]
name_df$MW[which(name_df$Source=="NIST")] = datacas$MWt[as.numeric(a)]
name_df$MIR[which(name_df$Source=="NIST"&!is.na(name_df$CAS))] = datacas$New[as.numeric(a)]
name_df$Matched_Name[which(name_df$Source=="NIST"&!is.na(name_df$CAS))] = datacas$Description[as.numeric(a)]
name_df$MW[which(name_df$Source=="NIST"&!is.na(name_df$CAS))] = datacas$MWt[as.numeric(a)]

for(k in which(name_df$Source=="")){
tarlist=gsub(" ", "", tolower(datacas$Description), fixed = TRUE)
Expand Down

0 comments on commit 765c6f8

Please sign in to comment.