sciruby 0.1.3 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/CHANGES +3 -0
  4. data/CONTRIBUTING.md +46 -0
  5. data/Gemfile +34 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.rdoc +28 -0
  8. data/lib/sciruby/gems.rb +27 -0
  9. data/lib/sciruby/version.rb +3 -0
  10. data/lib/sciruby.rb +2 -77
  11. data/sciruby.gemspec +35 -0
  12. metadata +51 -413
  13. data/.autotest +0 -23
  14. data/.gemtest +0 -0
  15. data/History.txt +0 -6
  16. data/Manifest.txt +0 -119
  17. data/Rakefile +0 -178
  18. data/bin/sciruby-plotter +0 -12
  19. data/data/r/man/AirPassengers.Rd +0 -51
  20. data/data/r/man/BJsales.Rd +0 -34
  21. data/data/r/man/BOD.Rd +0 -53
  22. data/data/r/man/ChickWeight.Rd +0 -68
  23. data/data/r/man/DNase.Rd +0 -63
  24. data/data/r/man/EuStockMarkets.Rd +0 -28
  25. data/data/r/man/Formaldehyde.Rd +0 -44
  26. data/data/r/man/HairEyeColor.Rd +0 -77
  27. data/data/r/man/Harman23.cor.Rd +0 -25
  28. data/data/r/man/Harman74.cor.Rd +0 -28
  29. data/data/r/man/Indometh.Rd +0 -57
  30. data/data/r/man/InsectSprays.Rd +0 -45
  31. data/data/r/man/JohnsonJohnson.Rd +0 -37
  32. data/data/r/man/LakeHuron.Rd +0 -27
  33. data/data/r/man/LifeCycleSavings.Rd +0 -54
  34. data/data/r/man/Loblolly.Rd +0 -56
  35. data/data/r/man/Nile.Rd +0 -78
  36. data/data/r/man/Orange.Rd +0 -57
  37. data/data/r/man/OrchardSprays.Rd +0 -62
  38. data/data/r/man/PlantGrowth.Rd +0 -39
  39. data/data/r/man/Puromycin.Rd +0 -84
  40. data/data/r/man/Theoph.Rd +0 -84
  41. data/data/r/man/Titanic.Rd +0 -73
  42. data/data/r/man/ToothGrowth.Rd +0 -40
  43. data/data/r/man/UCBAdmissions.Rd +0 -68
  44. data/data/r/man/UKDriverDeaths.Rd +0 -72
  45. data/data/r/man/UKLungDeaths.Rd +0 -40
  46. data/data/r/man/UKgas.Rd +0 -25
  47. data/data/r/man/USAccDeaths.Rd +0 -23
  48. data/data/r/man/USArrests.Rd +0 -45
  49. data/data/r/man/USJudgeRatings.Rd +0 -38
  50. data/data/r/man/USPersonalExpenditure.Rd +0 -33
  51. data/data/r/man/VADeaths.Rd +0 -51
  52. data/data/r/man/WWWusage.Rd +0 -41
  53. data/data/r/man/WorldPhones.Rd +0 -40
  54. data/data/r/man/ability.cov.Rd +0 -50
  55. data/data/r/man/airmiles.Rd +0 -29
  56. data/data/r/man/airquality.Rd +0 -56
  57. data/data/r/man/anscombe.Rd +0 -62
  58. data/data/r/man/attenu.Rd +0 -66
  59. data/data/r/man/attitude.Rd +0 -48
  60. data/data/r/man/austres.Rd +0 -22
  61. data/data/r/man/beavers.Rd +0 -73
  62. data/data/r/man/cars.Rd +0 -59
  63. data/data/r/man/chickwts.Rd +0 -47
  64. data/data/r/man/co2.Rd +0 -43
  65. data/data/r/man/crimtab.Rd +0 -129
  66. data/data/r/man/datasets-package.Rd +0 -24
  67. data/data/r/man/discoveries.Rd +0 -30
  68. data/data/r/man/esoph.Rd +0 -66
  69. data/data/r/man/euro.Rd +0 -56
  70. data/data/r/man/eurodist.Rd +0 -25
  71. data/data/r/man/faithful.Rd +0 -63
  72. data/data/r/man/freeny.Rd +0 -56
  73. data/data/r/man/infert.Rd +0 -56
  74. data/data/r/man/iris.Rd +0 -62
  75. data/data/r/man/islands.Rd +0 -29
  76. data/data/r/man/lh.Rd +0 -22
  77. data/data/r/man/longley.Rd +0 -56
  78. data/data/r/man/lynx.Rd +0 -33
  79. data/data/r/man/morley.Rd +0 -50
  80. data/data/r/man/mtcars.Rd +0 -44
  81. data/data/r/man/nhtemp.Rd +0 -30
  82. data/data/r/man/nottem.Rd +0 -30
  83. data/data/r/man/occupationalStatus.Rd +0 -44
  84. data/data/r/man/precip.Rd +0 -31
  85. data/data/r/man/presidents.Rd +0 -36
  86. data/data/r/man/pressure.Rd +0 -41
  87. data/data/r/man/quakes.Rd +0 -40
  88. data/data/r/man/randu.Rd +0 -46
  89. data/data/r/man/rivers.Rd +0 -21
  90. data/data/r/man/rock.Rd +0 -34
  91. data/data/r/man/sleep.Rd +0 -51
  92. data/data/r/man/stackloss.Rd +0 -77
  93. data/data/r/man/state.Rd +0 -80
  94. data/data/r/man/sunspot.month.Rd +0 -49
  95. data/data/r/man/sunspot.year.Rd +0 -26
  96. data/data/r/man/sunspots.Rd +0 -33
  97. data/data/r/man/swiss.Rd +0 -79
  98. data/data/r/man/treering.Rd +0 -38
  99. data/data/r/man/trees.Rd +0 -48
  100. data/data/r/man/uspop.Rd +0 -27
  101. data/data/r/man/volcano.Rd +0 -31
  102. data/data/r/man/warpbreaks.Rd +0 -56
  103. data/data/r/man/women.Rd +0 -40
  104. data/data/r/man/zCO2.Rd +0 -81
  105. data/lib/ext/csv.rb +0 -22
  106. data/lib/ext/shoes.rb +0 -131
  107. data/lib/ext/string.rb +0 -39
  108. data/lib/sciruby/analysis/suite.rb +0 -87
  109. data/lib/sciruby/analysis/suite_report_builder.rb +0 -44
  110. data/lib/sciruby/analysis.rb +0 -98
  111. data/lib/sciruby/config.rb +0 -93
  112. data/lib/sciruby/data/guardian.rb +0 -96
  113. data/lib/sciruby/data/r/base.rb +0 -110
  114. data/lib/sciruby/data/r/data_frame.rb +0 -24
  115. data/lib/sciruby/data/r/grouped_data.rb +0 -7
  116. data/lib/sciruby/data/r/list.rb +0 -20
  117. data/lib/sciruby/data/r/multi_time_series.rb +0 -24
  118. data/lib/sciruby/data/r/r_matrix.rb +0 -7
  119. data/lib/sciruby/data/r/time_series.rb +0 -19
  120. data/lib/sciruby/data/r/time_series_base.rb +0 -40
  121. data/lib/sciruby/data/r/vector.rb +0 -125
  122. data/lib/sciruby/data/r.rb +0 -155
  123. data/lib/sciruby/data.rb +0 -168
  124. data/lib/sciruby/editor.rb +0 -82
  125. data/lib/sciruby/plotter.rb +0 -128
  126. data/lib/sciruby/recommend.rb +0 -70
  127. data/lib/sciruby/validation.rb +0 -368
  128. data/readme.md +0 -75
  129. data/static/sciruby-icon.png +0 -0
  130. data/test/helpers_tests.rb +0 -58
  131. data/test/test_recommend.rb +0 -16
data/data/r/man/swiss.Rd DELETED
@@ -1,79 +0,0 @@
1
- % File src/library/datasets/man/swiss.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{swiss}
7
- \docType{data}
8
- \alias{swiss}
9
- \title{Swiss Fertility and Socioeconomic Indicators (1888) Data}
10
- \description{
11
- Standardized fertility measure and socio-economic indicators for each
12
- of 47 French-speaking provinces of Switzerland at about 1888.
13
- }
14
- \usage{swiss}
15
- \format{
16
- A data frame with 47 observations on 6 variables, \emph{each} of which
17
- is in percent, i.e., in \eqn{[0, 100]}.
18
-
19
- \tabular{rll}{
20
- [,1] \tab Fertility \tab \eqn{I_g}{Ig}, \sQuote{common standardized
21
- fertility measure}\cr
22
- [,2] \tab Agriculture\tab \% of males involved in agriculture
23
- as occupation\cr
24
- [,3] \tab Examination\tab \% draftees receiving highest mark
25
- on army examination\cr
26
- [,4] \tab Education \tab \% education beyond primary school for draftees.\cr
27
- [,5] \tab Catholic \tab \% \sQuote{catholic} (as opposed to \sQuote{protestant}).\cr
28
- [,6] \tab Infant.Mortality\tab live births who live less than 1
29
- year.
30
- }
31
-
32
- All variables but \sQuote{Fertility} give proportions of the
33
- population.
34
- }
35
- \details{
36
- (paraphrasing Mosteller and Tukey):
37
-
38
- Switzerland, in 1888, was entering a period known as the
39
- \emph{demographic transition}; i.e., its fertility was beginning to
40
- fall from the high level typical of underdeveloped countries.
41
-
42
- The data collected are for 47 French-speaking \dQuote{provinces} at
43
- about 1888.
44
-
45
- Here, all variables are scaled to \eqn{[0, 100]}, where in the
46
- original, all but \code{"Catholic"} were scaled to \eqn{[0, 1]}.
47
- }
48
- \source{
49
- Project \dQuote{16P5}, pages 549--551 in
50
-
51
- Mosteller, F. and Tukey, J. W. (1977)
52
- \emph{Data Analysis and Regression: A Second Course in Statistics}.
53
- Addison-Wesley, Reading Mass.
54
-
55
- indicating their source as
56
- \dQuote{Data used by permission of Franice van de Walle. Office of
57
- Population Research, Princeton University, 1976. Unpublished data
58
- assembled under NICHD contract number No 1-HD-O-2077.}
59
- }
60
- \references{
61
- Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
62
- \emph{The New S Language}.
63
- Wadsworth & Brooks/Cole.
64
- }
65
- \note{
66
- Files for all 182 districts in 1888 and other years have been available at
67
- \url{http://opr.princeton.edu/archive/eufert/switz.html} or
68
- \url{http://opr.princeton.edu/archive/pefp/switz.asp}.
69
-
70
- They state that variables \code{Examination} and \code{Education}
71
- are averages for 1887, 1888 and 1889.
72
- }
73
- \examples{
74
- require(stats); require(graphics)
75
- pairs(swiss, panel = panel.smooth, main = "swiss data",
76
- col = 3 + (swiss$Catholic > 50))
77
- summary(lm(Fertility ~ . , data = swiss))
78
- }
79
- \keyword{datasets}
@@ -1,38 +0,0 @@
1
- % File src/library/datasets/man/treering.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{treering}
7
- \docType{data}
8
- \alias{treering}
9
- \title{
10
- Yearly Treering Data, -6000--1979
11
- }
12
- \description{
13
- Contains normalized tree-ring widths in dimensionless units.
14
- }
15
- \usage{
16
- treering
17
- }
18
- \format{
19
- A univariate time series with 7981 observations. The object is of
20
- class \code{"ts"}.
21
-
22
- Each tree ring corresponds to one year.
23
- }
24
- \details{
25
- The data were recorded by Donald A. Graybill, 1980, from
26
- Gt Basin Bristlecone Pine 2805M, 3726-11810 in Methuselah Walk, California.
27
- }
28
- \source{
29
- Time Series Data Library:
30
- \url{http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/},
31
- series \file{CA535.DAT}
32
- }
33
- \references{
34
- For background on Bristlecone pines and Methuselah Walk, see
35
- \url{http://www.sonic.net/bristlecone/}; for some photos see
36
- \url{http://www.ltrr.arizona.edu/~hallman/sitephotos/meth.html}
37
- }
38
- \keyword{datasets}
data/data/r/man/trees.Rd DELETED
@@ -1,48 +0,0 @@
1
- % File src/library/datasets/man/trees.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{trees}
7
- \docType{data}
8
- \alias{trees}
9
- \title{Girth, Height and Volume for Black Cherry Trees}
10
- \description{
11
- This data set provides measurements of the girth, height and volume
12
- of timber in 31 felled black cherry trees. Note that girth is the
13
- diameter of the tree (in inches) measured at 4 ft 6 in above the
14
- ground.
15
- }
16
- \usage{trees}
17
- \format{
18
- A data frame with 31 observations on 3 variables.
19
- \tabular{rlll}{
20
- \code{[,1]} \tab \code{Girth} \tab numeric
21
- \tab Tree diameter in inches\cr
22
- \code{[,2]} \tab \code{Height}\tab numeric
23
- \tab Height in ft\cr
24
- \code{[,3]} \tab \code{Volume}\tab numeric
25
- \tab Volume of timber in cubic ft\cr}
26
- }
27
- \source{
28
- Ryan, T. A., Joiner, B. L. and Ryan, B. F. (1976)
29
- \emph{The Minitab Student Handbook}.
30
- Duxbury Press.
31
- }
32
- \references{
33
- Atkinson, A. C. (1985)
34
- \emph{Plots, Transformations and Regression}.
35
- Oxford University Press.
36
- }
37
- \examples{
38
- require(stats); require(graphics)
39
- pairs(trees, panel = panel.smooth, main = "trees data")
40
- plot(Volume ~ Girth, data = trees, log = "xy")
41
- coplot(log(Volume) ~ log(Girth) | Height, data = trees,
42
- panel = panel.smooth)
43
- summary(fm1 <- lm(log(Volume) ~ log(Girth), data = trees))
44
- summary(fm2 <- update(fm1, ~ . + log(Height), data = trees))
45
- step(fm2)
46
- ## i.e., Volume ~= c * Height * Girth^2 seems reasonable
47
- }
48
- \keyword{datasets}
data/data/r/man/uspop.Rd DELETED
@@ -1,27 +0,0 @@
1
- % File src/library/datasets/man/uspop.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{uspop}
7
- \docType{data}
8
- \alias{uspop}
9
- \title{Populations Recorded by the US Census}
10
- \description{
11
- This data set gives the population of the United States (in millions)
12
- as recorded by the decennial census for the period 1790--1970.
13
- }
14
- \usage{uspop}
15
- \format{A time series of 19 values.}
16
- \source{
17
- McNeil, D. R. (1977)
18
- \emph{Interactive Data Analysis}.
19
- New York: Wiley.
20
- }
21
- % FIXME: missing \references{}
22
- \examples{
23
- require(graphics)
24
- plot(uspop, log = "y", main = "uspop data", xlab = "Year",
25
- ylab = "U.S. Population (millions)")
26
- }
27
- \keyword{datasets}
@@ -1,31 +0,0 @@
1
- % File src/library/datasets/man/volcano.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{volcano}
7
- \docType{data}
8
- \alias{volcano}
9
- \title{Topographic Information on Auckland's Maunga Whau Volcano}
10
- \description{
11
- Maunga Whau (Mt Eden) is one of about 50 volcanos in the Auckland
12
- volcanic field. This data set gives topographic information for
13
- Maunga Whau on a 10m by 10m grid.
14
- }
15
- \usage{volcano}
16
- \format{
17
- A matrix with 87 rows and 61 columns, rows corresponding to grid lines
18
- running east to west and columns to grid lines running south to
19
- north.}
20
- \source{
21
- Digitized from a topographic map by Ross Ihaka.
22
- These data should not be regarded as accurate.
23
- }
24
- % FIXME: missing \references{}
25
- \seealso{\code{\link{filled.contour}} for a nice plot.}
26
- \examples{
27
- require(grDevices); require(graphics)
28
- filled.contour(volcano, color.palette = terrain.colors, asp = 1)
29
- title(main = "volcano data: filled contour map")
30
- }
31
- \keyword{datasets}
@@ -1,56 +0,0 @@
1
- % File src/library/datasets/man/warpbreaks.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{warpbreaks}
7
- \docType{data}
8
- \alias{warpbreaks}
9
- \title{The Number of Breaks in Yarn during Weaving}
10
- \description{
11
- This data set gives the number of warp breaks per loom, where a loom
12
- corresponds to a fixed length of yarn.
13
- }
14
- \usage{warpbreaks}
15
- \format{
16
- A data frame with 54 observations on 3 variables.
17
- \tabular{rlll}{
18
- \code{[,1]} \tab \code{breaks} \tab numeric \tab The number of breaks\cr
19
- \code{[,2]} \tab \code{wool} \tab factor \tab The type of wool (A or B)\cr
20
- \code{[,3]} \tab \code{tension} \tab factor \tab The level of tension (L, M, H)
21
- }
22
- There are measurements on 9 looms for each of the six types of warp
23
- (\code{AL}, \code{AM}, \code{AH}, \code{BL}, \code{BM}, \code{BH}).
24
- }
25
- \source{
26
- Tippett, L. H. C. (1950)
27
- \emph{Technological Applications of Statistics}.
28
- Wiley. Page 106.
29
-
30
- }
31
- \references{
32
- Tukey, J. W. (1977)
33
- \emph{Exploratory Data Analysis}.
34
- Addison-Wesley.
35
-
36
- McNeil, D. R. (1977)
37
- \emph{Interactive Data Analysis}.
38
- Wiley.
39
- }
40
- \seealso{
41
- \code{\link{xtabs}} for ways to display these data as a table.
42
- }
43
- \examples{
44
- require(stats); require(graphics)
45
- summary(warpbreaks)
46
- opar <- par(mfrow = c(1,2), oma = c(0, 0, 1.1, 0))
47
- plot(breaks ~ tension, data = warpbreaks, col = "lightgray",
48
- varwidth = TRUE, subset = wool == "A", main = "Wool A")
49
- plot(breaks ~ tension, data = warpbreaks, col = "lightgray",
50
- varwidth = TRUE, subset = wool == "B", main = "Wool B")
51
- mtext("warpbreaks data", side = 3, outer = TRUE)
52
- par(opar)
53
- summary(fm1 <- lm(breaks ~ wool*tension, data = warpbreaks))
54
- anova(fm1)
55
- }
56
- \keyword{datasets}
data/data/r/man/women.Rd DELETED
@@ -1,40 +0,0 @@
1
- % File src/library/datasets/man/women.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-2007 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{women}
7
- \docType{data}
8
- \alias{women}
9
- \title{Average Heights and Weights for American Women}
10
- \description{
11
- This data set gives the average heights and weights for American women
12
- aged 30--39.
13
- }
14
- \usage{women}
15
- \format{A data frame with 15 observations on 2 variables.
16
- \tabular{rlll}{
17
- \code{[,1]} \tab \code{height} \tab numeric \tab Height (in)\cr
18
- \code{[,2]} \tab \code{weight} \tab numeric \tab Weight (lbs)
19
- }
20
- }
21
- \source{The World Almanac and Book of Facts, 1975.}
22
- \details{
23
- The data set appears to have been taken from the American Society of
24
- Actuaries \emph{Build and Blood Pressure Study} for some (unknown to
25
- us) earlier year.
26
-
27
- The World Almanac notes: \dQuote{The figures represent weights in
28
- ordinary indoor clothing and shoes, and heights with shoes}.
29
- }
30
- \references{
31
- McNeil, D. R. (1977)
32
- \emph{Interactive Data Analysis}.
33
- Wiley.
34
- }
35
- \examples{
36
- require(graphics)
37
- plot(women, xlab = "Height (in)", ylab = "Weight (lb)",
38
- main = "women data: American women aged 30-39")
39
- }
40
- \keyword{datasets}
data/data/r/man/zCO2.Rd DELETED
@@ -1,81 +0,0 @@
1
- % File src/library/datasets/man/zCO2.Rd
2
- % Part of the R package, http://www.R-project.org
3
- % Copyright 1995-20011 R Core Development Team
4
- % Distributed under GPL 2 or later
5
-
6
- \name{CO2}
7
- \docType{data}
8
- \alias{CO2}
9
- \title{Carbon Dioxide Uptake in Grass Plants}
10
- \description{
11
- The \code{CO2} data frame has 84 rows and 5 columns of data from an
12
- experiment on the cold tolerance of the grass species
13
- \emph{Echinochloa crus-galli}.
14
- }
15
- \usage{CO2}
16
- \format{
17
- This object of class \code{c("nfnGroupedData", "nfGroupedData",
18
- "groupedData", "data.frame")} containing the following columns:
19
- \describe{
20
- \item{Plant}{
21
- an ordered factor with levels
22
- \code{Qn1} < \code{Qn2} < \code{Qn3} < \dots < \code{Mc1}
23
- giving a unique identifier for each plant.
24
- }
25
- \item{Type}{
26
- a factor with levels
27
- \code{Quebec}
28
- \code{Mississippi}
29
- giving the origin of the plant
30
- }
31
- \item{Treatment}{
32
- a factor with levels
33
- \code{nonchilled}
34
- \code{chilled}
35
- }
36
- \item{conc}{
37
- a numeric vector of ambient carbon dioxide concentrations (mL/L).
38
- }
39
- \item{uptake}{
40
- a numeric vector of carbon dioxide uptake rates
41
- (\eqn{\mu\mbox{mol}/m^2}{umol/m^2} sec).
42
- }
43
- }
44
- }
45
- \details{
46
- The \eqn{CO_2}{CO2} uptake of six plants from Quebec and six plants
47
- from Mississippi was measured at several levels of ambient
48
- \eqn{CO_2}{CO2} concentration. Half the plants of each type were
49
- chilled overnight before the experiment was conducted.
50
-
51
- This dataset was originally part of package \code{nlme}, and that has
52
- methods (including for \code{[}, \code{as.data.frame}, \code{plot} and
53
- \code{print}) for its grouped-data classes.
54
- }
55
- \source{
56
- Potvin, C., Lechowicz, M. J. and Tardif, S. (1990)
57
- \dQuote{The statistical analysis of ecophysiological response curves
58
- obtained from experiments involving repeated measures}, \emph{Ecology},
59
- \bold{71}, 1389--1400.
60
-
61
- Pinheiro, J. C. and Bates, D. M. (2000)
62
- \emph{Mixed-effects Models in S and S-PLUS}, Springer.
63
- }
64
- \examples{
65
- require(stats); require(graphics)
66
- \testonly{options(show.nls.convergence=FALSE)}
67
- coplot(uptake ~ conc | Plant, data = CO2, show.given = FALSE, type = "b")
68
- ## fit the data for the first plant
69
- fm1 <- nls(uptake ~ SSasymp(conc, Asym, lrc, c0),
70
- data = CO2, subset = Plant == 'Qn1')
71
- summary(fm1)
72
- ## fit each plant separately
73
- fmlist <- list()
74
- for (pp in levels(CO2$Plant)) {
75
- fmlist[[pp]] <- nls(uptake ~ SSasymp(conc, Asym, lrc, c0),
76
- data = CO2, subset = Plant == pp)
77
- }
78
- ## check the coefficients by plant
79
- print(sapply(fmlist, coef), digits=3)
80
- }
81
- \keyword{datasets}
data/lib/ext/csv.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'csv'
2
- require 'statsample'
3
-
4
- class CSV
5
- def to_dataset mode=:col
6
- CSV::Table.new(self).send("by_#{mode}.to_s".to_sym).to_dataset
7
- end
8
- end
9
-
10
- class CSV::Table
11
- def to_dataset
12
- begin
13
- h = {}
14
- self.headers.each { |header| h[header] = self[header].to_scale }
15
- h
16
- rescue NoMethodError => e # Table has no headers. Try a different way.
17
- v = []
18
- 0.upto(self.size-1).each { |j| v[j] = self[j].to_scale }
19
- v
20
- end.to_dataset
21
- end
22
- end
data/lib/ext/shoes.rb DELETED
@@ -1,131 +0,0 @@
1
- require "green_shoes"
2
-
3
- class Shoes
4
- class App
5
- # This has been integrated into Green Shoes in the repo, but is not yet in the current gem.
6
- # Creates an edit_box for source code editing, using gtksourceview2.
7
- def code_box args={}
8
- require 'gtksourceview2'
9
- args = basic_attributes args
10
-
11
- args[:width] = 400 if args[:width].zero?
12
- args[:height] = 300 if args[:height].zero?
13
-
14
- (change_proc = args[:change]; args.delete :change) if args[:change]
15
- sv = Gtk::SourceView.new
16
- sv.show_line_numbers = true
17
- sv.insert_spaces_instead_of_tabs = true
18
- sv.smart_home_end = Gtk::SourceView::SMART_HOME_END_ALWAYS
19
- sv.tab_width = 2
20
- sv.buffer.text = args[:text].to_s
21
- sv.buffer.language = Gtk::SourceLanguageManager.new.get_language('ruby')
22
- sv.buffer.highlight_syntax = true
23
- sv.modify_font(Pango::FontDescription.new(args[:font])) if args[:font]
24
-
25
- cb = Gtk::ScrolledWindow.new
26
- cb.set_size_request args[:width], args[:height]
27
- cb.set_policy Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC
28
- cb.set_shadow_type Gtk::SHADOW_IN
29
- cb.add sv
30
-
31
- sv.buffer.signal_connect "changed" do
32
- yield @_cb
33
- end if block_given?
34
-
35
- @canvas.put cb, args[:left], args[:top]
36
-
37
- cb.show_all
38
- args[:real], args[:app], args[:textview] = cb, self, sv
39
- @_cb = CodeBox.new(args).tap{|s| s.change &change_proc}
40
- end
41
-
42
-
43
- # Helper function for image() [with no name provided]. Currently only understands SVGs. Converts whatever it's given to
44
- # the format needed by Gtk::Image.new().
45
- #
46
- # Arguments:
47
- # * :data can be a string (e.g., for an SVG), an RSVG::Handle, a Gdk::Pixbuf, or even a Gtk::Image. If it can't tell which, it'll try
48
- # calling the pixbuf() method on :data, or just returning it as is.
49
- # * :format, when it works, will specify the content-type of :data when that is not implicit in the class of :data. For example, if
50
- # :data is a string, :format might be :svg.
51
- def image_handle args={}
52
- if args[:data].is_a?(String)
53
- raise(NotImplementedError, "Currently only RSVG::Handle is implemented.") if args.has_key?(:format) && args[:format] != :svg
54
- RSVG::Handle.new_from_data(args[:data]).tap{|s|s.close}.pixbuf
55
- elsif args[:data].is_a?(RSVG::Handle)
56
- args[:data].pixbuf
57
- elsif args[:data].is_a?(Gdk::Pixbuf) || args[:data].is_a?(Gtk::Image)
58
- args[:data]
59
- else
60
- # Unknown format. Try asking for a pixbuf, otherwise just assume it's already a pixbuf.
61
- args[:data].respond_to?(:pixbuf) ? args[:data].pixbuf : args[:data]
62
- end
63
- end
64
-
65
-
66
- # Improvement on Green Shoes' image function: accepts already-loaded images, such as those you might
67
- # create in-app. This has mostly been merged into green shoes, but that version is buggy.
68
- def image name, args={}
69
- # Handle case where no name is given -- typically, :data argument will be set.
70
- if name.is_a?(Hash)
71
- args = name
72
- name = nil
73
- raise(ArgumentError, ":data must be set if no name given") unless args.has_key?(:data)
74
- end
75
-
76
- args = basic_attributes args
77
- args[:full_width] = args[:full_height] = 0
78
- (click_proc = args[:click]; args.delete :click) if args[:click]
79
-
80
- if name.nil?
81
- img = Gtk::Image.new image_handle(args)
82
-
83
- args[:full_width], args[:full_height] = img.size_request if (!args[:width].zero? or !args[:height].zero?)
84
- downloading = false
85
-
86
- elsif name =~ /^(http|https):\/\//
87
- tmpname = File.join(Dir.tmpdir, "__green_shoes_#{Time.now.to_f}.png")
88
- d = download name, save: tmpname
89
- img = Gtk::Image.new File.join(DIR, '../static/downloading.png')
90
- downloading = true
91
- else
92
- img = Gtk::Image.new name
93
- downloading = false
94
- end
95
-
96
- if (!args[:width].zero? or !args[:height].zero?) and !downloading
97
- args[:full_width], args[:full_height] = imagesize(name) unless name.nil?
98
- args[:width] = args[:full_width] if args[:width].zero?
99
- args[:height] = args[:full_height] if args[:height].zero?
100
- img = Gtk::Image.new img.pixbuf.scale(args[:width], args[:height])
101
- end
102
- @canvas.put img, args[:left], args[:top]
103
- img.show_now
104
- @canvas.remove img if args[:hidden]
105
- args[:real], args[:app], args[:path] = img, self, name
106
- Image.new(args).tap do |s|
107
- @dics.push([s, d, tmpname]) if downloading
108
- s.click &click_proc if click_proc
109
- end
110
- end
111
-
112
-
113
- def icon filename=nil
114
- filename.nil? ? win.icon : win.icon = filename
115
- end
116
-
117
- class << self
118
- def default_icon= filename
119
- Gtk::Window.set_default_icon(filename)
120
- end
121
- end
122
- end
123
-
124
- class CodeBox < EditBox; end
125
- end
126
-
127
- module SciRuby
128
- ICON_PATH = File.join(DIR, '..', 'static', 'sciruby-icon.png')
129
- end
130
-
131
- Shoes::App.default_icon = SciRuby::ICON_PATH
data/lib/ext/string.rb DELETED
@@ -1,39 +0,0 @@
1
- class String
2
- unless method_defined?(:constantize)
3
- # Based on constantize from ActiveSupport::Inflector
4
- def constantize
5
- names = self.split('::')
6
- names.shift if names.empty? || names.first.empty?
7
-
8
- constant = Object
9
- names.each do |name|
10
- constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name)
11
- end
12
- constant
13
- end
14
- end
15
-
16
- unless method_defined?(:camelize)
17
- # Adapted from camelize from ActiveSupport::Inflector
18
- def camelize first_letter_in_uppercase = true
19
- if first_letter_in_uppercase
20
- self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
21
- else
22
- self.to_s[0].chr.downcase + self[1..-1].camelize
23
- end
24
- end
25
- end
26
-
27
- unless method_defined?(:underscore)
28
- # Adapted from underscore from ActiveSupport::Inflector
29
- def underscore
30
- word = self.dup
31
- word.gsub!(/::/, '/')
32
- word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
33
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
34
- word.tr!("-", "_")
35
- word.downcase!
36
- word
37
- end
38
- end
39
- end
@@ -1,87 +0,0 @@
1
- require "statsample"
2
-
3
- module SciRuby
4
- module Analysis
5
- class Suite
6
- include ::Statsample::Shorthand
7
- attr_accessor :output
8
- attr_accessor :name
9
- attr_reader :block
10
- def initialize(opts=Hash.new(), &block)
11
- if !opts.is_a? Hash
12
- opts={:name=>opts}
13
- end
14
-
15
- @block=block
16
- @name=opts[:name] || "Analysis #{Time.now}"
17
- @attached=[]
18
- @output=opts[:output] || ::STDOUT
19
- end
20
- # Run the analysis, putting output on
21
- def run
22
- @block.arity<1 ? instance_eval(&@block) : @block.call(self)
23
- end
24
- # Provides a description of the procedure. Only appears as a commentary on
25
- # SuiteReportBuilder outputs
26
- def desc(d)
27
- @output.puts("Description:")
28
- @output.puts(" #{d}")
29
- end
30
- def echo(*args)
31
- @output.puts(*args)
32
- end
33
- def summary(obj)
34
- obj.summary
35
- end
36
- def add_to_reportbuilder(rb)
37
- SuiteReportBuilder.new({:name=>name, :rb=>rb}, &block)
38
- end
39
-
40
- def generate(filename)
41
- ar=SuiteReportBuilder.new({:name=>name}, &block)
42
- ar.generate(filename)
43
- end
44
- def to_text
45
- ar=SuiteReportBuilder.new({:name=>name}, &block)
46
- ar.to_text
47
- end
48
-
49
- def attach(ds)
50
- @attached.push(ds)
51
- end
52
- def detach(ds=nil)
53
- if ds.nil?
54
- @attached.pop
55
- else
56
- @attached.delete(ds)
57
- end
58
- end
59
- alias :old_boxplot :boxplot
60
- alias :old_histogram :histogram
61
- alias :old_scatterplot :scatterplot
62
-
63
- def show_svg(svg)
64
- require 'tmpdir'
65
- fn=Dir.tmpdir+"/image_#{Time.now.to_f}.svg"
66
- File.open(fn,"w") {|fp| fp.write svg}
67
- `xdg-open '#{fn}'`
68
- end
69
- def boxplot(*args)
70
- show_svg(old_boxplot(*args).to_svg)
71
- end
72
- def histogram(*args)
73
- show_svg(old_histogram(*args).to_svg)
74
- end
75
- def scatterplot(*args)
76
- show_svg(old_scatterplot(*args).to_svg)
77
- end
78
-
79
- def method_missing(name, *args,&block)
80
- @attached.reverse.each do |ds|
81
- return ds[name.to_s] if ds.fields.include? (name.to_s)
82
- end
83
- raise "Method #{name} doesn't exists"
84
- end
85
- end
86
- end
87
- end