Permalink
Browse files

add digits param for toJSON conversion see #39

	geändert:   R4CouchDB/DESCRIPTION
	geändert:   R4CouchDB/NAMESPACE
	geändert:   R4CouchDB/R/cdbIni.R
	geändert:   R4CouchDB/man/cdbIni.Rd
	neue Datei:   R4CouchDB_0.3.3.tar.gz
	geändert:   README.md
	neue Datei:   example/3dplot.pdf
  • Loading branch information...
1 parent 00c8d58 commit 72e486a55a05a10bf7cb2a8160f8b122f12dcdf9 @wactbprot committed Dec 30, 2013
View
@@ -1,16 +1,16 @@
Package: R4CouchDB
Type: Package
Title: A R convenience layer for CouchDB
-Version: 0.3.2
-Date: 2013/10/30
+Version: 0.3.3
+Date: 2013/12/30
Author: wactbprot
Maintainer: <thsteinbock@web.de>
Description: The R4CouchDB package provides a collection of functions for
basic database and document management operations such as add and
delete. Every cdbFunction() gets and returns a list() containing the
- connection setup. Such a list (in the documentation mostly called cdb)
+ connection setup. Such a list (in the documentation mostly called cdb)
can be generated by cdb <- cdbIni(). Then cdb also contains some function
- resp. functionality e.g cdb$baseUrl().
+ resp. functionality e.g cdb$baseUrl().
License: BSD
LazyLoad: yes
Depends:
View
@@ -1,5 +1,5 @@
-export(cdbAddDoc)
export(cdbAddAttachment)
+export(cdbAddDoc)
export(cdbDeleteDoc)
export(cdbGetConfig)
export(cdbGetDoc)
View
@@ -9,7 +9,7 @@
#'
#' @author wactbprot
#' @export
-#' @usage cdbIni(serverName="localhost", port="5984", DBName="", prot = "http", uname = "", pwd = "", newDBName = "", removeDBName = "", id = "", dataList = list(), fileName = "", design = "", view = "", list = "", queryParam = "", encSub = "?", attachmentsWithPath=TRUE)
+#' @usage cdbIni(serverName="localhost", port="5984", DBName="", prot = "http", uname = "", pwd = "", newDBName = "", removeDBName = "", id = "", dataList = list(), fileName = "", design = "", view = "", list = "", queryParam = "", encSub = "?", attachmentsWithPath=TRUE, digits = 7)
#' @param serverName server name
#' @param port port
#' @param DBName name of database
@@ -27,6 +27,7 @@
#' @param queryParam additional query params
#' @param encSub a character which is used as a replacement for chars who can not be converted by iconv
#' @param attachmentsWithPath effects the result of the function cdbAddAttachment in the way the variable is named
+#' @param digits digits kept at toJSON conversion
#' @return \item{cdb}{The R4CouchDB (method) chain(ing) list }
#' @keywords misc
#'
@@ -47,7 +48,8 @@ cdbIni <- function(serverName = "localhost",
list = "",
queryParam = "",
encSub = "?",
- attachmentsWithPath = TRUE){
+ attachmentsWithPath = TRUE,
+ digits = 7){
rc <- library(RCurl,
logical.return = TRUE,
@@ -81,8 +83,8 @@ cdbIni <- function(serverName = "localhost",
curl = getCurlHandle(),
localEnc = "UTF-8",
serverEnc = "UTF-8",
- attachmentsWithPath = TRUE
- )
+ attachmentsWithPath = TRUE,
+ digits = digits)
cdb$opts <- function(cdb){
if(cdb$uname != "" & cdb$pwd != ""){
@@ -120,7 +122,8 @@ cdbIni <- function(serverName = "localhost",
cdb$toJSON <- function(lst){
jsn <- toJSON(lst,
- collapse = "")
+ collapse = "",
+ digits = digits)
jsn <- iconv(jsn,
cdb$localEnc,
cdb$serverEnc,
@@ -131,6 +134,7 @@ cdbIni <- function(serverName = "localhost",
## this way. A \r is here replaced by \\r
## resulting in \r in the database
jsn <- gsub("\\r","\\\\r",jsn)
+
return(jsn)
}
cdb$getDocRev <- function(cdb){
View
@@ -6,7 +6,7 @@
prot = "http", uname = "", pwd = "", newDBName = "",
removeDBName = "", id = "", dataList = list(), fileName
= "", design = "", view = "", list = "", queryParam =
- "", encSub = "?", attachmentsWithPath=TRUE)
+ "", encSub = "?", attachmentsWithPath=TRUE, digits = 7)
}
\arguments{
\item{serverName}{server name}
@@ -47,6 +47,8 @@
\item{attachmentsWithPath}{effects the result of the
function cdbAddAttachment in the way the variable is
named}
+
+ \item{digits}{digits kept at toJSON conversion}
}
\value{
\item{cdb}{The R4CouchDB (method) chain(ing) list }
View
Binary file not shown.
View
@@ -1,10 +1,10 @@
-<pre>
+```
__ _ _ ___ _ ___ ___
/__\ || | / __\___ _ _ ___| |__ / \/ __\
/ \// || |_ / / / _ \| | | |/ __| '_ \ / /\ /__\//
/ _ \__ _/ /__| (_) | |_| | (__| | | |/ /_// \/ \
\/ \_/ |_| \____/\___/ \__,_|\___|_| |_/___,'\_____/
-</pre>
+```
## A Collection of R functions for CouchDB access
@@ -52,21 +52,9 @@ There are some examples below the demo folder.
foo$queryParam <- "count=10"
cdbGetUuidS(foo)$res
-* or make a twitter_db and fill up some search results from the request
- http://search.twitter.com/search.json?q=couchdb
+* see test session in the example folder
- foo$newDBName <- "japan_db"
- foo <- cdbMakeDB(foo)
- u <- "http://search.twitter.com/search.json?q=japan&rpp=100&page=10"
- res <- fromJSON(getURLContent(u))
- lapply(res$results,
- function(i){
- foo$dataList <- i
- cdbAddDoc(foo)$error
- })
-
-
-* get angry and write a ticket or mail
+* get angry and write a issue
## Problems
@@ -89,7 +77,9 @@ and than
In cdbIni I added with 0.1.2 the lines:
cdb$toJSON <- function(lst){
- jsn <- toJSON(lst, collapse = "")
+ jsn <- toJSON(lst,
+ collapse = "",
+ digits = digits)
jsn <- gsub("\\r","\\\\r",jsn)
return(jsn)
}
@@ -116,3 +106,11 @@ I'm not happy
with this but have no better solution for the moment.
+### digits
+
+Numbers are converted to JSON with 7 digits by default. Adjust this to your
+needs by
+
+
+ cdb <- cdbIni()
+ cdb$digits <- 13
View
Binary file not shown.

0 comments on commit 72e486a

Please sign in to comment.