Search notes:

R function: gl

gl creates factors:
f_1 <- gl(3, 4);

class(f_1);
#
# "factor"

as.numeric(f_1);
#
# 1 1 1 1 2 2 2 2 3 3 3 3

# ------------------------------------------------------------------------

f_2 <- gl(3, 4, labels = c('foo', 'bar', 'baz'));

as.character(f_2);
#
# "foo" "foo" "foo" "foo" "bar" "bar" "bar" "bar" "baz" "baz" "baz" "baz"

# ------------------------------------------------------------------------

f_3 <- gl(2, 1, length = 8, labels=c('yes', 'no'));

as.character(f_3);
#
# "yes" "no"  "yes" "no"  "yes" "no"  "yes" "no"
Github repository about-R, path: /functions/gl.R

See also

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