Categories:
Cloud (204)
Entertainment (11)
Facebook (43)
General (50)
Life (31)
Programming (64)
Technology (430)
Testing (4)
Tools (488)
Twitter (5)
Wearable (26)
Web Design (44)
Collections:
Other Resources:
Data Structure - Vector
What is data structure "Vector"?
✍: FYIcenter.com
Vector is a special data structure that
represents a sequence of data elements of the same data type.
A vector is an array in many other programming language.
1. Create a vector object with the c() function -
> v = c("Apple", "Banana", "Orange")
> print(v)
[1] "Apple" "Banana" "Orange"
> is.vector(v)
[1] TRUE
2. Get vector length and members - Remember that member indexes start from 1.
> v = c("Apple", "Banana", "Orange")
> length(v)
[1] 3
> v[1]
[1] "Apple"
3. Get a sub-set of a vector -
> v = c("Apple", "Banana", "Orange")
> v[2:3] # specifies a range
[1] "Banana" "Orange"
> v[-2] # specifies the end backward
[1] "Apple" "Orange"
> v[ c(2,3,2,3) ] # specifies a list of members
[1] "Banana" "Orange" "Banana" "Orange"
2023-06-11, 999🔥, 0💬
Popular Posts:
What contents are stored in a Web Archive (.mht) file? When you convert a word document into a singl...
How to unzip a PowerPoint .pptx file? According to Microsoft documentation, a .pptx file is really a...
How to convert slide files created with older versions of PowerPoint to the current PowerPoint? I ha...
Is Tahoma font supported on iPhone, iPad and other Apple devices? The answer is no. Tahoma font is n...
How to convert a Word document into an MHTML? I have a nice Word document and want to publish it on ...