2017-09-21 2 views
-1

아래의 R 함수에서 객체 Binputn 또는 es을 출력하는지 여부를 R이 어떻게 평가할 수 있는지 궁금합니다.R에서 조건 출력을 평가 하시겠습니까?

참고 : 나는 input의 정확한 출력을 알아야합니다, 그래서 identical()를 사용 할 수없는 등

다음

내가 성공하지 시도 무엇 :

d = function(n, es){ 
    input = if(length(n) > 1) n else if(length(es) > 1) es else n 
    if(input == n) cat("yes") else cat("No") # IF `input` is `n` cat("yes") otherwise cat("no") 
} 

d(n = c(2, 3), es = 1) 

답변

2

시도 if(identical(n, input)) cat("yes") else cat("No")을 사용하십시오. ==은 (는)

+0

입니다. 편집시주의 사항을 참조하십시오. – rnorouzian

+0

'if (identical (input, n)) cat ("yes") else cat ("No")'멋지게 작동합니다 ... –

+0

@DamianoFantini, [** Here Here **] (https://stackoverflow.com/) 질문/46334808/mtext-for-the-input-argument-in-the-r)에 대한 선택 텍스트는 저의 완전한 질문입니까? – rnorouzian

관련 문제