R-Language custom functions-character combinations

Source: Internet
Author: User

Several functions were written the first two days to record some of the things that were harvested inside.

The function Str_comb, which is used to enter a string or a numeric vector, returns all combinations of the non-repeating lengths of elements in the vector that are less than the length of the vector, and the results are output in matrix form.

The function uses the following result:

The idea is simple, in R there is a function combn function, can produce a specified vector in the composition of the specified length of the composition, the function is to put these combinations together, so the focus is COMBN function and loop.

But finally a more empty value, should be a stop condition out of some trouble, but I did not see it, someone willing to teach the best.

Some of the R foundations involved are:

1, choose function: Choose (x, y), the permutation of the combination of C (×, y), from the X elements of any number of Y elements of a subset, only return numeric values.

2, Combn function: Combn (x, y), × vector, Y is the length of the random combination, as follows:

3. Break statement for Interrupt loop.

4. Column-by-row combination of data frames (Cbind function)

5. Load r function File: source function

6. Load history and Data: Historical function and load function,

7. Paste Function: Character combination function

8, Ncol and Nrow functions: Returns the number of columns and rows

R-Language custom functions-character combinations

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.