Search notes:

R function: tempfile

# tempfile() does not generate a file, it returns
# the name for a usable file:
temp_file_name <- tempfile()

file_handle <- file(temp_file_name)

cat("\nWriting to ", temp_file_name, '\n')
writeLines(c('first line', "second line"), file_handle)

cat("\nshowing content of file:\n")
file.show(temp_file_name)

cat("\n\nGoing to sleep for a few seconds so that")
cat("\nthe content of the file can be checked.")
cat("\nThe file will be destroyed after the script finishes")
Sys.sleep(20)

close(file_handle)
Github repository about-r, path: /functions/tempfile.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...', 1758201006, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/tempfile(56): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78