R语言-要点琐细及自定义函数的创建
2018-02-27 11:40
218 查看
# Time of establishment: 2018.2.27 # Restart of the R learning # ------------------------------------------------------------------------------ # 1.the symble of connecting sentence when changing lines is + # If a line is still not completed, but the key enter has been pushed, there # will be a symbol "+" that means you can continue # 2."#" is commenting symbol # 3.ctrl + c is used to stop a function which is still working # 4.object is to be manipulated a <- 1 # establish an object a <- a +2 # change the value of object a # 5.uppercase and lowecase letters are different # 6.the command "ls()" can show us the objects that exist # 7.R langusge will use vector loop method to achieve the purpose of length matching # for the mulplication of matrix, # %*% --->>> in multiply # %o% --->>> out multiply die <- c(1:6) inn <- die %*% die # get a number out <- die %o% die # get a matrix out t(die) # transpose. Vector can be seen as a column Vector die det(out) # ------------------------------------------------------------------------------ # function round(3.15426) # as the name, rounding factorial(5) # mean(die) # to get the average value sample(x = 1:4, size = 2) # x means the vector to be sampled # size means the number of members sample(die, 1) # simulate the craps process args(sample) # look up for the arguments of the function round(3.14, digits = 1) # remain a decimal # note: sample function is without replacement originally # in order to get the result with replacement sample(die, size = 2, replace = TRUE) # ------------------------------------------------------------------------------ # establish a function of mine roll <- function(){ die <- 1:6 dice <- sample(die, size = 2, replace = TRUE) sum(dice) } sim = roll() # note: 8L means a long integer which is 8 # function with input arguements roll2 <- function(bones){ dice <- sample(bones, size = 2, replace = TRUE) sum(dice) } roll2(bones = 1:4) # set defauts for the input arguements roll3 <- function(bones = 1:6){ dice <- sample(bones, size = 2, replace = TRUE) sum(dice) } roll3()
相关文章推荐
- 自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X * run方法内统计每个线程 一共6次
- mysql创建自定义函数
- Python自定义函数的创建、调用和函数的参数详解
- Python自定义函数的创建、调用和函数的参数详解
- 第二种:自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X * run方法内统计每个线程 一共6次
- 22- mysql不能创建自定义函数
- R语言:自定义函数
- MySQL存储过程和自定义函数、Navicat、创建存储过程和函数、调用存储过程和函数、三种方式、In和Out类型参数、
- mysql创建自定义函数和存储过程
- MySQL存储过程和自定义函数、Navicat for mysql、创建存储过程和函数、调用存储过程和函数的区别
- PHP入门教程之自定义函数用法详解(创建,调用,变量,参数,返回值等)
- MySQL 创建自定义函数
- 深入mysql创建自定义函数与存储过程的详解
- sql代码重构—— 创建自定义函数(二)
- 基于自定义函数的Function-Based索引创建
- 在C#中创建SQLite自定义函数
- mysql在centos上创建自定义函数报错。
- mysql 报错之创建自定义函数
- mysql创建自定义函数与存储过程
- larave5.4自定义公共函数的创建