R Language 6th day 128 page __r language

Source: Internet
Author: User

1 adding a single data to a vector

> v <-C (v,newitems)

It can also be set to the next element of the vector v[length (v) +1] <-NewItem

2 is very slow with append.

3 When you add a lot of data to a vector

With append function > Append (VEC, NewValues, After=n)

4 1:6 1:3 (1:6) + (1:3)

1 1 2

2 2 4

3 3 6

4 1 5

5 2 7

6 3 9

5 Creating a column vector with the Cbind function

6 Creating a factor

Using the Factor function

> F <-Factor (V,levels) # V is a vector of strings or integers

> F <-Factor (Wday, C ("Mon", "Tue", "Wed", "Thu", "Fri"))

7 combining multiple vectors with a stack function to synthesize a dataframe

> Comb <-Stack (list (V1=V1, V2=v2, V3=v3)) # Combine 3 vectors

8 Build a list

The list can contain different data types

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.