# Vectors
{id: vectors}

## R vectors
{id: r-vectors}
{i: c}

* c stands for concatenate

![](examples/vectors/vector.R)

![](examples/vectors/vector.out)

## Variable types of vectors are deducted
{id: variable-types-of-vectors-are-deducted}

* We'll learn a lot more about vectors later

* TODO: Mixed data?

![](examples/vectors/data_types_vectors.R)

## One element vector is the same a single value
{id: one-element-vector}

![](examples/vectors/one_element_vector.R)
![](examples/vectors/one_element_vector.out)

## Sum of values in vectors
{id: sum-of-values-in-vectors}

![](examples/vectors/sum.R)

## Size of vector (length of vector)
{id: length-of-vector}

![](examples/vectors/vector_length.R)

## Access the n-the element of a vector
{id: access-the-n-the-element-of-a-vector}

* It is `some_vector[n]`
* It is 1-based

![](examples/vectors/access_vector_element.R)

## R Vector: Negative index, exclude element
{id: negative-index-exclude-element}

Using a negative index will give you the same vector without that element

![](examples/vectors/negative_index.R)

## R vector: Access several elements (slice)
{id: access-several-elements-of-a-vector}

* We can use a vector as the index of anther vector thereby fetching a new vector of the specific values.
* We can also select a range of elements using :

![](examples/vectors/several_elements.R)

## R vector: Exclude several elements
{id: exclude-several-elements-of-a-vector}

![](examples/vectors/exclude_elements.R)

## Some basic statistical functions
{id: some-basic-statistical-functions}
{i: median}
{i: sum}
{i: mean}
{i: min}
{i: max}

![](examples/vectors/statistics.R)

## 3 ways to create vectors
{id: 3-ways-to-create-vectors}
{i: c}
{i: seq}
{i: :}

![](examples/vectors/create_vectors.R)

## R - sequences and ranges
{id: r-sequences-and-ranges}
{i: seq}

![](examples/vectors/seq.R)

## Range of numbers
{id: range-of-numbers}
{i: :}

![](examples/vectors/range_of_numbers.R)



## Filter values
{id: filter-values}

![](examples/vectors/filter_values.R)
![](examples/vectors/filter.R)

## Index of true elements - which
{id: index-of-true-elements}
{i: which}

![](examples/vectors/index_of_true_elements.R)

## which
{id: which}

Showing the indexes of the elements that are TRUE in a boolean vector

![](examples/vectors/which.R)


## Matix TBD
{id: matrix}

![](examples/matrix.R)

## Vector operations - reuse values from shorter vector
{id: reuse-data-from-shorter-vector}

![](examples/vectors/reuse_short_array_exact_multiple.R)

![](examples/vectors/vector_multiplication.R)

![](examples/vectors/different_length_of_arrays.R)

## Summary of numeric data
{id: summary-of-numeric-data}
{i: summary}
{i: mean}

![](examples/vectors/summary_of_numeric.R)
![](examples/vectors/summary_of_boolean.R)
![](examples/vectors/summary_of_strings.R)

## Change element of vector
{id: change-element-of-vector}

![](examples/vectors/change_element_of_vector.R)

## Assign vector to another name
{id: assign-vector-to-another-name}

![](examples/vectors/assign_vector.R)

## Reverse vector
{id: reverse}
{i: rev}
{i: reverse}

![](examples/vectors/reverse.R)

## Sort vector
{id: sort}
{i: sort}

![](examples/vectors/sort.R)

## Sort using order
{id: order}
{i: order}

![](examples/vectors/order.R)

## Operators comparing vectors
{id: operators-comparing-vectors}

![](examples/vectors/compare_vectors_with_numbers.R)

## Convert vector of strings to numerics
{id: convert-strings-to-numerics}
{i: as.numeric}

![](examples/vectors/convert_strings_to_numeric.R)

## Repeate the same number
{id: repeate-the-same-number}
{i: rep}

![](examples/vectors/repeat_number.R)

## Boolean (logical) operations on vectors
{id: boolean-operations-on-vectors}

![](examples/vectors/boolean_vectors_truth_table.R)

![](examples/vectors/boolean.R)

## Factors
{id: factors}

* "Category", "enumerated type"

![](examples/factors.R)

![](examples/factor.R)

## Append to end of vector
{id: append-to-end-of-vector}

![](examples/vectors/append.R)

