我正在尝试编写一个脚本,从字符向量安装包,如下所示:
import WebKit
import UIKit
class ViewController: UIViewController, WKNavigationDelegate {
var webView: WKWebView!
override func loadView() {
webView = WKWebView()
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: "https://hackingswift.com")!
webView.load(URLRequest(url:url))
webView.allowsBackForwardNavigationGestures = true
}
}
当它读取行packages <- c("data.table", "dplyr", "tidyr")
for (i in seq_along(packages)) {
if (is.na(match(i, rownames(installed.packages()))) == TRUE )
{ install.packages(i)
}
library(i)
}
时,它会显示错误:
库(i)中的错误:没有名为'i'的包
任何人都可以帮我揭开它为什么不将library(i)
元素识别为循环的一部分?