-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectors.Rmd
More file actions
92 lines (67 loc) · 1.18 KB
/
Copy pathVectors.Rmd
File metadata and controls
92 lines (67 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: "Vectors"
author: "Javier Patron"
date: "2022-08-03"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
library(palmerpenguins)
```
## Making some Vectors
```{r}
marmots <- c("blue", "green", 4, "yellow")
# Check for class
class(marmots)
```
# Make another animal
```{r}
pika <- c(12.4, 6.8, 2.9, 8.8, 8.5)
class(pika)
##--## Scalar Multiplier
scale_for_pika <- 5.2 * pika
scale_for_pika
```
### More Examples
```{r}
bananas <- c(1,2,3)
apples <- c(6,7,8)
#Multiplication
bananas*apples
#Sum
bananas + apples
#Resting
bananas - apples
#Dot Product
bananas %*% apples
```
### Sequences
Term is seq()
## Sintax
seq(a,b,c)
a= from
b= to
c= several stuff like (length=#, by=#)
```{r}
seq
```
### Matrices
# Term is matrix
##Sintax
# matrix(a,b,c,d)
# a -> data = (What do you wanna put in the matrix)
# b -> nrow = # (number of rows)
# c -> ncol = # (number of columns)
# d -> byrow = Boolean (If you want to put the data by columns (FALSE), or by rows (TRUE))
```{r}
my_values <- seq(1,10)
my_values
my_matrix <- matrix(data = my_values, nrow=2, ncol = 5, byrow=FALSE)
my_matrix
```
```{r}
glimpse(penguins)
```