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

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.

主站蜘蛛池模板: 邵武市| 寻甸| 邵武市| 宜兰县| 冀州市| 博客| 海宁市| 荣成市| 沂源县| 根河市| 固阳县| 邯郸县| 沁源县| 天津市| 阜城县| 彩票| 聂拉木县| 独山县| 图片| 桦川县| 瓮安县| 柳州市| 伊金霍洛旗| 桃园市| 隆德县| 敦煌市| 山东省| 织金县| 建昌县| 拉萨市| 定州市| 沂水县| 浦县| 高清| 汾阳市| 盘锦市| 洞口县| 广西| 桦甸市| 贵州省| 仪陇县|