在欧洲国家,逗号用于分隔数字的整数部分和小数部分。因此,我们可能希望使用逗号作为小数点分隔符来创建数据或执行计算。在 R 中,我们可以通过使用代码选项(OutDec=",")来做到这一点。一旦我们在 R 控制台中输入它,所有带小数的数值都将用逗号代替点打印。
options(OutDec=",") rnorm(10)输出结果
[1] 0,14421957 -0,24152088 -0,05215867 -0,40577010 0,19806357 -1,49349808 [7] 0,91085263 0,43550033 2,64009603 1,17177332
rnorm(50)输出结果
[1] -0,56186368 -2,11404777 0,99584461 -2,22892798 -0,21588798 1,17378223 [7] 0,80136793 -0,49890663 0,18921894 0,84527020 0,70202718 0,19353172 [13] -2,98976881 -1,55517319 -1,68843588 1,86947547 -0,85967931 2,22141501 [19] -0,42453554 -0,40316155 0,59594728 -0,65595306 -0,56355375 0,16093191 [25] 0,41548714 -0,93818875 1,52681800 0,48608906 0,15661614 -0,62745645 [31] 0,65458574 0,67902693 0,93203727 -2,08749758 1,42334302 0,63484421 [37] 0,17237517 0,80096817 2,23775268 -1,11276711 1,35285967 -1,46419180 [43] 0,04372825 0,13612209 -0,05656928 -3,19635679 -0,72720528 0,60253277 [49] -0,01956573 0,20112019
rnorm(50,100,2.24)输出结果
[1] 101,48879 100,75694 100,11546 99,08057 103,07195 99,53475 100,07432 [8] 98,15613 99,55028 98,63225 103,61765 101,77876 103,99651 97,80804 [15] 100,18855 101,57944 98,55887 102,64728 96,80716 99,69487 98,67344 [22] 98,23136 96,59398 101,13809 104,94554 99,65301 98,26410 99,66751 [29] 99,36292 99,50532 100,45769 98,02576 97,53276 101,41777 94,87069 [36] 102,58284 99,81109 101,60850 97,81656 100,99039 100,68643 97,32286 [43] 100,02354 97,62044 99,64247 99,58946 98,28843 99,64843 103,45448 [50] 102,01404
runif(50,2,5)输出结果
[1] 4,259546 4,969702 2,475870 3,622774 3,080443 4,256582 3,330830 3,024105 [9] 3,554120 3,185494 3,555678 3,449932 2,520527 4,460643 2,714603 2,641070 [17] 3,736799 3,716577 4,790006 2,673009 2,607128 2,818719 4,945594 3,874789 [25] 2,075472 3,821771 4,585981 2,223283 3,440357 4,812539 4,681781 4,349544 [33] 3,763122 3,711276 2,762271 4,037973 2,585901 3,649577 2,272758 2,960357 [41] 3,492060 3,063031 4,528179 3,367038 3,447430 4,705368 3,841602 2,319730 [49] 3,991398 2,109541
runif(50,2,10)输出结果
[1] 2,601662 7,086130 4,194458 4,030670 7,344066 6,476318 3,986455 8,276996 [9] 3,434791 9,760952 7,930710 7,154138 2,123655 2,169285 3,057115 2,826888 [17] 7,043019 5,317010 2,034057 8,667900 5,239970 9,278061 6,970918 9,131989 [25] 8,422478 9,642288 6,161859 7,361440 8,727534 4,972344 4,567614 9,981694 [33] 5,540412 5,144425 7,511388 5,628992 8,084486 2,462876 6,890469 5,386261 [41] 5,501142 3,140518 2,720681 5,481277 4,601765 3,194673 5,109435 5,786930 [49] 2,306639 6,518805
runif(50,100,500)输出结果
[1] 324,6319 108,5833 307,9311 294,8830 375,5872 385,8248 198,6368 204,8510 [9] 476,9923 272,6734 162,3869 468,9543 299,4737 397,6416 252,0612 387,7843 [17] 355,5026 369,7032 481,1163 219,3107 294,8288 230,6538 431,2116 478,4371 [25] 290,9903 351,6383 303,7567 141,1547 170,9008 285,7873 303,0370 203,2985 [33] 280,5315 223,7103 379,3487 200,4625 308,8092 303,7486 326,9930 151,6563 [41] 420,9092 296,0903 406,7682 445,1934 249,7644 477,2750 219,6605 365,9331 [49] 302,1841 193,9043
> rexp(80,1.37)输出结果
[1] 0,077263307 0,234174073 2,454894184 1,216015443 0,610670577 0,450220421 [7] 0,781902644 0,723594229 0,371607325 0,309788914 0,633456800 0,207343224 [13] 0,921222861 0,410496700 0,285874644 0,825631686 0,494836147 0,746554059 [19] 1,504242058 0,723692745 0,024898318 0,226251193 1,626604424 0,011893407 [25] 0,090971133 0,277625917 1,221526514 1,490549443 0,549020237 1,028102484 [31] 0,847492135 0,703920750 0,431831026 0,757378246 0,198574527 0,185446256 [37] 0,630798171 0,156981764 0,474978723 0,723217920 0,007928459 0,663266058 [43] 0,546132607 0,599982265 1,116886327 0,521197610 0,734407484 0,537714507 [49] 0,302900192 0,120592181 0,461599988 1,492210717 0,179615216 0,109953492 [55] 0,144390039 0,200401695 0,363837669 0,622152051 0,106983411 0,795086033 [61] 1,677166648 0,656683241 0,664218854 0,155483176 0,207980542 0,053253430 [67] 1,182462243 0,566262626 2,111718532 0,616123683 0,169117398 0,146551466 [73] 0,137258728 0,007949792 0,301259944 0,937648224 0,204266282 0,815650912 [79] 3,744783548 0,897738114
sample(c(3.17*10^14,2.25*10^25),50,replace=TRUE)输出结果
[1] 3,17e+14 2,25e+25 2,25e+25 3,17e+14 3,17e+14 2,25e+25 2,25e+25 3,17e+14 [9] 3,17e+14 3,17e+14 3,17e+14 3,17e+14 2,25e+25 2,25e+25 3,17e+14 3,17e+14 [17] 2,25e+25 3,17e+14 3,17e+14 3,17e+14 3,17e+14 2,25e+25 2,25e+25 3,17e+14 [25] 2,25e+25 3,17e+14 2,25e+25 3,17e+14 2,25e+25 3,17e+14 2,25e+25 2,25e+25 [33] 3,17e+14 2,25e+25 3,17e+14 3,17e+14 2,25e+25 3,17e+14 2,25e+25 2,25e+25 [41] 3,17e+14 2,25e+25 3,17e+14 2,25e+25 3,17e+14 3,17e+14 2,25e+25 3,17e+14 [49] 2,25e+25 3,17e+14
binom.test(x=20,n=100,p=0.30)输出结果
Exact binomial test data: 20 and 100 number of successes = 20, number of trials = 100, p-value = 0,02896 alternative hypothesis: true probability of success is not equal to 0,3 95 percent confidence interval: 0,1266556 0,2918427 sample estimates: probability of success 0,2