これはただのラッパー。 set.proxy = function(proxy) { if( is.list(proxy) ) { if(length(setdiff(names(proxy), c("http", "https", "ftp"))) == 0 ) { Sys.setenv("http_proxy"=proxy$http) Sys.setenv("https_proxy"=proxy$https) Sys.setenv("ftp_proxy"=proxy$ftp) return(TRUE) } else { return(FALSE) } } else if (is.vector(proxy)) { if( length(proxy) == 3 ) { Sys.setenv("http_proxy"=proxy[1]) Sys.setenv("https_proxy"=proxy[2]) Sys.setenv("ftp_proxy"=proxy[3]) return(TRUE) } else if (is.character(proxy[1])) { Sys.setenv("http_proxy"=proxy[1]) Sys.setenv("https_proxy"=proxy[1]) Sys.setenv("ftp_proxy"=proxy[1]) return(TRUE) } else { return(FALSE) } } else if (is.character(proxy)) { Sys.setenv("http_proxy"=proxy) Sys.setenv("https_proxy"=proxy) Sys.setenv("ftp_proxy"=proxy) return(TRUE) } return(FALSE) } 使用法は次のとおり。 set.proxy(list(http="http://proxy.uec.ac.jp:8080", https="http://proxy.uec.ac.jp:8080", ftp="http://proxy.uec.ac.jp:8080")) set.proxy(c("http://proxy.uec.ac.jp:8080", "http://proxy.uec.ac.jp:8080", "http://proxy.uec.ac.jp:8080")) set.proxy("http://proxy.uec.ac.jp:8080") プロキシの設定を解除する関数も一緒に用意しておく。 unset.proxy = function() { Sys.setenv("http_proxy") Sys.setenv("https_proxy") Sys.setenv("ftp_proxy") } この関数の使い方は、引数なし。 unset.proxy()