| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- algeomath
- 작도
- 오일러
- 블록코딩
- 삼각함수의그래프
- 재귀함수
- 하합
- 수학탐구
- project euler
- 피타고라스 정리
- python
- 정오각형
- 시뮬레이션
- 큰 수의 법칙
- counting sunday
- 제곱근의뜻
- 구분구적법
- java
- 알지오매스
- 확률실험
- Geogebra
- 큰수의법칙
- 리만합
- 지오지브라
- 이항분포
- 프로젝트 오일러
- 파이썬
- 몬테카를로
- 프랙탈
- 상합
Archives
- Today
- Total
이경수 선생님의 수학실험실
Control Structure_if else & for loops 본문
R에서 조건문(if else문)은 다음과 같은 형식으로 나타낸다.
> x<-3
> if(x>3){
+ y<-1
+ } else if(x==3){
+ y<-2
+ } else {
+ y<-3
+ }
> y
[1] 2
반복문(for 문)은 다음과 같은 형식으로 나타낸다. 세 가지 예제는 모두 같은 결과를 나타내는 서로 다른 방법들이다.
> x<-c("red","blue","green")
> for(i in 1:4){
+ print(x[i])
+ }
[1] "red"
[1] "blue"
[1] "green"
[1] NA
> for(i in seq_along(x)){
+ print(x[i])
+ }
[1] "red"
[1] "blue"
[1] "green"
> for(letter in x){
+ print(letter)
+ }
[1] "red"
[1] "blue"
[1] "green"'R' 카테고리의 다른 글
| Function (0) | 2021.04.15 |
|---|---|
| Control Structures_Next (0) | 2021.04.15 |
| Control Structures_While loops (0) | 2021.04.15 |
| Subsetting_Removing Missing Values (0) | 2021.04.15 |
| Subsetting_Partial Matching (0) | 2021.04.15 |
Comments