Test
## ── Attaching packages ─────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0 ✔ purrr 0.2.5
## ✔ tibble 2.0.1 ✔ dplyr 0.7.8
## ✔ tidyr 0.8.2 ✔ stringr 1.3.1
## ✔ readr 1.3.1 ✔ forcats 0.3.0
## Warning: package 'tibble' was built under R version 3.5.2
## ── Conflicts ────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ readr::guess_encoding() masks rvest::guess_encoding()
## ✖ dplyr::lag() masks stats::lag()
## ✖ purrr::pluck() masks rvest::pluck()
iphone_links <- "03_bookmarks_temp.Rmd"
remove_md <- function(str) {
if (substr(str, 1, 1) == "[") {
str = substr(str, 2, nchar(str))
}
if (substr(str, nchar(str), nchar(str)) == ")") {
str = substr(str, 1, nchar(str) - 1)
}
return(str)
}
test <- read_lines(iphone_links, skip = 10, n_max = 1000)
test_file <- "test2.Rmd"
if(length(test) > 0) {
test <- test %>%
as_tibble() %>%
filter(value != "") %>%
mutate(test1 = remove_md(value)) %>%
separate(test1, into = c("label", "url"), sep = "\\]\\(") %>%
distinct() %>%
arrange(value) %>%
select(value) %>%
rename(`# value` = value) %>%
pull()
}
## Warning: Calling `as_tibble()` on a vector is discouraged, because the behavior is likely to change in the future. Use `enframe(name = NULL)` instead.
## This warning is displayed once per session.
## Warning in if (substr(str, 1, 1) == "[") {: the condition has length > 1
## and only the first element will be used
## Warning in if (substr(str, nchar(str), nchar(str)) == ")") {: the condition
## has length > 1 and only the first element will be used
## Warning: Expected 2 pieces. Missing pieces filled with `NA` in 1 rows [68].
#
# test %>%
# distinct(url)
test %>%
paste(collapse = "\n\n\n") %>%
paste("#test n stuff\n\n\n", .) %>%
write_file(test_file)
Test stuff