Permalink
Browse files

ensure columns are double or character before viewing

  • Loading branch information...
1 parent eb5f6f1 commit 8c3d37be21812fa613b30af1714a848a4ca9ff61 @jjallaire jjallaire committed Mar 21, 2013
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/cpp/session/modules/SessionData.R
@@ -24,7 +24,24 @@
})
.rs.registerReplaceHook("View", "utils", function(original, x, title) {
+
+ # generate title if necessary
if (missing(title))
title <- deparse(substitute(x))[1]
- invisible(.Call("rs_viewData", as.data.frame(x), title))
+
+ # make sure we are dealing with a data frame
+ if (!is.data.frame(x))
+ x <- as.data.frame(x)
+
+ # call viewData (prepare columns so they are either double or character)
+ invisible(.Call("rs_viewData",
+ lapply(x, function(col) {
+ if (is.numeric(col)) {
+ storage.mode(col) <- "double"
+ col
+ }
+ else
+ as.character(col)
+ }),
+ title))
})

0 comments on commit 8c3d37b

Please sign in to comment.