Facebook
From Hot Giraffe, 1 Month ago, written in R.
Embed
Download Paste or View Raw
Hits: 66
  1. # Question 1
  2. x = c(1,2,3)
  3. sum(x)
  4. mean(x)
  5. sqrt(x)
  6.  
  7. # Question 2
  8. s = c(14.2,4,9,10,14,28,52)
  9. mean(s)
  10. sd(s)
  11.  
  12. # Question 3
  13. x = c('A','B','C','A','B','A','A','B')
  14. s = fact(x)
  15.  
  16. # Question 4
  17. A = matrix(c(1,2,3,4),2,2)
  18. B = matrix(c(2,1,3,1),2,2)
  19. c = rbind(A,B)
  20. d = cbind(A,B)
  21.  
  22. # Question 5
  23. x<-1,4
  24. y<-2
  25. x3=x+y
  26. print(x3)
  27.  
  28. ----------------------------------------------------------------------
  29.  
  30. # Long Answers
  31. # Question 6
  32. Write about the Different data types in r
  33. There are 5 data types
  34.  
  35. # Question 7
  36. Write a function to check if a number methods/html/is.html">is a prime number
  37.  
  38. # Question 8
  39.  
  40. Maybe this stuff
  41. {
  42. x <- c(1,3,5)
  43. y <- c(3,2,10)
  44. z1 = rbind(x,y)
  45. z2 = cbind(x,y)
  46. print(dim(z1))
  47. print(dim(z2))
  48. }
  49. Def this stuff
  50. A <- matrix(c(1,3,5),3)
  51. B <- matrix(c(2,3,10),3)
  52.  
  53.  
  54. # Question 9
  55.  
  56. H = c(66,62,63,70,74)
  57. G = c(3.80,3,78,3.88,3.72,3.69)
  58.  
  59. st = data.frame(H,G)
  60. print(st)
  61.  
  62. ----------------------------------------------------------------------
  63. #Functions
  64. adi <- function(x,y)
  65. {
  66.     res = x+y
  67.     print(res)
  68. }
  69.  
  70. adi(5,9)