Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Reading in File
- table<- read.csv("C:~table.csv", header = TRUE)
- table[] <- lapply(First33000n, as.character)
- table <- as.data.table(First33000n[,c(2,3,4)])
- #Initializing Tracking Variables
- table[,checked:=0]
- table[,results:=character]
- table[,percentages:=character]
- #Starting Loop over column of table
- for (i in 1:NROW(table)){
- #Writing full chain of operations for first desired output
- txt<-tryCatch(readLines(table[i,websiteURL]), error = function(e) table[i,error:=1]) %>%
- paste(collapse = " ", .) %>%
- gsub(" ", " ", .) %>%
- strsplit("\t") %>% unlist() %>%
- grep("influx pattern", x = ., value = TRUE, ignore.case = TRUE) %>%
- #First desired output
- gsub("^\s?", "", x = .) %>%
- table[i,results:=paste(txtn, collapse = " / ")]
- #Rewriting full chain of operations again for second desired output with different variables
- txt2<-tryCatch(readLines(table[i,websiteURL]), error = function(e) table[i,error:=1]) %>%
- paste(collapse = " ", .) %>%
- gsub(" ", " ", .) %>%
- strsplit("\t") %>% unlist() %>%
- grep("influx pattern", x = ., value = TRUE, ignore.case = TRUE) %>%
- #Second desired output
- str_extract_all(., "\d+(\.\d+){0,1}%") %>%
- table[i,percentages:=paste(txtn2, collapse = " / ")]
- table[i,checked:=1]
- }
- #Reading in File
- table<- read.csv("C:~table.csv", header = TRUE)
- table[] <- lapply(First33000n, as.character)
- table <- as.data.table(First33000n[,c(2,3,4)])
- #Initializing Tracking Variables
- table[,checked:=0]
- table[,results:=character]
- table[,percentages:=character]
- #Starting Loop over column of table
- for (i in 1:NROW(table)){
- #Writing full chain of operations for both desired outputs and naming resultant object ".."
- txt<-tryCatch(readLines(table[i,websiteURL]), error = function(e) table[i,error:=1]) %>%
- paste(collapse = " ", .) %>%
- gsub(" ", " ", .) %>%
- strsplit("\t") %>% unlist() %>%
- grep("influx pattern", x = ., value = TRUE, ignore.case = TRUE) -> ..
- #First operation I want to be done to the newly named object ".."
- gsub("^\s?", "", x = ..) -> a %>%
- table[i,results:=paste(a, collapse = " / ")]
- #Second operation I want to be done to the newly named object ".."
- str_extract_all(.., "\d+(\.\d+){0,1}%") ->b %<>%
- table[i,percentages:=paste(b, collapse = " / ")]
- table[i,checked:=1]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement