Skip to content

Instantly share code, notes, and snippets.

@fbergmann
Last active April 25, 2017 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbergmann/a165db4fd05eae21f7a1b2039bf0be85 to your computer and use it in GitHub Desktop.
Save fbergmann/a165db4fd05eae21f7a1b2039bf0be85 to your computer and use it in GitHub Desktop.
--- a/COPASI.R
+++ b/COPASI.R
@@ -94,7 +94,9 @@ function(name, .values, where = topenv(parent.frame()), suffix = "Value")
enumToInteger <- function(name,type)
{
if (is.character(name)) {
- ans <- as.integer(get(paste(".__E__", type, sep = ""))[name])
+ gettype <- paste(".__E__", type, sep = "")
+ if (!exists(gettype)) gettype <- paste(".__E__", substr(type, 3, nchar(type)), sep = "")
+ ans <- as.integer(get(gettype)[name])
if (is.na(ans)) {warning("enum not found ", name, " ", type)}
ans
}
@@ -103,7 +105,9 @@ enumToInteger <- function(name,type)
enumFromInteger =
function(i,type)
{
- itemlist <- get(paste(".__E__", type, sep=""))
+ gettype <- paste(".__E__", type, sep = "")
+ if (!exists(gettype)) gettype <- paste(".__E__", substr(type, 3, nchar(type)), sep = "")
+ itemlist <- get(gettype)
names(itemlist)[match(i, itemlist)]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment