官术网_书友最值得收藏!

Functions

As you grow in confidence with R, you will want to begin writing your own functions. This is achieved very simply, and in a manner quite similar to many other languages. You will no doubt want to read more about writing functions in R in more detail, but just to give you an idea, the following code is a function called the sumMultiply function that adds together x and y and multiplies the result by z:

sumMultiply <- function(x, y, z){ 
  final = (x+y) * z 
  return(final) 
} 

This function can now be called using sumMultiply(2, 3, 6), which will return 2 plus 3 times 6, which gives 30.

主站蜘蛛池模板: 通海县| 固阳县| 霍州市| 抚州市| 西充县| 渭源县| 略阳县| 珠海市| 沁阳市| 汝州市| 平罗县| 自贡市| 宿州市| 高邮市| 柞水县| 当阳市| 禹州市| 漾濞| 盱眙县| 林西县| 湘潭市| 刚察县| 新安县| 定西市| 金山区| 东乌珠穆沁旗| 宣武区| 珠海市| 西和县| 武清区| 阿巴嘎旗| 渭南市| 澳门| 临高县| 准格尔旗| 商河县| 古田县| 枣强县| 凤山市| 黑山县| 临夏县|