Skip to contents

It executes the function fun by first switching directories temporarily to the folder folder and then returning to the working directory.

Usage

fun_from_folder(folder, fun, ...)

Arguments

folder

The folder of execution that the function is switched to before executing fun

fun

Function to be executed from the relative path

...

Options to be passed to fun

Value

The return value of fun(...)

Examples

list.files()
#>  [1] "CompileDocument.html"           "CompileLatexDir.html"          
#>  [3] "ConstructAnswerSheet.html"      "CountNumberOfSections.html"    
#>  [5] "CreateRandomExams.html"         "DivideFile.html"               
#>  [7] "FindExamAnswers.html"           "FindMatchingRow.html"          
#>  [9] "FindStructure.html"             "GenerateHomework.html"         
#> [11] "GenerateShortAnswerSheet.html"  "GetLayerSampleIndexes.html"    
#> [13] "GradeExams.html"                "IsWellSectioned.html"          
#> [15] "ObtainExamStats.html"           "ParsePreambleForOptions.html"  
#> [17] "RandomizeDocument.html"         "ReplaceFromTable.html"         
#> [19] "ReplacePreambleCommand.html"    "Rplot001.png"                  
#> [21] "StructureDocument.html"         "SubsetWithAtributes.html"      
#> [23] "TexExamRandomizer-package.html" "WhichAnswerOriginal.html"      
#> [25] "catDocument.html"               "compilation_options.html"      
#> [27] "compile_latex_directory.html"   "index.html"                    
fun_from_folder(system.file("data", package = "TexExamRandomizer"), list.files)
#> [1] "Rdata.rdb" "Rdata.rds" "Rdata.rdx"
list.files()
#>  [1] "CompileDocument.html"           "CompileLatexDir.html"          
#>  [3] "ConstructAnswerSheet.html"      "CountNumberOfSections.html"    
#>  [5] "CreateRandomExams.html"         "DivideFile.html"               
#>  [7] "FindExamAnswers.html"           "FindMatchingRow.html"          
#>  [9] "FindStructure.html"             "GenerateHomework.html"         
#> [11] "GenerateShortAnswerSheet.html"  "GetLayerSampleIndexes.html"    
#> [13] "GradeExams.html"                "IsWellSectioned.html"          
#> [15] "ObtainExamStats.html"           "ParsePreambleForOptions.html"  
#> [17] "RandomizeDocument.html"         "ReplaceFromTable.html"         
#> [19] "ReplacePreambleCommand.html"    "Rplot001.png"                  
#> [21] "StructureDocument.html"         "SubsetWithAtributes.html"      
#> [23] "TexExamRandomizer-package.html" "WhichAnswerOriginal.html"      
#> [25] "catDocument.html"               "compilation_options.html"      
#> [27] "compile_latex_directory.html"   "index.html"