R_old_tips3 - アールメカブ

アールメカブ


R_old_tips3

R_old_tips2

Rサーチ

R関係のスライドやビデオ

# $ fc-list : family
# $ xlsfonts -fn -ipamona-gothic-*-*-*-*-*-*-*-*-*-*-*-*

 grDevices::X11.options(
   fonts=c("-ipamona-gothic-*-*-*-*-*-*-*-*-*-*-*-*", ## "-kochi-gothic-%s-%s-*-*-%d-*-*-*-*-*-*-*",
                       "-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*"))
  grDevices::pdf.options(family="Japan1GothicBBB")
  grDevices::ps.options(family="Japan1GothicBBB")

_ 自作パッケージ

  • RMeCabパッケージ データ解析・グラフィックス環境 R から日本語形態素解析ソフト和布蕪( MeCab )を呼び出して使うインターフェイス
    • R2MeCabRMeCabのサブセット.実装関数は三つだけです.
  • RCaBoChaパッケージ データ解析・グラフィックス環境 R から日本語係り受け判定ソフト南瓜( CaBoCha )を呼び出して使うインターフェイス

_ Rを最新版にした結果、RExcel が起動しなくなった場合

R を管理者権限で実行し

  1.  R のメニュー パッケージ を使って Rcmdr をインストール
  2.  R のメニュー パッケージ を使って RExcelInstaller? をインストール
  3. library(RExcelInstaller?) を実行
  4. installRExcel() を実行する
  5. Setup ウイザードの指示に従って next, install をクリックしていく
  6. 念のため RExcel を管理者権限で実行

以上です

RExcel を含め、古いRにインストールしていたパッケージをすべて新しい環境に移したい場合は

http://sunsite.univie.ac.at/rcom/  トップメニュー Wiki -> 左フレーム How to upgrade R with our packages installed

その他,中澤先生のサイトも参照ください

_ RExcel

_ R の参考書

  • :R でコーパス・テキスト・言語処理を行うための入門書ですが,第3章にRの包括的な入門があります.
  • 中級者になるために.
  • 解析をばりばり行うために.
  • データをばりばり処理するために.
  • R のプログラミングテクニックを学ぶために.
  • R での解析手法に慣れるために.
  • とにかく R を使ってみたい.
  • 統計学と R を同時に学びたい.

_ 資料

準備途上 Windows 用実行ファイル &ref(): File not found: "ism20091124.R" at page "R_old_tips3";


R についての最近のメモ

_ ************

_ RとEmacsとGDBでデバッグ

_ Rcpp

_ Rcpp_DataFrame

_ Rの正規表現で URL 抽出.

とりあえず,手っ取り早くこんなもん.ただし,抽出できない場合もあるので注意.

str <- "これはhttp://cran.r-project.org/で,あれはhttp://www.yahoo.co.jp/です."

tmp <- gregexpr ("https?://.+/(.+/)*?", str)
substring(str, tmp[[1]], tmp[[1]] + attr (tmp[[1]],  'match.length') -1)

_ Rでシフト演算

_ animation

_ RHIPE - R and Hadoop Integrated Processing Environment

_ Putting Robust Standard Errors into LaTeX Tables An Extension of mtable

_ Building and checking R source packages for Windows

_ R 2.12 to 2.13 package upgrade

_ How to upgrade R on windows 7

_ Server版RStudio Ubuntu

_ 分割表をもとのデータに

_ Rで曜日と月の数を数える:

_ CRANberries

_ zapsmall

_ R_Connection

_ R_sqLite_Excel

_ if_else

_ rawToChar

_ Unicode_utf8

_ ReferenceClasses

とりあえずここを参考にサンプルを実行してみる

## a simple editor for matrix objects.  Method  $edit() changes  some
## range of values; method $undo() undoes the last edit.
mEditor <- setRefClass("matrixEditor",
     fields = list( data = "matrix",
       edits = "list"),
     methods = list(
    edit = function(i, j, value) {
      ## the following string documents the edit method
      'Replaces the range [i, j] of the
       object by value.
       '
        backup <-
            list(i, j, data[i,j])
        data[i,j] <<- value
        edits <<- c(list(backup),
                    edits)
        invisible(value)
    },
    undo = function() {
      'Undoes the last edit() operation
       and update the edits field accordingly.
       '
        prev <- edits
        if(length(prev)) prev <- prev[[1]]
        else stop("No more edits to undo")
        edit(prev[[1]], prev[[2]], prev[[3]])
        ## trim the edits list
        length(edits) <<- length(edits) - 2
        invisible(prev)
    }
    ))

xMat <- matrix(1:12,4,3)
xx <- mEditor$new(data = xMat)
xx$edit(2, 2, 0)
xx$data
xx$undo()
mEditor$help("undo")
stopifnot(all.equal(xx$data, xMat))

## add a method to save the object
mEditor$methods(
    save = function(file) {
      'Save the current object on the file
       in R external object format.
      '
        base::save(.self, file = file)
    }
)  
 
tf <- tempfile()
xx$save(tf) #$

_ Rcpp

_ 疎行列を作成する

_ boxplot

_ 適合度の検定における最小期待値

期待値が5未満のセルが20%あるといけないなどというが,一度,この根拠をしらべてみたことがある.このWikiのどこかにあるはずなのだが,みつからない.で,青木先生のサイトに情報があった.

_ CS3とEPS

Rで作成した日本語入りEPSを, Windows の CS3 で確実に読みこんでもらうには

library(Cairo)
CairoFonts(
  regular="IPA P明朝,IPAPMincho:style=Regular",
  bold="IPA Pゴシック,IPAPGothic:style=Regular,Bold",
  italic="IPA P明朝,IPAPMincho:style=Regular,Italic",
  bolditalic="IPA Pゴシック,IPAPGothic:style=Regular,Bold Italic,BoldItalic")

CairoPS(file = "/home/ishida/cairo.ps", bg="white")
plot(1:10, 1:10, main ="テスト", cex = 1.2)
dev.off()
embedFonts(file ="~/cairo.ps", outfile ="~/Cairo2.eps"  )

としておく.ここも参照

_ PDF

根本的解決に至っていないが R 上で日本語を含む PDF を作成できない. とりあえず

library(Cairo)
# CairoFonts(regular="VL ゴシック,VL Gothic:style=regular")
CairoFonts(regular="IPA P明朝,IPAPMincho:style=Regular")
CairoPS(file = "Fig", bg="white")
  hogehoge
dev.off()

として ps を作成し,変換しておく

_ RCurl

twitteR のインストールに必要だが,'curl' と 'libcurl3 に加えて,以下のコマンドの出力が示すように libcurl4-openssl-dev が必要

$ apt-cache search libcurl3-dev
libcurl4-openssl-dev - Development files and documentation for libcurl (OpenSSL)
$ apt-get install libcurl4-openssl-dev

ここ を参照

_ if の返り値

x <- 0
y <- if(x + 1){
  x + 100
}else{
  x - 100
}
y
[1] 100
# 
y <- if(x + 1) cat("TRUE\n")# else cat("FALSE\n")
if(y <- x + 1) cat("TRUE\n") else cat("FALSE\n")

_ lme による分散成分の標準誤差

  • Rjpwikiに lme の出力から分散成分の標準誤差を取り出したいという議論があるが,Batesがしばしば指摘しているようA,B) に,確率区間を使うべき.確率区間の計算は interval.lme() だから getS3method("interval", "lme") を実行して,一度アルゴリズムを確認すれば良いかなと思うのだけど.

_ .Primitives

2校演算子の定義するためにはクオートするが,呼び出しは以下のように,ダブルコーテーションも使えるのか

> str(`*`)
function (e1, e2)  
> get("*")
function (e1, e2)  .Primitive("*")
> `*`(3,3)
[1] 9
> get("*")
function (e1, e2)  .Primitive("*")
> "*"(3,3)
[1] 9
> `like this` <- 2
> "like that" <- 3
> print(`like this`)
[1] 2
> print("like that")
[1] "like that"

R-helpより

_ Cairo

Last-modified: 2019-07-17 (水) 09:03:48 (1744d)