a b c a b c a b c a b c a b c a B CLevels:a B C D E> table (d)DA B C D E10 10 10) 0 0> table (d, exclude= "B")DA C D E10 10 0 0
function lapply and function sapply:
Lapply is used in the following format:Lapply (X, fun, ...) The return value of Lapply is a list object with the same length as x, and each element in the list object is applied to each
The R language provides a bulk processing function that iterates through all or part of the elements within a collection to simplify operations.
The bottom of these functions is achieved by C, so efficiency is more efficient than manual.The batch processing function has very important apply family function: lapply sapply
Apply ()Apply (M,dimcode,f,fargs)
M is a matrix.
DimCode is the dimension number, 1 is applied to the row, and 2 is the function for the column.
F is a function
Fargs is an optional parameter set for F
> z > f + x/c(2, 8)+ }> apply(z,1,f) #f函数得到两个元素,则为几行,竖着来的 [,1] [,2] [,3][1,] 0.5 1.000 1.50[2,] 0.5 0.625 0.75Lapply ()Lapply () (on behalf of list apply) is similar to the u
Apply ()Apply (M,dimcode,f,fargs)
M is a matrix.
DimCode is the dimension number, 1 is applied to the row, and 2 is the function for the column.
F is a function
Fargs is an optional parameter set for F
> z > f + x/c(2, 8)+ }> apply(z,1,f) #f函数得到两个元素,则为几行,竖着来的 [,1] [,2] [,3][1,] 0.5 1.000 1.50[2,] 0.5 0.625 0.75Lapply ()Lapply () (on behalf of list apply) is similar to the u
More busy than busy more recently ... Really busy///As a rookie, do not understand why so easy to forget the basic operation of R, feel more difficult than C # JAVA, and to review again1 ##数据操作的入门2 3 ##定义一个函数判断偶数4Func function (x)5 {6 if(x% 2 = =0) {7RET 'even'8}Else9 {TenRET 'Odd' One } A return(ret) - } - the ##测试效果 -Func (35) - - ##sapply----The following code will error, the parameter can only
Recently participated in a small game where the tapply,sapply (lapply) function can quickly achieve my purpose and effectively reduce the amount of code
F
Description
Tapply (X,F,G)
X is a vector, F is a factor column, G is an action function, and a similar operation with a data frame can be done by using the by
ObjectiveAt the beginning of the contact with the R language, you will hear a variety of R language use skills, the most important one is not to use the loop, the efficiency is particularly low, to use vector computing instead of cyclic calculation.So, what is this for? The reason is that R's cyclic operation for and while, are based on the R language itself, and the vector operation is based on the underlying C language function implementation, from
Apply
Apply Functions over Array MarginsUse functions against column rows or columns
Apply (X, MARGIN, fun, ...)
Lapply
Apply a Function over a List or VectorUsing functions on lists or vectors
Lapply (X, fun, ...)
Sapply
Apply a Function over a List or VectorUsing functions on lists or vectors
[SOURCE DOWNLOAD]Quick Fix (3)-PHP: function basis, function parameters, function return value, variable function, anonymous function, closure function, callback functionWebabcdIntroducedQuick and fast PHP
There are several commonly used functions in the R language, which can be processed by group, apply, Lapply, sapply, tapply, mapply, etc. These functions are somewhat similar, and the following describes the usage of these functions.ApplyThis is an operation on a matrix or array for a dimension. The format is: Apply (data, dimension index, arithmetic function, function
virtual functions are defined in the base class for overload and polymorphism, and can be overridden or not written in a base class, even if the definition is null.
pure virtual functions are not defined in the base class and must be implemented in subclasses, much like Java the interface function in.
virtual function
Introduction Reason: In order to facilitate the use of polymorphic features, we often ne
Zookeeper
1 fork () function
The sub-process copies the 0-3g space of the parent process and the PCB in the parent process kernel, but the ID number is different. A fork call returns two times at a time, which has the following features:
A: The child process ID is returned from the parent process.
B: The sub-process returns 0.
C: shared during read and copy during write
2 fork ()-dependent header file
# Include
3 fork ()
I. Lambda anonymous function (one line for a function, but not a complex function operation)Syntax: function name = lambda parameter: return valueAttention:1. Functions can have more than one argument, separated by commas2. Anonymous functions no matter how complex, can only write one line, and the logic is finished di
sheets ', ' 370322199109011234 ', ' Class three ', 60,50,40, ' male ')INSERT into XS values (1, ' John Doe Li ', ' 370322199110011234 ', ' Class three ', 61,51,41, ' female ')INSERT into XS values (1, ' Harry King ', ' 370322199111011234 ', ' Class three ', 62,52,42, ' male ')INSERT into XS values (1, ' Zhao Liu Zhao ', ' 370322199112011234 ', ' Class three ', 63,53,43, ' female ')GoSelect *from XSALTER TABLE XS Add [Xingbie]char (10)--Add columnGoSelect *from XSALTER TABLE XS drop column [Xing
File: mfunentry. BasFunction: encapsulate the callback function -- construct an entry in the form of a common function (a function without the this pointer in the parameter) for the object method (the function with the this pointer in the parameter ).Author: zyl910Version: V1.0Date: 2005-6-24
It is very troublesome to
function
In JavaScript, a function is also a data type, and there are two ways to define a function:
function f () {return 1;}
var f=function () {return 1;}
So, the function in JavaScript is a kind of data, but it has two impor
Reclaim process user space resource exit () function _ exit () function atexit () function on_exit () function, _ exitatexitAbstract:This article describes how to terminate a process and how to use the exit () function to terminate the process and reclaim the user space reso
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.