~ubuntu-branches/ubuntu/utopic/rggobi/utopic

« back to all changes in this revision

Viewing changes to R/next-version/dataset.r

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2006-11-09 20:28:24 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061109202824-rprmht1pviku76qg
Tags: 2.1.4-1-1
* New upstream release
* debian/rules: Simplied to one-liner sourcing r-cran.mk
* debian/control: (Build-)Depends: upgraded to the current versions
  r-base-core (>= 2.4.0) and ggobi (>= 2.1.4)
* debian/control: Added Depends: on r-cran-rgtk2; we cannot currently
  Build-Depends: on it as it wants an X11 display which stop autobuilds
* debian/control: Standards-Version: upgraded to 3.7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Stuff yet to be cleaned up
2
 
# ============================================================================ 
3
 
 
4
 
 
5
 
VariableTypeEnum <- c(real = 0, categorical = 1, integer = 2, counter = 3, uniform = 4)
6
 
 
7
 
 
8
 
#
9
 
#  variable name = value, ...
10
 
# or
11
 
#   .which = c(variable name = value, ....)
12
 
#
13
 
setVariableType.ggobi <- function(..., .which,  .data = 1, .gobi = getDefaultGGobi())
14
 
{
15
 
  if(missing(.which)) {
16
 
     tmp = list(...)
17
 
     .which = as.integer(unlist(list(...)))
18
 
     names(.which) = names(tmp)
19
 
  } else {
20
 
      mode(.which) = "integer"
21
 
  }
22
 
 
23
 
  if(mode(.data) == "numeric" || mode(.data) == "character")
24
 
    .data <- getDatasetReference.ggobi(.data, .gobi)
25
 
  
26
 
  i = match(names(.which), names(.data))
27
 
  if(any(is.na(i))) {
28
 
     stop("variable names ", paste(names(.which)[is.na(i)], collapse = ", "), " not in the specified data set")
29
 
  }
30
 
 
31
 
  .GGobiCall("setVariableTypes", as.integer(i-1), .which, .data, .gobi = .gobi)
32
 
}
33
 
 
34
 
"[[<-.ggobiDataset" <- function(x, i, j, value) {
35
 
  if(is.character(j))
36
 
    vars <- getVariableIndex.ggobi(j, .data=x)
37
 
  else
38
 
    vars <- j
39
 
 
40
 
  val <- rep(value, length = length(i))
41
 
  for(v in vars) {
42
 
    setVariableValues.ggobi(val, v, i, .data = x)
43
 
  } 
44
 
 
45
 
  x
46
 
}
47
 
 
48
 
 
49
 
 
50
 
 
51
 
removeVariable.ggobi <- function(..., .data = 1, .gobi = getDefaultGGobi()) {
52
 
 which <- getVariableIndex.ggobi(..., .gobi=.gobi)
53
 
 
54
 
 .GGobiC("removeVariables", which, .data, .gobi = .gobi)[[1]]
55
 
}
56
 
 
57
 
getVariable.ggobi <- function(which, .data = 1, .gobi = getDefaultGGobi(), asDataFrame = FALSE) {
58
 
  idx <- getVariableIndex.ggobi(which, .data = .data, .gobi = .gobi)
59
 
  if(any(is.na(idx))) {
60
 
    stop(paste("Unmatched variable name", which[is.na(idx)],"in ggobi"))
61
 
  }
62
 
 
63
 
  varNames <- getVariableNames.ggobi(.data = .data, .gobi = .gobi)[idx]
64
 
  if(asDataFrame)
65
 
    rowNames <- getRowNames.ggobi(.data = .data, .gobi = .gobi)
66
 
 
67
 
  if(mode(.data) == "numeric")
68
 
    .data <- as.integer(.data - 1)
69
 
 
70
 
  vals <- .GGobiCall("getVariables", as.integer(idx), .data, .gobi=.gobi)
71
 
  names(vals)  <- varNames
72
 
 
73
 
  if(asDataFrame)
74
 
    vals <- data.frame(vals, row.names = rowNames, check.names = FALSE)
75
 
 
76
 
  vals
77
 
}