2011-10-18 9 views
3

私は、処理されたWikipediaコーパスの単語の頻度とランクを持っています。 x(単語ランク)とy(頻度)の数字だけの行で、Rのログログプロットは次のようになります。http://en.wikipedia.org/wiki/File:Wikipedia-n-zipf.pngログログランク/周波数プロットの作成方法は?

どうすればいいですか?私は逆転したり、間違ったバージョンを取得し続けます。ありがとう。 latticelatticeExtra

答えて

2

を使用することができます。

plot(x, y, log="xy") 

これは対数スケールであなたのポイントをプロットします。

1

library(lattice) 
library(latticeExtra) 
xyplot((1:200)/20 ~ (1:200)/20, type = c('p', 'g'), 
     scales = list(x = list(log = 10), y = list(log = 10)), 
     xscale.components=xscale.components.log10ticks, 
     yscale.components=yscale.components.log10ticks) 

より多くの例here

1

あなたは既に単語の頻度とランクを取得することによって、苦労しています。ログスケールでプロットするだけです。

##Word frequencies in Moby dick 
dd = read.csv("http://tuvalu.santafe.edu/~aaronc/powerlaws/data/words.txt") 

##Rename the columns and add in the rank 
colnames(dd) = "freq" 
dd$rank = 1:nrow(dd) 

##Plot using base graphics 
plot(dd$rank, dd$freq, log="xy") 

それとも、ただ基本機能を備えたggplot2

require(ggplot2) 
ggplot(data=dd, aes(x=rank, y=Freq)) + 
    geom_point() + scale_x_log10() + 
    scale_y_log10() 
関連する問題