推 josephw:喔喔喔 謝謝學長喔^^酷耶 01/20 12:12
學長我想問一下
就是之前學長在介紹盧sir的最後
有告訴我們可以讓R跑很快的指令
哈哈 我突然忘記了 不過我想把他學起來
學長在教導一下^^ 哈哈
※ 引述《seablack (Water)》之銘言:
: Add some useful packages (functions) in R to all.
: Name Illustrations
: 1. boost : Boosting Methods for Real and Simulated Data
: 2. classifly : Explore classification models in high dimensions
: 3. concord : Concordance and reliability
: 4. dyn : Time Series Regression
: 5. EMV : Estimation of Missing Values for a Data Matrix
: 6. FactoMineR: Factor Analysis and Data Mining with R
: 7. fda : Functional Data Analysis
: 8. gclus : Clustering Graphics
: 9. ump : Uniformly Most Powerful Tests
: 10. TwoWaySurvival : Additiv Two-Way Hazards Modelling of
: Right Censored Survival Data
: Reference from http://cran.csie.ntu.edu.tw/src/contrib/PACKAGES.html
: : In R :
: : 1. Function for reading binary data:
: : e.g.,
: : zz = file("D:/Test01.raw", "rb") # Readin binary data
: : N = 2064384/2; # Numbers of data
: : nb = 128; # image size = nb x nb
: : k = 40; # 40th
: : Img = readBin(zz, "integer", n=N,size=2) # using 2 bytes integer read data
: : ZZ = matrix(Img[(1+(k-1)*nb*nb):((k)*nb*nb)],nb,nb); # assign 40th image to ZZ
: : Co = rgb(0:255, 0:255, 0:255, max = 255); #Create gray map
: : image(1:nb, 1:nb,ZZ,col = Co) # display 40th image
: : 2. Function for data mining package:
: : RWeka : Collected many mining tools like those in http://www.cs.waikato.ac.nz/ml/weka/.
: : http://cran.cs.pu.edu.tw/src/contrib/Descriptions/RWeka.html
: : 3. Function for Parallel Virtual Machine (PVM):
: : rpvm : http://cran.cs.pu.edu.tw/src/contrib/Descriptions/rpvm.html
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.170.104.119
> -------------------------------------------------------------------------- <
作者: seablack (Water) 看板: NCTU-STAT95G
標題: Re: [討論] 程式碼
時間: Sat Jan 20 12:12:14 2007
How-to use "which" command and avoid using "for-loop" in R.
EX. X = 1 2 3 4 5 6 7 8
If we only want those X < 5 and save them as Y.
One possible solution as below.
> X=c(1,2,3,4,5,6,7,8)
> I=which(X>=5)
> I
[1] 5 6 7 8
# Those I records all "index" of X>=5.
# Next, you can use [-I] to skip thost index which X>=5
# Then, you get a new array Y which are those X<5. ^_^
> Y=X[-I]
> Y
[1] 1 2 3 4
For matrix object, this command also could be applied to.
Other possible commands also could be used to avoid "for-loop in R.
union(x, y)
intersect(x, y)
setdiff(x, y)
setequal(x, y)
Please try to use them. ^___^
※ 引述《ilanglenn (Glenn)》之銘言:
: 我有抄捏
: library 裡 ks
: 不過我不知道怎麼用哈哈
: 還有which
: ex
: I=which(x>0)
: y=x[-I]
: ※ 引述《mangogogo ()》之銘言:
: : 學長我想問一下
: : 就是之前學長在介紹盧sir的最後
: : 有告訴我們可以讓R跑很快的指令
: : 哈哈 我突然忘記了 不過我想把他學起來
: : 學長在教導一下^^ 哈哈
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.230.203.108