Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve .Rprofile template and add vignette for create_project() #86

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions R/create_project.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,20 +321,43 @@ create_project <- function(
file.create(paste0(path, "/.Rprofile"))
}
rprofile_content <- paste(
"# ---------------------------------------------------------",
"# This is the .Rprofile file",
"#",
"# Use it to include any functions you want to run before any other code",
"# is run.",
"# For example, using renv automatically sources its activate script to",
"# the .RProfile file",
"# This ensures that all renv checks on package versions happens before",
"# any code is run.",
"#",
"# ---------------------------------------------------------",
"",
"message('Sourcing .Rprofile..')",
"",
"source('renv/activate.R')",
"",
"# Welcome message",
".First <- function() {",
"if ('praise' %in% installed.packages()) {",
" message(praise::praise('${Exclamation}-${Exclamation}! '),",
" 'Welcome to your dfeR project.\\n',",
" praise::praise('Time for some ${adjective} R coding...'))",
" # Check if praise installed",
" if (system.file(package = 'praise') != '') {",
" welcome_msg <- message(",
" '\\n',",
" praise::praise('${Exclamation}-${Exclamation}! '),",
" 'Welcome to your dfeR project.\\n',",
" praise::praise('Time for some ${adjective} R coding...')",
" )",
"",
" welcome_msg",
" } else {",
" message('Welcome to your dfeR project!\\n',",
" message('\\n',",
" 'Welcome to your dfeR project!\\n',",
" 'To finish setting up renv, please do the following:\\n\\n',",
" '- Run `renv::snapshot()`\\n',",
" '- Select `2: Install the packages, then snapshot.`\\n',",
" '- Finally type `y` to `Do you want to proceed?`\\n')",
" }",
"}",
"source('renv/activate.R')",
sep = "\n"
)
writeLines(rprofile_content, paste0(path, "/.Rprofile"))
Expand Down