how to use sapply

Learn about how to use sapply, we have the largest and most updated how to use sapply information on alibabacloud.com

Use Apply, tapply, lapply, Sapply, mapply in R

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 element of the X. where x is a list object (each element of the list is a vector), other

R language Apply,sapply,lapply,tapply,vapply, the use of mapply

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 use of the Apply () function of the matrix, ex

R in the use of apply, tapply, lapply, sapply, mapply, table and other functions for grouping statistics-reproduced

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 use of the Apply () function of the matrix, ex

Introduction of Apply, Tapply, lapply, sapply, mapply, table and other functions in R

' NULL > Tapply (1:17, FAC, RANGE) $ ' 1 ' [1] 1 16 $ ' 2 ' [1] 2 17 $ ' 3 ' [1] 3 15 $ ' 4 ' NULL $ ' 5 ' NULL #利用tapply实现类似于excel里的数据透视表的功能: > da year Province Sale 12007 Nbsp;a1 22007 b2 32007c 3 42007d 4 52008a5 6 2008c6 72008 d7 82009 b8 92009 c9 2009d10 > attAch (DA) > Tapply (sale,list (year,province)) [1]147 102 8 1169 > Tapply (sale,list (year,province), mean) ab cd 200712 34 20085 NA 6 7 na8 9 10 lapply function and sapply function: L

Efficient batch processing functions in R (lapply sapply apply tapply mapply) _r language

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 tapply mapply. The Apply family function is one of the methods to realize the computational quantization (vectorization) with

Basic operation of the R language-read and write txt,sapply&lapply

='output.txt', append =TRUE) - ##cat还可以对已有内容的文件加操作---As to why this is not the direct use of output I am also very surprised AboutCat (101:200,sep ='\ n', File ='output.txt', append =TRUE) $ ##读取txt -Input 'output.txt') - input - A ##开始一个新的例子 + ##读取路径 thePath ] - ##改路径下的所有文件夹? $Doc.names dir (path) the Doc.names the ##改变路径 theDoc.path sapply (doc.names,function (names) { thePaste (Path,names,'DESCRIPTION'

R Language--tapply,sapply (actions of factors and lists)

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 function Sapply (LIST,G) G is the operatio

The exception that occurs when you use Unlist to convert a list of date data to vectors

When you use the Unlist function to convert a list of date types to vectors, you do not get the desired result, as follows:Datelst datelst[[1]][1] "2015-08-11"datevector DATEVECTOR[1] 16658 The same reason for using sapply (X, fun, ..., simplify = TRUE, use. NAMES = TRUE), if X is a date-type vector, fun returns the date, then the result will not be the expecte

Use R to generate wordcloud-from Twitter Project

Words and Their frequenciesplot the wordcloud Example 1: tweets via TwitterStep 1:Load all the required packageslibrary(twitteR)library(tm)library(wordcloud)library(RColorBrewer)Step 2:Let's get some tweets in English containing the words "Machine Learning"mach_tweets = searchTwitter("machine learning", n=500, lang="en")Step 3:Extract the text from the tweets in a vectormach_text = sapply(mach_tweets, function(x) x$getText())Step 4:Construct the lexi

Apply function in R language

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

Vi/vim Use advanced: Use GDB debugging in Vim – use Vimgdb

Label:Vi/vim Use advanced: Use GDB debugging in Vim – use Vimgdb The help entry for the commands used in this section: In the original design of Unix system, there is a very important idea: each program only to achieve a single function, through the pipeline and other ways to connect multiple programs, so that they work together to achieve more powerful function

Similar to Baidu Library solution (5) -- use SWFTools to Convert PDF files to SWF overall idea use Jacob to call MS Office to convert documents to PDF use JCom to call MS Office or Acrobat API to convert documents

Directory Baidu Library solution (I)-Overall Thinking Baidu Library solution (2) -- use Jacob to call MS Office to convert the document to PDF Baidu Library solution (3) -- use JCom to call MS Office or Acrobat API to convert the document to PDF Similar to Baidu Library solution (4) -- use JODConverter to call OpenOffice.org to convert the document to PDF Baidu L

Analysis on axios's inability to use Vue. use (), axiosvue. use

Analysis on axios's inability to use Vue. use (), axiosvue. use Preface I have encountered some problems in using axios recently. I feel it is necessary to share with you the basic knowledge about axios. For details, refer to this article: how to get started with axios, I won't talk much about it below. Let's take a look at the detailed introduction. Problem I be

Teach you how to use start uml to draw Use Case Diagrams and uml use cases

Teach you how to use start uml to draw Use Case Diagrams and uml use cases I have recently prepared to study volley's source code, but I have read some blogs on the Internet. They all work with the diagram. This looks more intuitive and the analysis logic is also good, what kind of diagrams can clearly analyze the relationships between various types and how to ex

Step 3: Use spring to develop osgi -- (step 2: Engineering) Step 3: Use spring to develop osgi -- (step 1: Environment) step 3: Use spring to develop osgi -- (step 2: Engineering)

The STS and Virgo environments have been configured above, and the Virgo server can be successfully run. Next we will use STS to build several projects. We simulate an example of registration. In our actual case, data is sometimes written to the database, written to a file, or written to the memory, which is convenient for different operations. This example may not completely explain the problem, but it is enough to explain how to build a project th

Step 3: Use spring to develop osgi -- (Step 3: Web) Step 3: Use spring to develop osgi -- (step 1: Environment) step 3: Use spring to develop osgi -- (step 2: Engineering)

Next we will create a web project. For simplicity, We will directly use the template in Virgo to create a new project. The control layer uses spring MVC 3.Create a WEB Project Open STS and create a project. Select sprinng template project. Figure: Create a spring template project Select spring MVC Project Figure: Template Selection Enter the project name and package name. Figure: Enter the project name and package name Click Finish. You m

JS three ways to use/css three ways to use the DOM event model in/js/js the writing of anonymous functions and the invocation/media query @media three ways to use

First, JS three ways to use 1, HTML tag embedded JS (do not promote the use of. )2, the HTML page directly using JS:3, reference external JS file: Ii. three ways to use CSS 1, inline style sheet: Directly in the HTML start tag using style= "" Way reference;Features: The CSS code and HTML code is completely melted together, do

Do I have to use Tomcat to use Jenkins? Can I use only nginx?

Do I have to use Tomcat to use Jenkins? Can I use only nginx? Used to deploy the php project. Do I have to use Tomcat to use Jenkins? Can I use only nginx? Used to deploy the php project. Reply content: Do I have to

How to use modal pop-up window in Yii2 (basic use), yii2 use modal pop-up window _ PHP Tutorial

How to use the modal pop-up window (basically used) in Yii2, yii2 uses the modal pop-up window. In Yii2, how to use modal pop-up windows (basically used), yii2 uses modal pop-up windows Modal, that is, modal windows. In other words, it is pop-up windows. Is a js plug-in for bootstrap, and the use effect is also very good. How to

Similar to Baidu Library solution (iv) -- use JODConverter to call OpenOffice.org service to convert the document into a PDF. Use Jacob to call MS Office to convert the document into a PDF file. Use JCom to call MS Offic.

Directory Baidu Library solution (I)-Overall Thinking Baidu Library solution (2) -- use Jacob to call MS Office to convert the document to PDF Baidu Library solution (3) -- use JCom to call MS Office or Acrobat API to convert the document to PDF Similar to Baidu Library solution (4) -- use JODConverter to call OpenOffice.org to convert the document to PDF Baidu L

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.