--4-Advanced inputs and outputs
#1-Dealing with failure
#2-Creating a safe function
# Pass the readLines() function to safely(), and assign the output to safe_readLines.
# Use safe_readLines() on the string "http://example.org" to read
# the example homepage HTML file.
# Use safe_readLines() on "http://asdfasdasdkfjlda", a nonsense web address that
# shouldn't be found
install.packages("purrr")
library(purrr)
readLines<-function (con = stdin(), n = -1L, ok = TRUE, warn = TRUE,
encoding = "unknown",
skipNul = FALSE)
{
if (is.character(con)) {
con <- file(con, "r")
on.exit(close(con))
}
.Internal(readLines(con, n, ok, warn, encoding, skipNul))
}
# Create safe_readLines() by passing readLines() to safely()
safe_readLines <- safely(readLines)
safe_readLines
# Call safe_readLines() on "http://example.org"
safe_readLines("http://example.org")
safe_readLines
# Call safe_readLines() on "http://asdfasdasdkfjlda"
safe_readLines("http://asdfasdasdkfjlda")
safe_readLines#3-Using map safely
#4-Working with safe output
#5-Working with errors and results
6-Maps over multiple arguments
​Map functions in purrr ​
#7-Getting started
#8-Mapping over two arguments
#9-Mapping over more than two arguments
#10-Argument matching
#11-Mapping over functions and their arguments
#12-Maps with side effects
​Map functions in purrr ​
#13-Walk
#14-Walking over two or more arguments
#15-Putting together writing functions and walk
#16-Nice breaks for all-X
#17-Walking with many arguments: pwalk
#18-Walking with pipes
Last updated