filmov
tv
Append Value to Vector in R (4 Examples) | Add New Data Element | c() & append() Functions
![preview_player](https://i.ytimg.com/vi/9mbNMaHaeCM/maxresdefault.jpg)
Показать описание
R code of this video:
x <- rep("a", 5) # Create example vector
x
x1 <- c(x, "b") # c() function
x1
x2 <- append(x, "b") # append() function
x2
x3 <- x # Replicate input vector
x3[length(x3) + 1] <- "b" # Add value at last position
x3
x_empty <- character() # Create empty character vector
x_empty
x_empty1 <- c(x_empty, "b") # Add value to empty vector
x_empty1
x <- rep("a", 5) # Create example vector
x
x1 <- c(x, "b") # c() function
x1
x2 <- append(x, "b") # append() function
x2
x3 <- x # Replicate input vector
x3[length(x3) + 1] <- "b" # Add value at last position
x3
x_empty <- character() # Create empty character vector
x_empty
x_empty1 <- c(x_empty, "b") # Add value to empty vector
x_empty1