Dasonk / docstring

Provides docstring like functionality to R functions without requiring the need to create a package.
57 stars 6 forks source link

It can't work when I source the function in the other .R file. #23

Open EularTang opened 5 years ago

EularTang commented 5 years ago

Hi, Thanks for your great job!But I encountered trouble in using the package 'docstring'. When I code the own function in the another .R file and source it, The function docstring will report an error and will not display any help files.Details are as follows:

source('/home/tangchen/vde/ls.R')
docstring(define_sce)
Error in docstring_to_roxygen(fun, fun_name = fun_name, default_title = default_title): This function doesn't have any detectable docstring
Traceback:

1. docstring(define_sce)

2. docstring_to_roxygen(fun, fun_name = fun_name, default_title = default_title)

3. stop("This function doesn't have any detectable docstring")

But if I input my own function in console, everything will be OK.The words following the #' can be showed. So what should I do to be able to use your function normally when I source the another R file?

define_sce=function(df,coldata=TRUE){
#' Compute similarity [/home/tangchen/code/scRNA_code/scmap_lung.R]
#' define our database
  if (coldata==TRUE){
      coldata=data.frame(cell=colnames(df),cell_type1=colnames(df))
  }
  e <- SingleCellExperiment(assays = list(normcounts = as.matrix(df)), colData = coldata)
  logcounts(e) <- log2(normcounts(e) + 1)    
  rowData(e)$feature_symbol <- rownames(e)    
  isSpike(e, "ERCC") <- grepl("^ERCC-", rownames(e))    
  e <- e[!duplicated(rownames(e)), ] 
  return(e)
}

docstring(define_sce)