R 1
Published:
In this post, basic grammar of R is introuduced.
R
Useful functions
ls() # 현재 사용중인 객체 이름 확인 args() # 함수의 인자 구조 확인Basic Operations
# 연속된 정수, <- 객체 변수에 할당 die <- 1:6 ## 1 2 3 4 5 6 # element-wise 연산 die + 1:2 ## 2 4 4 6 6 8 # matrix multiplication (행렬곱) die %*% die # vector outer product (벡터 외적) die %o% dieBasic Functions
# 반올림 round(3.1415) # ! factorial(3) # 평균 mean(die)비복원 추출 / 복원 추출
die <- 1:6 sample(die, size = 2) # 비복원 추출 dice <- sample(die, size = 2, replace = TRUE) # 복원 추출 dice dice # 여러번 호출해도 값은 동일

Leave a Comment