Skip to content

Commit

Permalink
changed to csv
Browse files Browse the repository at this point in the history
  • Loading branch information
oduerr committed May 27, 2024
1 parent 21f0c86 commit 826d2a3
Show file tree
Hide file tree
Showing 5 changed files with 14,545 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ data/challenger_files/figure-html/plot_data-1.png
R/edudat/man/load_data.Rd
*.Rproj
edudat_0.1.tar.gz
/test_excercise_local
64 changes: 41 additions & 23 deletions R/edudat/R/quarto_related.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ show_code <- function(df) {
#' attributes = attributes(df)
#' show_loading(attributes(df))
#' ```
show_loading <- function(attributes) {
r_code <- sprintf("df <- read.csv(\"%s\", stringsAsFactors = FALSE)", attributes$download_url)
show_loading <- function(attributes, show_python = FALSE) {
r_code <- sprintf("df <- read.csv(\"%s\")", attributes$download_url)
r_code2 <- sprintf("df <- edudat::load_data(\"%s\")", attributes$source)
py_code <- sprintf("df = pd.read_csv(\"%s\")", attributes$download_url)

if (knitr::is_html_output()) {
cat(
Expand All @@ -50,26 +49,45 @@ show_loading <- function(attributes) {
sep = ""
)
} else if (knitr::is_latex_output()) {
cat(
"\\begin{framed}\n",
"Loading: \\newline \n",
"\\footnotesize\n", # Make the text smaller
"Copy and Paste this code to load the data into R:\n\n",
"\\begin{verbatim}\n",
r_code,
"\n\\end{verbatim}\n\n",
"Using the edudat package (see https://github.com/tensorchiefs/data/):\n\n",
"\\begin{verbatim}\n",
r_code2,
"\n\\end{verbatim}\n\n",
"Copy and Paste this code to load the data into Python (need pandas as pd):\n\n",
"\\begin{verbatim}\n",
py_code,
"\n\\end{verbatim}\n",
"\\end{framed}\n",
sep = ""
)
} else {
if (show_python) {
cat(
"\\begin{framed}\n",
"Loading: \\newline \n",
"\\footnotesize\n", # Make the text smaller
"Copy and Paste this code to load the data into R:\n\n",
"\\begin{verbatim}\n",
r_code,
"\n\\end{verbatim}\n\n",
"Using the edudat package (see https://github.com/tensorchiefs/data/):\n\n",
"\\begin{verbatim}\n",
r_code2,
"\n\\end{verbatim}\n\n",
"Copy and Paste this code to load the data into Python (need pandas as pd):\n\n",
"\\begin{verbatim}\n",
py_code,
"\n\\end{verbatim}\n",
"\\end{framed}\n",
sep = ""
)
}else {
cat(
"\\begin{framed}\n",
"Loading: \\newline \n",
"\\footnotesize\n", # Make the text smaller
"Copy and Paste this code to load the data into R:\n\n",
"\\begin{verbatim}\n",
r_code,
"\n\\end{verbatim}\n\n",
"Using the edudat package (see https://github.com/tensorchiefs/data/):\n\n",
"\\begin{verbatim}\n",
r_code2,
"\n\\end{verbatim}\n\n",
"\\end{framed}\n",
sep = ""
)
}#Phython
} #Latex
else {
cat("Output format not supported.")
}
}
Expand Down
Loading

0 comments on commit 826d2a3

Please sign in to comment.