Skip to menu

length 오류질문

촙춉 2020.05.26 20:19 Views : 6152

deal <- function(){
  card <- deck[1, ]
  assign("deck", deck[-1, ], envir = globalenv())
  card
  a <- deck$suit
 
  if (a == "joker"){
    "도둑"
  }else if (a == "diamonds"){
    "다이아몬드"
  }else if (a == "hearts"){
    "하트"
  }
   else if (a == "clubs"){
     "클로버"
   }else {
     "스페이드"
   }}

'data.frame':	19 obs. of  3 variables:
 $ face : Factor w/ 14 levels "ace","eight",..: 10 5 11 4 14 14 1 10 9 3 ...
 $ suit : Factor w/ 5 levels "clubs","diamonds",..: 5 1 3 1 3 2 2 2 5 2 ...
 $ value: int  7 11 6 4 2 2 1 7 12 5 ...
>


제가 간단한거 하나만들려구하는데  deal()이라는 함수를 구동시키면

Warning messages:
1: In if (a == "joker") { :
  the condition has length > 1 and only the first element will be used
2: In if (a == "diamonds") { :
  the condition has length > 1 and only the first element will be used
3: In if (a == "hearts") { :
  the condition has length > 1 and only the first element will be used
4: In if (a == "clubs") { :
  the condition has length > 1 and only the first element will be used

이런 에러가떠요.. roll()을 구동했을때 에러가 안나왔으면 좋겠는데..

계속 만들어보다가 함수 겨우 찾아서 만든건데 에러가뜨네요 ㅠㅠ 해결방법이나 다른함수를 써서 코딩할수있는 방법좀 알려주세요

제가 하고싶은건 한번실행할때마다 하나의결과값을 얻는것입니다. 부탁드립니다