dirName="univ"
files <- list.files(dirName)
filesDir <- unlist(lapply(dirName, paste, files, sep = "/"))
filesDir
## [1] "univ/hiroshima.txt" "univ/kufs.txt" "univ/kyoto.txt"
## [4] "univ/osaka1.txt" "univ/osaka2.txt" "univ/osaka3.txt"
## [7] "univ/tokyo.txt" "univ/waseda.txt"
filename <- filesDir[1]
txt<-scan(filename, what="")
scan(filename, what="", sep = "\n")
## [1] "Hiroshima University aims to be a world-class hub of education and research, to foster excellent human resources to contribute to the community, and developmentally expand science."
## [2] "The main campus, covering 252 hectares, is located in Higashi-Hiroshima (Saijo), in a verdant area which is famous for sake brewing. Including campuses in Hiroshima, known as the International City of Peace and Culture, the University includes 11 faculties, 12 graduate schools, a research institute, a university hospital, and 11 attached schools."
## [3] "Hiroshima University's mission of ongoing growth, as based on the five principles, is to create new forms of knowledge, nurture well-rounded human beings, continue self-development, pursue international peace, and collaborate with the local, regional, and international community."
## [4] "I'd like to welcome your questions and comments; please feel free to send them to the President's Office. Though it might not be possible for me to provide feedback for every question, I'd certainly be happy to direct them to university operations, etc. Thank you in advance for your continued support of Hiroshima University. "
grep("univ",txt, ignore.case = T)
## [1] 2 62 73 80 156 169
grep("univ",txt, ignore.case = T, value=T)
## [1] "University" "University" "university" "University's"
## [5] "university" "University."
grep("ed$",txt, ignore.case = T, value=T)
## [1] "located" "attached" "based" "well-rounded"
## [5] "continued"
node <- "univ"
nodeLst <- grep(node,txt, ignore.case = T, value=T)
nodeIndex <- grep(node,txt, ignore.case = T)
Left1 <- txt[nodeIndex-1]
Left2 <- txt[nodeIndex-2]
Right1 <- txt[nodeIndex+1]
Right2 <- txt[nodeIndex+2]
collo <- cbind(Left2,Left1,nodeLst, Right1, Right2)
## Warning in cbind(Left2, Left1, nodeLst, Right1, Right2): number of rows of
## result is not a multiple of vector length (arg 1)
colnames(collo) <- c("L2","L1","node","R1","R2")
rownames(collo) <- rep(1:dim(collo)[1])
collo
## L2 L1 node R1 R2
## 1 "Culture," "Hiroshima" "University" "aims" "to"
## 2 "institute," "the" "University" "includes" "11"
## 3 "schools." "a" "university" "hospital," "and"
## 4 "them" "Hiroshima" "University's" "mission" "of"
## 5 "of" "to" "university" "operations," "etc."
## 6 "Culture," "Hiroshima" "University." NA NA
library(shiny)
runApp("shiny_apps/app_collocation1")
filenames <- c(filesDir[1],filesDir[8])
txt<-unlist(lapply(filenames, scan, what=""))
runApp("shiny_apps/app_collocation2")
install.packages('twitteR')
install.packages('ROAuth')
library(twitteR)
library(ROAuth)
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
consr_key="***********"
consr_secrt="***********"
req_url ="https://api.twitter.com/oauth/request_token"
acs_url = "https://api.twitter.com/oauth/access_token"
auth_url="https://api.twitter.com/oauth/authorize"
cred<-OAuthFactory$new(consumerKey=consr_key,consumerSecret=consr_secrt,requestURL =req_url,accessURL = acs_url,authURL=auth_url)
cred$handshake(cainfo="cacert.pem")
setup_twitter_oauth(consr_key, consr_secrt, acs_token, acs_token_sec)
searchTwitter("#DH2017", n=10)
searchTwitter("#成人式", n=10)
username = "casualconc"
userTimeline(username)
username = "lctabata"
userTimeline(username)
username = "langstat"
userTimeline(username)
runApp("shiny_apps/app_twitteR")