송지원
Q2. Find out about the function ‘rep’ by typing ?rep and generate a vector containing 10 repetitions of the word “noun”, and another vector containing 10 repetitions of the word “noun” and 20 repetitions of “verb”.
rep( c("noun", "verb"), c(10,20))
## [1] "noun" "noun" "noun" "noun" "noun" "noun" "noun" "noun" "noun" "noun"
## [11] "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb"
## [21] "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb" "verb"
Q3. Find out what the funciton ‘seq’ does, and generate a user-defined regular sequence.
seq는 등차수열을 생성하는 코드입니다. 제일 기본적인 예시는 다음과 같습니다.
seq(1,4)
## [1] 1 2 3 4
예를 들어, 1부터 10까지 1씩 증가하는 코드를 만들 때 아래와 같이 만들면 됩니다.
seq(1,10, by = 1)
## [1] 1 2 3 4 5 6 7 8 9 10
또 다른 예로, 1부터 10을 11개의 일정한 간격으로 나눌 때 아래와 같이 만들면 됩니다.
seq( 1, 10, length = 11 )
## [1] 1.0 1.9 2.8 3.7 4.6 5.5 6.4 7.3 8.2 9.1 10.0