![](https://img-blog.csdnimg.cn/20190918140129601.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
R语言中的函数
文章平均质量分 59
介绍R语言中的一些常用函数
zoujiahui_2018
统计学博士
展开
-
R语言中的函数28:Reduce(), Filter(), Find(), Map(), Negate(), Position()
R语言中的Reduce(), Filter(), Find(), Map(), Negate(), Position()是base包中的一些高级函数。随后,很多包也给这些函数提供了更多的扩展。原创 2023-12-23 23:49:08 · 1049 阅读 · 0 评论 -
R语言中的函数27:polynom::polynomial(), deriv(),integral(),solve()多式处理函数
R语言中多项式处理函数原创 2023-11-05 12:19:04 · 789 阅读 · 0 评论 -
R语言中的函数26:polyroot多项式求根函数
R语言中的base::polyroot()可以用于对多项式求根,求根的多项式可以是复数域上的。原创 2023-11-05 10:58:26 · 684 阅读 · 0 评论 -
R语言中的函数25:paste,paste0
R中的paste函数原创 2023-08-09 22:06:58 · 1854 阅读 · 0 评论 -
R语言中的函数24:Combinat:combn(), permn()
R语言中用于排列组合的函数原创 2023-08-09 21:24:25 · 1076 阅读 · 0 评论 -
R语言中的函数23:zoo::rollmean, rollmax, rollmedian, rollsum等等
R语言中的滚动函数原创 2023-07-26 23:50:15 · 1022 阅读 · 0 评论 -
R语言中的函数22:table(),xtabs(),prop.table(),margin.table(),addmargins(),ftable()
R语言中对多个因子可以汇总成一个列联表。原创 2022-11-21 21:11:44 · 4144 阅读 · 0 评论 -
R语言中的函数21:str(),mode(),class(),typeof(),.class2()
R语言中可以利用str(),mode(),class(),typeof(),.class2()这几个函数对一个数据对象的结构进行探测。原创 2022-11-21 12:29:02 · 723 阅读 · 0 评论 -
R语言中的函数20:parse(),eval()和do.call()
eval()函数的用法此函数可以接受一个字符串str作为参数,并把此str当做一段javascript代码去执行,如果str执行结果是一个值则返回此值,否则返回undefined。如果参数不是一个字符串,则直接返回该参数,实例如下:eval("var a=1");//声明一个变量a并赋值1。eval("2+3");//执行加运算,并返回运算值。eval("mytest()");//执行my...原创 2019-08-01 11:34:58 · 8282 阅读 · 1 评论 -
R语言中的函数19:openxlsx::read.xlsx(), write.xlsx(), writeData(), writeDataTable()
R语言中的openxlsx包的用法介绍原创 2022-11-15 17:20:07 · 5283 阅读 · 0 评论 -
R语言中的函数18:readxl::read_excel(), read_xls(),read_xlsx()
R语言中readxl包中的函数介绍原创 2022-11-15 11:06:11 · 13008 阅读 · 0 评论 -
R语言中的函数17:as.Date()和as.POSIXlt()
R语言中的时间对象处理函数原创 2022-11-14 22:21:34 · 3643 阅读 · 0 评论 -
R语言中的函数16:subset(dataset, subset, select)
# 函数介绍subset(dataset, subset, select)用于查找满足条件的dataset中的元素用法## S3 method for class 'matrix'subset(x, subset, select, drop = FALSE, ...)## S3 method for class 'data.frame'subset(x, subset, select, drop = FALSE, ...)参数:x object to be subsetted.s原创 2022-03-13 22:40:49 · 2767 阅读 · 0 评论 -
R语言中的函数15:tryCatch()
介绍tryCatch()函数可以根据表达式的Warning或者Error信息做出相应的操作。函数用法tryCatch({ expr}, warning = function(w){# 这里是出现warning状态时,应该怎么做,可以用print打印出来,可以执行其它命令}, error = function(e){# 这里时出现Error状态时,应该怎么做,可以用print打印出来,也可以执行其它命令},finally = {# 这是运行正常时,应该怎么做,可以用print打印出来,也可转载 2022-01-05 10:06:39 · 4539 阅读 · 0 评论 -
R语言中的函数14:corssprod()和tcrossprod()
介绍R语言中有两个矩阵乘积函数corssprod(x,y))(=t(x)%*%x)和tcorssprod(x,y)(=x%*%t(x)),这两个函数在向量之间的乘法应用中会很方便。应用a=c(1,2,3)b=c(2,5,4)crossprod(a,b)# [,1]# [1,] 24t(a)%*%b# [,1]# [1,] 24tcrossprod(a,b)# [,1] [,2] [,3]# [1,] 2 5 4#原创 2022-05-07 11:27:12 · 838 阅读 · 0 评论 -
R语言中的函数13:cut()
介绍cut()函数通过将一个连续变量分割后形成因子变量用法cut(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE, ...)参数介绍x a numeric vector which is to be converted to a factor by cutting.breaks either a numeric vecto原创 2022-04-07 21:03:12 · 1200 阅读 · 0 评论 -
R语言中的函数12:with()和by()
with(data, expr, …)该函数表示,利用data数据框中的数据,进行expr中代码的运算实例a='out'df=data.frame(x=c(1,2,3),y=c(5,6,8))with(df, {a=x+y b=x-y print(a) })# [1] 6 8 11a# [1] "out"注意,expr中的变量是局部变量。by(data, INDICES, FUN, …, simplify = TRUE)该函数表示根据in原创 2022-03-31 12:22:04 · 4290 阅读 · 0 评论 -
R语言中的函数11:corrplot::corrplot()和corrplot.mixed()
corrplot()介绍该函数实现了对correlation矩阵和置信区间的图示化。并且它也可以对一般的矩阵实现可视化只需要设置is.corr = FALSE.用法corrplot( corr, method = c("circle", "square", "ellipse", "number", "shade", "color", "pie"), type = c("full", "lower", "upper"), add = FALSE, col = NULL, col翻译 2022-03-15 16:25:08 · 10100 阅读 · 1 评论 -
R语言中的函数10:“[“, $,@和[[]]
介绍R语言中有一个很小众的函数"[",意思是按索引取值用法"["(x,n)参数介绍:x: 具有索引值的对象,如vector,listn: 是一个整数返回值:x[n]例子a=c(4,5,6,7)'['(a,2)#5原创 2022-03-14 23:18:01 · 4757 阅读 · 0 评论 -
R语言中的函数9:line()和lines()
R语言中的line()和lines()函数介绍原创 2022-11-14 12:49:56 · 4439 阅读 · 0 评论 -
R语言中的函数8:lowess()
R语言中实现非参平滑的函数lowess()原创 2022-11-14 12:29:19 · 2779 阅读 · 0 评论 -
R语言中的函数7:cut()
R语言中cut()函数的用法原创 2022-11-14 12:22:21 · 1507 阅读 · 0 评论 -
R语言中的函数6:grep()和grepl(),sub()和gsub()
函数介绍grep()和grepl()是用来查找目标字符串或字符串向量中是否包含目标子串。用法grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE)grepl(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)参数原创 2022-03-13 22:24:59 · 9975 阅读 · 0 评论 -
R语言中的函数5:purrr:map()
map(x, f)原创 2020-02-21 23:42:09 · 15528 阅读 · 1 评论 -
R语言中的函数4:split(), cut(), subset()
split()函数#Rsplit(x, f, drop = FALSE, ...)## Default S3 method:split(x, f, drop = FALSE, sep = ".", lex.order = FALSE, ...)split(x, f, drop = FALSE, ...) <- valueunsplit(value, f, drop = FALS...原创 2020-04-28 13:16:42 · 16829 阅读 · 2 评论 -
R语言中的函数3:curve()
文章目录curve函数简介实例绘制y=x的直线绘制 y = 2x + 3 的直线y= 2x + 3幂函数图像y = x三角函数图像余切函数curve函数简介curve函数语法格式如下:curve(expr, from = NULL, to = NULL, n = 101, add = FALSE, type = "l", xname = "x", xlab = xname, ylab = NULL, log = NULL, xlim = NULL, ...)主要的参数如下:expr:函数名称或转载 2021-07-18 16:08:11 · 12904 阅读 · 1 评论 -
R语言中的函数2:predict()
predict()的用法函数形式predict (object, ...)该函数是一个大类,其中还包含很多变体:[1] predict.ar* predict.Arima* predict.arima0* predict.glm [5] predict.HoltWinters* predict.lm predict.loess* ...原创 2021-08-22 18:40:41 · 70204 阅读 · 4 评论 -
R语言中的函数1:outer(张量积)
含义1.outer()相当于张量积,不过这里不单单实现了数值运算还实现了更丰富的运算。2.outer(x,y, fun)的输出是一个矩阵,记作A.元素A中的元素A[i,j]=fun(x[i],y[j]).3.x%o%y相当于outer(x,y,’*’)举例%o%的应用x <- 1:9; names(x) <- x# Multiplication & Power Tablesx %o% x# 1 2 3 4 5 6 7 8 9# 1 1 2 3原创 2021-11-08 16:00:33 · 3772 阅读 · 0 评论