Search notes:

R function: cbind

cbind() creates a matrix.
Each argument to cbind becomes a column.
# cbind stands for «column-bind». See also -> rbind

a <- 100:104
b <- 10 + 5*0:4
c <- c(17, 13, 22, 21, 18)

mat <- cbind(a, b, c)

mat
#        a  b  c
# [1,] 100 10 17
# [2,] 101 15 13
# [3,] 102 20 22
# [4,] 103 25 21
# [5,] 104 30 18

df_1 <- data.frame (
                 col_1 = c("Foo", "Bar", "Baz"),
                 col_2 = c(  11 ,   22 ,   33 ),
                 col_3 = c("abc", "def", "ghi") )

df_2 <- data.frame (
                 col_a = c("one", "two", "three"),
                 col_b = c(" X ", " Y ", " Z "  ) )


# combine by columns

df_3 <- cbind(df_1, df_2)

df_3
#   col_1 col_2 col_3 col_a col_b
# 1   Foo    11   abc   one    X
# 2   Bar    22   def   two    Y
# 3   Baz    33   ghi three    Z
Github repository about-r, path: /functions/cbind.R

See also

rbind
Index to (some) R functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201476, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/cbind(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78