差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| r:set.proxy [2022/05/21 09:38] – watalu | r:set.proxy [2022/05/21 10:04] (現在) – watalu | ||
|---|---|---|---|
| 行 3: | 行 3: | ||
| set.proxy = function(proxy) { | set.proxy = function(proxy) { | ||
| if( is.list(proxy) ) { | if( is.list(proxy) ) { | ||
| + | if(length(setdiff(names(proxy), | ||
| Sys.setenv(" | Sys.setenv(" | ||
| Sys.setenv(" | Sys.setenv(" | ||
| Sys.setenv(" | Sys.setenv(" | ||
| return(TRUE) | return(TRUE) | ||
| + | } else { | ||
| + | return(FALSE) | ||
| + | } | ||
| } else if (is.vector(proxy)) { | } else if (is.vector(proxy)) { | ||
| if( length(proxy) == 3 ) { | if( length(proxy) == 3 ) { | ||
| 行 13: | 行 17: | ||
| Sys.setenv(" | Sys.setenv(" | ||
| return(TRUE) | return(TRUE) | ||
| - | } else if (is.vector) { | + | } else if (is.character(proxy[1])) { |
| - | | + | Sys.setenv(" |
| - | Sys.setenv(" | + | Sys.setenv(" |
| - | Sys.setenv(" | + | Sys.setenv(" |
| - | Sys.setenv(" | + | return(TRUE) |
| - | return(TRUE) | + | } else { |
| - | } else { | + | return(FALSE) |
| - | return(FALSE) | + | |
| - | } | + | |
| } | } | ||
| } else if (is.character(proxy)) { | } else if (is.character(proxy)) { | ||
| 行 35: | 行 37: | ||
| 使用法は次のとおり。 | 使用法は次のとおり。 | ||
| < | < | ||
| - | set.proxy(c(" | + | set.proxy(list(http=" |
| + | https=" | ||
| + | ftp=" | ||
| + | </ | ||
| + | < | ||
| + | set.proxy(c(" | ||
| + | | ||
| + | | ||
| </ | </ | ||
| < | < | ||
| set.proxy(" | set.proxy(" | ||
| </ | </ | ||
| + | プロキシの設定を解除する関数も一緒に用意しておく。 | ||
| + | < | ||
| + | unset.proxy = function() { | ||
| + | Sys.setenv(" | ||
| + | Sys.setenv(" | ||
| + | Sys.setenv(" | ||
| + | } | ||
| + | </ | ||
| + | この関数の使い方は、引数なし。 | ||
| + | < | ||
| + | unset.proxy() | ||
| + | </ | ||
| + | |||