R   Getopt::Long               Tsukuba.R #9 (2011/11/12)                               @a_bicky
parseArgs <- function() {    argv <- commandArgs(trailingOnly = TRUE)    argv <- strsplit(argv, "=")    argv <- sapply(arg...
orz
Getopt::Long
Perl                                 parseruse Getopt::Long;my $data   = "file.dat";my $length = 24;my $verbose;$result = ...
…
http://d.hatena.ne.jp/a_bicky/20111020/1319061009
http://d.hatena.ne.jp/a_bicky/20111020/1319061009
http://d.hatena.ne.jp/a_bicky/20111020/1319061009
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)GetOptions(var1=s    =   var1...
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)use Getopt::Long;GetOptions(s...
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)use Getopt::Long;GetOptions(s...
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)$ RScript getopt_long_sample....
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)
getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)
Rgetopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)                            ...
Rgetopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)                            ...
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
Upcoming SlideShare
Loading in …5
×

R版Getopt::Longを作ってみた

4,234 views

Published on

Tsukuba.R #9のLTです

Published in: Business, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,234
On SlideShare
0
From Embeds
0
Number of Embeds
2,100
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

R版Getopt::Longを作ってみた

  1. 1. R Getopt::Long Tsukuba.R #9 (2011/11/12) @a_bicky
  2. 2. parseArgs <- function() { argv <- commandArgs(trailingOnly = TRUE) argv <- strsplit(argv, "=") argv <- sapply(argv, function(arg) { ret <- ifelse(is.na(arg[2]), 1, arg[2]) names(ret) <- arg[1] return(ret) }) # show usage # Not use existsFunction because loading methods packagetakes about 60% of the startup time if ("help" %in% names(argv)) { tryCatch(usage(), error = function(e) cat("No usage forthis scriptn")) quit() } # check arguments # Not use existsFunction because loading methods packagetakes about 60% of the startup time try(checkArgs(argv), silent = TRUE) return(argv)}
  3. 3. orz
  4. 4. Getopt::Long
  5. 5. Perl parseruse Getopt::Long;my $data = "file.dat";my $length = 24;my $verbose;$result = GetOptions ("length=i" => $length, # numeric "file=s" => $data, # string "verbose" => $verbose); # flag http://search.cpan.org/~jv/Getopt-Long-2.38/lib/Getopt/Long.pmgetopt_long_sample.pluse Getopt::Long;GetOptions(save_path=s => $save_path);print "$save_pathn";$ perl getopt_long_sample.pl --save_path=hogehoge
  6. 6.
  7. 7. http://d.hatena.ne.jp/a_bicky/20111020/1319061009
  8. 8. http://d.hatena.ne.jp/a_bicky/20111020/1319061009
  9. 9. http://d.hatena.ne.jp/a_bicky/20111020/1319061009
  10. 10. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)GetOptions(var1=s = var1, # var2=i = var2, # var3=f = var3, # var4 = var4, # var5=s@ = var5, # var6=i% = var6 #)
  11. 11. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)use Getopt::Long;GetOptions(save_path=s => $save_path);print "$save_pathn";
  12. 12. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)use Getopt::Long;GetOptions(save_path=s => $save_path);print "$save_pathn";
  13. 13. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)$ RScript getopt_long_sample.R --save.path=hoge[1] "hoge"
  14. 14. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)
  15. 15. getopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path)
  16. 16. Rgetopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path) save.path# parent.framevar.names <- as.character(match.call()[-1])assign(var, ret[[var]], envir = parent.frame())
  17. 17. Rgetopt_long_sample.Rsource("GetoptLong.R")GetOptions(save.path=s = save.path)print(save.path) save.path# parent.framevar.names <- as.character(match.call()[-1])assign(var, ret[[var]], envir = parent.frame()) http://user.ecc.u-tokyo.ac.jp/~s105503/p02.html

×