r.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ace.define("ace/snippets/r",[], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "snippet #!\n\
  4. #!/usr/bin/env Rscript\n\
  5. \n\
  6. # includes\n\
  7. snippet lib\n\
  8. library(${1:package})\n\
  9. snippet req\n\
  10. require(${1:package})\n\
  11. snippet source\n\
  12. source('${1:file}')\n\
  13. \n\
  14. # conditionals\n\
  15. snippet if\n\
  16. if (${1:condition}) {\n\
  17. ${2:code}\n\
  18. }\n\
  19. snippet el\n\
  20. else {\n\
  21. ${1:code}\n\
  22. }\n\
  23. snippet ei\n\
  24. else if (${1:condition}) {\n\
  25. ${2:code}\n\
  26. }\n\
  27. \n\
  28. # functions\n\
  29. snippet fun\n\
  30. ${1:name} = function (${2:variables}) {\n\
  31. ${3:code}\n\
  32. }\n\
  33. snippet ret\n\
  34. return(${1:code})\n\
  35. \n\
  36. # dataframes, lists, etc\n\
  37. snippet df\n\
  38. ${1:name}[${2:rows}, ${3:cols}]\n\
  39. snippet c\n\
  40. c(${1:items})\n\
  41. snippet li\n\
  42. list(${1:items})\n\
  43. snippet mat\n\
  44. matrix(${1:data}, nrow=${2:rows}, ncol=${3:cols})\n\
  45. \n\
  46. # apply functions\n\
  47. snippet apply\n\
  48. apply(${1:array}, ${2:margin}, ${3:function})\n\
  49. snippet lapply\n\
  50. lapply(${1:list}, ${2:function})\n\
  51. snippet sapply\n\
  52. sapply(${1:list}, ${2:function})\n\
  53. snippet vapply\n\
  54. vapply(${1:list}, ${2:function}, ${3:type})\n\
  55. snippet mapply\n\
  56. mapply(${1:function}, ${2:...})\n\
  57. snippet tapply\n\
  58. tapply(${1:vector}, ${2:index}, ${3:function})\n\
  59. snippet rapply\n\
  60. rapply(${1:list}, ${2:function})\n\
  61. \n\
  62. # plyr functions\n\
  63. snippet dd\n\
  64. ddply(${1:frame}, ${2:variables}, ${3:function})\n\
  65. snippet dl\n\
  66. dlply(${1:frame}, ${2:variables}, ${3:function})\n\
  67. snippet da\n\
  68. daply(${1:frame}, ${2:variables}, ${3:function})\n\
  69. snippet d_\n\
  70. d_ply(${1:frame}, ${2:variables}, ${3:function})\n\
  71. \n\
  72. snippet ad\n\
  73. adply(${1:array}, ${2:margin}, ${3:function})\n\
  74. snippet al\n\
  75. alply(${1:array}, ${2:margin}, ${3:function})\n\
  76. snippet aa\n\
  77. aaply(${1:array}, ${2:margin}, ${3:function})\n\
  78. snippet a_\n\
  79. a_ply(${1:array}, ${2:margin}, ${3:function})\n\
  80. \n\
  81. snippet ld\n\
  82. ldply(${1:list}, ${2:function})\n\
  83. snippet ll\n\
  84. llply(${1:list}, ${2:function})\n\
  85. snippet la\n\
  86. laply(${1:list}, ${2:function})\n\
  87. snippet l_\n\
  88. l_ply(${1:list}, ${2:function})\n\
  89. \n\
  90. snippet md\n\
  91. mdply(${1:matrix}, ${2:function})\n\
  92. snippet ml\n\
  93. mlply(${1:matrix}, ${2:function})\n\
  94. snippet ma\n\
  95. maply(${1:matrix}, ${2:function})\n\
  96. snippet m_\n\
  97. m_ply(${1:matrix}, ${2:function})\n\
  98. \n\
  99. # plot functions\n\
  100. snippet pl\n\
  101. plot(${1:x}, ${2:y})\n\
  102. snippet ggp\n\
  103. ggplot(${1:data}, aes(${2:aesthetics}))\n\
  104. snippet img\n\
  105. ${1:(jpeg,bmp,png,tiff)}(filename=\"${2:filename}\", width=${3}, height=${4}, unit=\"${5}\")\n\
  106. ${6:plot}\n\
  107. dev.off()\n\
  108. \n\
  109. # statistical test functions\n\
  110. snippet fis\n\
  111. fisher.test(${1:x}, ${2:y})\n\
  112. snippet chi\n\
  113. chisq.test(${1:x}, ${2:y})\n\
  114. snippet tt\n\
  115. t.test(${1:x}, ${2:y})\n\
  116. snippet wil\n\
  117. wilcox.test(${1:x}, ${2:y})\n\
  118. snippet cor\n\
  119. cor.test(${1:x}, ${2:y})\n\
  120. snippet fte\n\
  121. var.test(${1:x}, ${2:y})\n\
  122. snippet kvt \n\
  123. kv.test(${1:x}, ${2:y})\n\
  124. ";
  125. exports.scope = "r";
  126. });
  127. (function() {
  128. ace.require(["ace/snippets/r"], function(m) {
  129. if (typeof module == "object" && typeof exports == "object" && module) {
  130. module.exports = m;
  131. }
  132. });
  133. })();