Q. Which of the following R code can be used to avoid numeric problems such as taking the logarithm of a negative number?

  • (A) if( any(x < 0) ) y <- log(1+x) else y <- log(x)
  • (B) if( any(x <= 0) ) y <- log(1+x) else y <- log(x)
  • (C) if( any(x >= 0) ) y <- log(1+x) else y <- log(x)
  • (D) if( any(x >> 0) ) x >- log(1+x) else x <- log(x)
πŸ’¬ Discuss
βœ… Correct Answer: (B) if( any(x <= 0) ) y <- log(1+x) else y <- log(x)

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
111
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
98%
Success Rate