Search notes:

R function: dim

Sets or return the dimension attribute of an object.
#
#    S.a. ../examples/having_a_look_at_data.R
#


dataFrame <- data.frame (
               col_1 = c("Foo", "Bar", "Baz"),
               col_2 = c(  11 ,   22 ,   33 ))

dim(dataFrame)
# [1] 3 2


#
#  dim can also be used to set or chagne the dimension:

a <- 1:50
dim(a) <- c(10, 5)
a
# 
#       [,1] [,2] [,3] [,4] [,5]
#  [1,]    1   11   21   31   41
#  [2,]    2   12   22   32   42
#  [3,]    3   13   23   33   43
#  [4,]    4   14   24   34   44
#  [5,]    5   15   25   35   45
#  [6,]    6   16   26   36   46
#  [7,]    7   17   27   37   47
#  [8,]    8   18   28   38   48
#  [9,]    9   19   29   39   49
# [10,]   10   20   30   40   50
Github repository about-r, path: /functions/dim/dim.R

dim() applied on a vector

dim() applied on a vector returns NULL.
v <- c( 1, 1, 2, 3, 5, 8 );
dim(v);
#
#  NULL
Github repository about-r, path: /functions/dim/vector.R

See also

Exploring R objects
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...', 1743241458, '18.218.189.36', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/dim(87): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78