[Stacomir-commits] r440 - pkg/stacomirtools/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 13 08:37:56 CEST 2017


Author: briand
Date: 2017-07-13 08:37:56 +0200 (Thu, 13 Jul 2017)
New Revision: 440

Modified:
   pkg/stacomirtools/R/RequeteODBC.r
   pkg/stacomirtools/R/utilities.r
Log:
updated documentation

Modified: pkg/stacomirtools/R/RequeteODBC.r
===================================================================
--- pkg/stacomirtools/R/RequeteODBC.r	2017-07-13 06:36:15 UTC (rev 439)
+++ pkg/stacomirtools/R/RequeteODBC.r	2017-07-13 06:37:56 UTC (rev 440)
@@ -61,13 +61,15 @@
 			
 
 
+
+
 #' Function loaded in this package to avoid errors, if the package is called
-#' without stacomiR
+#' without 'stacomiR'
 #' 
 #' This function will be replaced by a longer function using gWidgets if the
-#' package stacomiR is loaded. It is provided there to avoid to pointing to an
-#' undefined global function. Normally the program tests for the existence of
-#' and environment envir_stacomi which indicates that the messages are to be
+#' package 'stacomiR' is loaded. It is provided there to avoid to pointing to
+#' an undefined global function. Normally the program tests for the existence
+#' of and environment envir_stacomi which indicates that the messages are to be
 #' displayed in the gWidget interface, so this code is to avoid notes in
 #' R.check.
 #' 
@@ -75,7 +77,7 @@
 #' @param text The text to display
 #' @param arret If true calls the program to stop and the message to be
 #' displayed
-#' @param wash Only used when called from within stacomiR, and there is a
+#' @param wash Only used when called from within 'stacomiR', and there is a
 #' widget interface, kept there for consistency
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 			funout<-function(text,arret=FALSE){
@@ -84,6 +86,8 @@
 			}
 
 
+
+
 #' very usefull function remove factor that appear, noticeably after loading
 #' with 'ODBC'
 #' 
@@ -94,6 +98,14 @@
 #' @param df a data.frame
 #' @return df
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples
+#' 
+#' df <- data.frame("var1" = c("blue","red"),"var2"=c("nice","ugly"))
+#' df[,"var1"] <- as.factor(df[,"var1"])
+#' df[,"var2"] <- as.factor(df[,"var2"])
+#' df <- killfactor(df)
+#' apply(df,1,function(x) is.factor(x)) # FALSE FALSE
+#' 
 #' @export killfactor
 			killfactor=function(df){
 				for (i in 1:ncol(df))

Modified: pkg/stacomirtools/R/utilities.r
===================================================================
--- pkg/stacomirtools/R/utilities.r	2017-07-13 06:36:15 UTC (rev 439)
+++ pkg/stacomirtools/R/utilities.r	2017-07-13 06:37:56 UTC (rev 440)
@@ -7,6 +7,8 @@
 #############################################
 
 
+
+
 #' function used to print the html tables of output (see xtable documentation)
 #' 
 #' see \pkg{xtable} for further description, an xtable is created and printed
@@ -36,6 +38,8 @@
 #############################################
 
 
+
+
 #' This function replaces the variable names in a data.frame
 #' 
 #' This function replaces the variable names in a data.frame
@@ -46,6 +50,19 @@
 #' @param new_variable_name a character vector with new variables names
 #' @return object
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples
+#' 
+#' df <- data.frame("var1" = c("blue","red"), "var2" = c("nice","ugly"))
+#' colnames(df) # "var1" "var2"
+#' df <- chnames(object = df, old_variable_name = c("var1","var2"), 
+#' "new_variable_name" = c("color","beauty"))
+#' colnames(df) # "color"  "beauty"
+#' # the following will return an error, as the variable wrong_name is not in variable names
+#' \dontrun{
+#' chnames(object = df, old_variable_name = c("wrong_name"), 
+#' "new_variable_name" = c("color")))
+#' }
+#' 
 #' @export chnames
 chnames=function(object,
 		old_variable_name,
@@ -61,6 +78,8 @@
 
 
 
+
+
 #' unique values of a vector
 #' 
 #' returns the index of values appearing only once in a vector :
@@ -71,6 +90,10 @@
 #' @param a a vector
 #' @return the index unique values within a vector
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples
+#' 
+#' induk(c(1,1,2,2,2,3))
+#' 
 #' @export induk
 induk=function(a){
 	sol=match(unique(a),a)     #index des valeurs uniques
@@ -94,6 +117,8 @@
 
 
 
+
+
 #' ex fonction to write to the clipboard
 #' 
 #' ex fonction to write to the clipboard
@@ -115,6 +140,8 @@
 
 
 
+
+
 #' id.odd function modified from package sma
 #' 
 #' id.odd function modified from package sma (which did not verify that the
@@ -124,6 +151,11 @@
 #' @param x integer
 #' @return a logical
 #' @author Adapted from Henrik Bengtsson
+#' @examples
+#' 
+#' is.odd(1)
+#' is.odd(2)
+#' 
 #' @export is.odd
 is.odd=function (x) 
 {
@@ -141,6 +173,8 @@
 }
 
 
+
+
 #' is.even function modified from package sma
 #' 
 #' is.even function modified from package sma (which did not verify that the
@@ -150,6 +184,11 @@
 #' @param x integer
 #' @return a logical
 #' @author Adapted from Henrik Bengtsson
+#' @examples
+#' 
+#' is.even(1)
+#' is.even(2)
+#' 
 #' @export is.even
 is.even=function (x) 
 {
@@ -168,6 +207,8 @@
 
 
 
+
+
 #' Function to transform a ftable into dataframe but just keeping the counts,
 #' works with ftable of dim 2
 #' 
@@ -177,6 +218,12 @@
 #' 
 #' @param tab a flat table
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+#' @examples
+#' 
+#' df <- data.frame("var1" = c("blue","red"), "var2" = c("nice","ugly"))
+#' ftdf <- ftable(df)
+#' tab2df(ftdf)
+#' 
 #' @export tab2df
 tab2df<-function(tab){
 	if (length((attributes(tab)$dim))>2) stop("only works with tables of dim 2")



More information about the Stacomir-commits mailing list