[Rprotobuf-commits] r880 - papers/jss

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Mar 24 21:25:09 CET 2014


Author: murray
Date: 2014-03-24 21:25:09 +0100 (Mon, 24 Mar 2014)
New Revision: 880

Modified:
   papers/jss/article.Rnw
Log:
Replace sweave code with manual CodeInput/CodeOutput for now so this
is buildable again with protobuf-2.5 library which doesn't like our
unittest.proto.



Modified: papers/jss/article.Rnw
===================================================================
--- papers/jss/article.Rnw	2014-03-23 23:01:28 UTC (rev 879)
+++ papers/jss/article.Rnw	2014-03-24 20:25:09 UTC (rev 880)
@@ -984,7 +984,7 @@
 choose another type (such as enum or integer) capable of storing three
 distinct values.
 
-<<echo=FALSE,print=FALSE>>=
+<<echo=FALSE,print=FALSE,eval=FALSE>>=
 if (!exists("protobuf_unittest.TestAllTypes",
             "RProtoBuf:DescriptorPool")) {
     unittest.proto.file <- system.file("unitTests", "data",
@@ -1041,19 +1041,27 @@
 If we try to set an int64 field in \proglang{R} to double values, we lose
 precision:
 
-<<>>=
-test <- new(protobuf_unittest.TestAllTypes)
-test$repeated_int64 <- c(2^53, 2^53+1)
-length(unique(test$repeated_int64))
-@
+% We want a cleaner error message here.
+\begin{CodeChunk}
+\begin{CodeInput}
+R> test <- new(protobuf_unittest.TestAllTypes)
+R> test$repeated_int64 <- c(2^53, 2^53+1)
+R> length(unique(test$repeated_int64))
+\end{CodeInput}
+\begin{CodeOutput}
+[1] 1
+\end{CodeOutput}
+\end{CodeChunk}
 
 But when the values are specified as character strings, \pkg{RProtoBuf}
 will automatically coerce them into a true 64-bit integer types 
 before storing them in the Protocol Buffer message:
 
-<<>>=
-test$repeated_int64 <- c("9007199254740992", "9007199254740993")
-@
+\begin{CodeChunk}
+\begin{CodeInput}
+R> test$repeated_int64 <- c("9007199254740992", "9007199254740993")
+\end{CodeInput}
+\end{CodeChunk}
 
 When reading the value back into \proglang{R}, numeric types are returned by
 default, but when the full precision is required a character value
@@ -1063,14 +1071,34 @@
 packages such as \pkg{int64} \citep{int64} or \pkg{bit64}
 \citep{bit64} which represent 64-bit integers in \proglang{R}.
 
-<<>>=
-options("RProtoBuf.int64AsString" = FALSE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-options("RProtoBuf.int64AsString" = TRUE)
-test$repeated_int64
-length(unique(test$repeated_int64))
-@
+\begin{CodeChunk}
+\begin{CodeInput}
+R> options("RProtoBuf.int64AsString" = FALSE)
+R> test$repeated_int64
+\end{CodeInput}
+\begin{CodeOutput}
+[1] 9.007e+15 9.007e+15
+\end{CodeOutput}
+\begin{CodeInput}
+R> length(unique(test$repeated_int64))
+\end{CodeInput}
+\begin{CodeOutput}
+[1] 1
+\end{CodeOutput}
+\begin{CodeInput}
+R> options("RProtoBuf.int64AsString" = TRUE)
+R> test$repeated_int64
+\end{CodeInput}
+\begin{CodeOutput}
+[1] "9007199254740992" "9007199254740993"
+\end{CodeOutput}
+\begin{CodeInput}
+R> length(unique(test$repeated_int64))
+\end{CodeInput}
+\begin{CodeOutput}
+[1] 2
+\end{CodeOutput}
+\end{CodeChunk}
 
 <<echo=FALSE,print=FALSE>>=
 options("RProtoBuf.int64AsString" = FALSE)



More information about the Rprotobuf-commits mailing list