Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the various apply functions in R

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces you how the various apply functions in R are, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Lapply: can be used for a list object and returns a list object

Sapply: more flexible, can accept vector or matrix as the main parameter, return form has better results, often in tabular form.

Lapply (XMagna FUNJI...)

Sapply (x Magna FUNJI.. Reagle simplifyproof true pr.

Vapply (x recordFUNJFUN.VALUE recorder.. reparentUSE.NAMESqualified true)

Replicate (nGravity exprforce simplify = "array")

Simplify2array (XMAE higherbelt true)

Lapply: returns a list equal to x, and each element is the result of applying the function FUN to the corresponding x element.

Sapply: a flexible version on top of lapply that returns vectors, matrices, or array array when simplify= "array" by default. At the same time, the application of simplify2array (), sapply (XMagnefo simplifyFALSE.NAMESFALSE) and lapply (XLING f) are equivalent.

Vapply: similar to sapply, but the return type can be specified in advance, which is more secure.

Replicate: repeatable evaluation of an expression on top of sapply, usually involving the generation of random numbers.

Simplify2array: called by sapply when the simplify part is FALSE.

Tapply applies FUN functions to x according to the different levels of INDEX.

Where:

X: an atomic object, usually a vector.

A list of INDEX:factors, each factor and x of the same length (which can be multidimensional).

FUN: the applied function, which can be an operator (qualified in quotation marks). If NULL, returns a vector.

Simplify: if false, an array of list mode is returned; if true, if FUN always returns scalar, then tapply returns an array of scalar mode (array)

When FUN is empty, a vector equal to x (called split vector) is returned, where each value is the index of the ith element of x in the levels array (when INDEX is multidimensional) or the tables two-dimensional array (column precedence).

When INDEX is multidimensional, a group is a factor vector.

About the various apply functions in R is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report