0

ファイルにデータセットがあります。これは次のようになります。

0.0707526823
0.4859753978
0.0084166789
0.0694709558
0.0156410467
0.3783259831
0.8977261856
0.7981824881
0.2079852045
0.9498437264
0.9264972044
0.1878358734
0.0020816686
0.0024611297
0.4250464895
0.0725748666
0.0407962054
0.8282363221
0.8408343333
0.7129760016
0.2772250135
0.3677588953
0.4723908637
0.9452814318

このデータを0.1の間隔でビニングし、ヒストグラムをプロットしたいと思います。

私はRを使ってみました、

そしてここで私がしていたこと

x<-read.table("filex", header=T)
breaks=seq (min, max, step)
hist (x$col1, breaks)

しかし、私の場合、このコマンドは機能しません:(

awkの任意の1つのライナー、またはRを歓迎します

ありがとうございました

4

1 に答える 1

3

や などでより適切に指定する必要があるようbreaksです。min(x)max(x)

x <- read.table(textConnection("
    0.0707526823
    0.4859753978
    0.0084166789
    0.0694709558
    0.0156410467
    0.3783259831
    0.8977261856
    0.7981824881
    0.2079852045
    0.9498437264
    0.9264972044
    0.1878358734
    0.0020816686
    0.0024611297
    0.4250464895
    0.0725748666
    0.0407962054
    0.8282363221
    0.8408343333
    0.7129760016
    0.2772250135
    0.3677588953
    0.4723908637
    0.9452814318
"))

# extract vector of numeric from current data frame
x <- x$V1

# create breaks for frequency
# need to add a padding factor to make things equally spaced
step <- .1
pad <- step - ((max(x) - min(x)) %% step)/2
breaks <- seq(min(x) - pad, max(x) + pad,by=.1)

# alternative (only good for exact decimal increments):
# use floor and ceiling
breaks <- floor(min(x)*10):ceiling(max(x)*10)/10

# create histogram
# equally spaced breaks create frequency chart automatically
hist(x,breaks)
于 2012-11-01T13:49:26.253 に答える