{"action":"opened","issue":{"url":"https://api.github.com/repos/bgreenwell/ramify/issues/9","labels_url":"https://api.github.com/repos/bgreenwell/ramify/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/bgreenwell/ramify/issues/9/comments","events_url":"https://api.github.com/repos/bgreenwell/ramify/issues/9/events","html_url":"https://github.com/bgreenwell/ramify/issues/9","id":129762061,"number":9,"title":"Allow creation of non-numeric matrices with mat","user":{"login":"bgreenwell","id":3777755,"avatar_url":"https://avatars.githubusercontent.com/u/3777755?v=3","gravatar_id":"","url":"https://api.github.com/users/bgreenwell","html_url":"https://github.com/bgreenwell","followers_url":"https://api.github.com/users/bgreenwell/followers","following_url":"https://api.github.com/users/bgreenwell/following{/other_user}","gists_url":"https://api.github.com/users/bgreenwell/gists{/gist_id}","starred_url":"https://api.github.com/users/bgreenwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgreenwell/subscriptions","organizations_url":"https://api.github.com/users/bgreenwell/orgs","repos_url":"https://api.github.com/users/bgreenwell/repos","events_url":"https://api.github.com/users/bgreenwell/events{/privacy}","received_events_url":"https://api.github.com/users/bgreenwell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-29T13:10:14Z","updated_at":"2016-01-29T13:10:14Z","closed_at":null,"body":"Something like this should work:\r\n\r\n```{r}\r\nmat.character <- function(x, rows = TRUE, sep = getOption(\"mat.sep\"), \r\n                          ...) {\r\n  \r\n  # Gather rows and individual values\r\n  vecs <- unlist(strsplit(x, split = \";\"))  # column/row vectors\r\n  vals <- if (!is.null(sep)) {\r\n    trimws(unname(unlist(lapply(vecs, strsplit, split = sep))))\r\n  } else {\r\n    vecs\r\n  }\r\n\r\n  if (all(grepl(\"^[1-9]\\\\d*(\\\\.\\\\d+)?$\", vals))) {\r\n    # vals <- unlist(lapply(vals, function(x) eval(parse(text = x))))\r\n    vals <- as.numeric(x)  # much faster!\r\n  } \r\n  \r\n  # Form matrix from parsed values by calling R's built-in matrix function\r\n  if (rows) {\r\n    matrix(vals, nrow = length(vecs), byrow = TRUE, ...)\r\n  } else {\r\n    matrix(vals, ncol = length(vecs), byrow = FALSE, ...)\r\n  }\r\n  \r\n}\r\n```"}}