# Create a temporary file with an R function definition
temp_file <- tempfile(fileext = ".R")
writeLines("example_function <- function(x) {\n return(x * 2)\n}", temp_file)
# Check if the temporary file contains an R function definition
result <- contains_r_func(temp_file)
print(result) # Should print TRUE
# Check if a character string contains an R function definition
result <- contains_r_func("example_function <- function(x) { return(x * 2) }")
print(result) # Should print TRUE
# Remove the temporary file
file.remove(temp_file)
Run the code above in your browser using DataLab