Search notes:
R function: which
which(logical_vector)
returns the indices of a logical
vector that are true:
which(c( F, T, T, F, F, F, T, F, T))
#
# 2 3 7 9
Find the longest names
The folllowing contrived example finds the longest character-string in a vector:
# find longest name:
names = c('foo', 'bar baz', 'a longer foo than all other bazes', 'bar bazed on his own foo')
names_len = nchar(names)
names[which(names_len == max(names_len))]
# [1] "a longer foo than all other bazes"
See also
match(…)
returns the index of the first element in a vector that matches a value.
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...', 1740537106, '18.222.188.129', 'Mozilla/5.0 App...', NULL)
#2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/which(62): insert_webrequest()
#3 {main}
thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78