You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swirl《Programming E》练习9报错:无法找到函数‘func’求助

Troubleshooting "could not find function 'func'" in Swirl's Programming E Exercise 9

Hey there! I’ve run into similar head-scratching issues with Swirl exercises before—those "function not found" errors can feel frustrating, but let’s walk through some practical fixes:

  • Make sure you’re in the right Swirl exercise context
    Swirl loads exercise-specific functions only when you’re actively in that section. If you switched away or restarted Swirl mid-exercise, try exiting with quit() (when prompted, you can skip saving the workspace if you’re unsure), then relaunch Swirl with swirl(), reselect Programming E, and pick up at exercise 9 again. This ensures the exercise’s custom functions are loaded properly.

  • Check if you skipped defining func in an earlier step
    Sometimes Swirl expects you to write the func function yourself in prior exercise prompts. If you rushed past that step, the function won’t exist in your workspace. Go back a few prompts (you can use skip() if needed, but it’s better to redo the definition step) and make sure you ran code like this:

    func <- function(dat) {
      # Your code here as per the exercise instructions
    }
    

    After defining it, run ls() in the console to confirm func shows up in your workspace.

  • Watch for typos and case sensitivity
    R is strict about case and spelling! Double-check that you’re typing func(dat) exactly as the exercise specifies—no capital letters (like Func), extra characters, or misspellings. Even a tiny typo will trigger that error.

  • Restart your entire R session
    Occasionally, R’s workspace can get cluttered or have caching issues that block Swirl from loading functions correctly. Close R/RStudio entirely, reopen it, launch Swirl, and try the exercise again. This clears any leftover cruft that might be causing problems.

If none of these work, re-read the exercise prompt closely—sometimes Swirl uses slightly different function names than you might assume, so make sure you’re following the instructions to the letter.

内容的提问来源于stack exchange,提问作者Katherine Stolin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:02:34