R_old_tips4 - アールメカブ

アールメカブ


R_old_tips4

R_old_tips3

_ R_64_bit_packages

_ biplot のラベルを変える

res.pc <- princomp(res, scale = 1)
rownames(res.pc$loadings) <- c("安部","麻生","福田","鳩山")
names(res.pc$scale) <- c("安部","麻生","福田","鳩山

_ 要素の長さが違うリストからテーブルを作る

もっとエレガントな方法(関数)があったような。

> a <- c("A","A", "B", "A")
> b <- c("A","B", "C", "A", "B")
> c <- c("C","A", "C", "B", "A", "B")
> 
> abc <- list(a,b,c)
> names(abc) <- c("あ","い","う")
> abc
$あ
[1] "A" "A" "B" "A"

$い
[1] "A" "B" "C" "A" "B"

$う
[1] "C" "A" "C" "B" "A" "B"

> 
> abc2 <- lapply(abc, table)
> abc2
$あ

A B 
3 1 

$い

A B C 
2 2 1 

$う

A B C 
2 2 2 

> abc3 <- lapply(abc2, data.frame)
> abc3
$あ
  Var1 Freq
1    A    3
2    B    1

$い
  Var1 Freq
1    A    2
2    B    2
3    C    1

$う
  Var1 Freq
1    A    2
2    B    2
3    C    2

> library(reshape)
 要求されたパッケージ plyr をロード中です 
> melt(abc3)
Using Var1 as id variables
Using Var1 as id variables
Using Var1 as id variables
  Var1 variable value L1
1    A     Freq     3 あ
2    B     Freq     1 あ
3    A     Freq     2 い
4    B     Freq     2 い
5    C     Freq     1 い
6    A     Freq     2 う
7    B     Freq     2 う
8    C     Freq     2 う
 
Link: R_old_tips5(149d) R_old_tips3(149d) R_64_bit_packages(3077d)
Last-modified: 2019-07-17 (水) 09:04:33 (149d)