R R.scripts !!!co2list CHATファイル内の分析コード(%co2: )の抽出 {{pre co2list <- function() { token.all <- "" files <- list.files() for (i in files) { token <- "" lines.tmp <- scan(i, what="char", sep="\n") body.tmp <- grep("^%co2", lines.tmp, value=T) body.tmp2 <- gsub("%co2:\t", "", body.tmp) body.tmp2 <- gsub("\\s+", " ", body.tmp2) #複数のペースを一つに token.all <- c(token.all, body.tmp2) } code.list <- sort(token.all) code.list <- code.list[code.list != ""] as.data.frame(code.list) } }}