This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str <- "" | |
system.time(for (i in 1:30000000) str == "") | |
system.time(for (i in 1:30000000) nchar(str) == 0) | |
system.time(for (i in 1:30000000) nzchar(str)) | |
str<-rep("", 30000000) | |
system.time(str=="") | |
system.time(nchar(str)==0) | |
system.time(nzchar(str)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 科研検索APIのヘルプ http://kaken.nii.ac.jp/ja/help/#opensearch-form | |
# 課題検索OpenSearchテスト | |
test1 <- readLines("http://kaken.nii.ac.jp/opensearchk.cgi?q15=60273570", encoding="UTF-8") | |
cat(test1, fill=TRUE) | |
# 研究者検索OpenSearchテスト | |
test2 <- readLines('http://kaken.nii.ac.jp/opensearchr.cgi?q1="社会学"', encoding="UTF-8") | |
cat(test2, fill=TRUE) | |
# 課題RDF取得テスト |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(XML) | |
# 社会学者一覧 | |
# 研究種目が社会学の研究者を検索→研究者番号を取得→検索2ページ目以降の研究者の研究者番号をループで所得 | |
# 取得の所要時間は5分程度 | |
search.result <- xmlParse(enc2utf8('http://kaken.nii.ac.jp/opensearchr.cgi?count=200&q1="社会学"')) # 研究者検索 | |
search.result <- xmlToList(search.result) | |
search.result <- rapply(search.result, function(x){iconv(x,"UTF-8","CP932")}, how="replace") | |
entries <- search.result[which(names(search.result)=="entry")] | |
r.names <- sapply(entries, function(x){x$title$text}) # 研究者名 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tc <- setRefClass(Class="testClass", | |
fields = list(f1="numeric", f2="numeric"), | |
representation=representation(x="character") | |
) | |
t1 <- tc$new(f1=4, f2=5, x="a") | |
t2 <- t1 | |
t2@x <- "b" | |
t1 | |
t2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(twitteR) | |
library(ROAuth) | |
requestURL <- "https://api.twitter.com/oauth/request_token" | |
authURL <- "https://api.twitter.com/oauth/authorize" | |
accessURL <- "https://api.twitter.com/oauth/access_token" | |
consumerKey <- "(Consumer key)" | |
consumerSecret <- "(Consumer secret)" | |
twitCred <- OAuthFactory$new(consumerKey=consumerKey, | |
consumerSecret=consumerSecret, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main> | |
<menu name="Data"> | |
<category name="Variable"> | |
<menuitem name="mean">Mean</menuitem> | |
</category> | |
</menu> | |
<menu name="Analysis"> | |
<category name="Descriptive"> | |
<menuitem name="cor">Correlation</menuitem> | |
</category> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<main> | |
<function name="mean" package="base" vesion="2.13.1"> | |
<arg name="x" input="free" type="numeric" requisite="true" /> | |
<arg name="trim" input="free" type="numeric" default="0" /> | |
<arg name="na.rm" input="logical" default="FALSE" /> | |
</function> | |
<function name="cor" package="stats" vesion="2.13.1"> | |
<arg name="x" input="free" type="numeric; matrix; data.frame" requisite="true" /> | |
<arg name="y" input="free" type="NULL; numeric; matrix; data.frame" default="NULL" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
http://sourceforge.jp/projects/hsy-color/wiki/HSY%E8%89%B2%E7%A9%BA%E9%96%93%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6 | |
*/ | |
private int RGBtoHSYtoRGB(int rgb) { | |
float h; | |
float y; | |
float s; | |
float S; | |
float MAX; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RGtk2) | |
win <- gtkWindowNew(show=FALSE) | |
win$add(gtkLabelNew("123abcあいうえお")) | |
win$setSizeRequest(300,300) | |
win$showAll() | |
settings <- gtkSettingsGetDefault() | |
settings$setStringProperty("gtk-font-name", "Hiragino Kaku Gothic Pro 32", NULL) | |
settings$setStringProperty("gtk-font-name", "Hiragino Mincho Pro 32", NULL) | |
settings$setStringProperty("gtk-font-name", "IPAGothic 32", NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f <- function(i){ | |
l <- c("Fizz", "Buzz", "FizzBuzz") | |
ii <- (0==i%%5)*2 + (0==i%%3)*1 | |
print(l[ii]) | |
print(rep(l[ii], 10)[i]) | |
return(ifelse(0<ii, l[ii], i)) | |
} |
OlderNewer