$ Rscript a.R # command line output
$ R CMD BATCH a.R # a.Rout 생성
1. Data frame
*데이터에 대한 정보 얻기
ls() #objects in working env
str(mydata) #structure 보여줌
levels(mydata$v1) #factor v1의 level을 보여줌
dim(object) #object의 차원
class(object) #object의 class (numeric, matrix, data frame, etc)
head(mydata, n=10) #첫 10개 row를 보여줌
tail(mydata, n=5) #끝 5개 row를 보여줌
*데이터 다루기
cbind(M,v): 서로 다른 column끼리 가로로 붙임
rbind(M,v): 서로 다른 row끼리 세로로 붙임
data.frame(col_name=integer(), col_name2=double()...) : 빈 data frame 만들기
colnames(m2) <- paste("Sub", colnames(m2), sep = "_") # column name에 이어 붙이기
2. File IO
data <- read.table(file_name, header = T)
write.table( data, file_name, colname = T, rowname = F, append = F)
save( objects, to, save, file = 'file_dir.rda') # save workspace : http://rfunction.com/archives/420
3. R functions
myfunction <- function(arg1, arg2, ... ){
statements
return(object)
}
4. Loop in R
for (i in list){
blah blah blah
}
5. Statistics
quantile( data, c(0.77,0.99,...) ) # quantile/precentile 계산
'Programming' 카테고리의 다른 글
[Linux] 메모리 관리 (0) | 2018.05.22 |
---|---|
[Linux] grep / find 사용하기 (0) | 2018.04.26 |
[linux][펌] ctags 사용법 (0) | 2017.09.26 |
[python] .pyc 파일은 무엇일까? (0) | 2017.09.26 |
[python] os 와 sys 모듈 (0) | 2017.08.07 |