I am facing a problem using plumber, when I "plumb" my code all my data.tables are reset to data.frame after each set of operations.
I thought the issue could be due to environment.I tried to play with envir parameter in the plumb function but nothing seems to work.
I have tried both versions of plumber (CRAN repo and Github). Any help/ directions would be highle appreciated, thanks in advance!
P.S. The code works fine w/o plumber.
Related
I'm using vegan 2.6.4 in RStudio, and have had an unusual error message pop up when I run the the following:
nmds11 = metaMDS(m_com11, distance = "bray")
data.scores11 = as.data.frame(scores(nmds11)$sites)
Error in UseMethod("scores") :
no applicable method for 'scores' applied to an object of class "c('metaMDS', 'monoMDS')
I can safely say this has never happened to me, and I was using the exact same code on a different dataset 5 minutes ago with no issues. I have also previously run this same script on at least a dozen other matrices with no errors.
I have tried calling scores.metaMDS as suggested when looking up the scores function (to help specify what type of object I'm trying to get scores from), but that function apparently does not exist. I've also tried running some old scripts that always worked in the past, with the same unfortunate results.
Any idea what I can do to address this?
Try using vegan::scores(); it could be that some other package you have loaded also has a scores() generic that is overwriting vegan::scores(). You can also try the much more specific vegan:::scores.metaMDS() if the whole S3 system has gotten clobbered.
Beyond that, restart R (in RStudio, find the Restart R option in the menus) so you get a clean session and try running your code again.
I I tried vegan:::scores.metaMDS() without restarting RStudio and it works ! Thanks !!!
I'm trying to work through some of the examples in this article around table generations using expss - https://cran.r-project.org/web/packages/expss/vignettes/tables-with-labels.html - however, I am consistently getting the error could not find function "setalloccol" using the most basic crosstab functions of cro and fre with two variables:
> cro(df$var1, df$var2)
Error in setalloccol(ans) : could not find function "setalloccol"
I'm using R Studio 1.2.1335 and I've re-installed the packages dplyr, data.table, tidyr and expss itself, but I still seem to get this error with all these libraries running. I've googled the exact error I'm coming up with and there is absolutely zilch on this, so appreciate any help...
Try to explicitly export setalloccol from data.table before running your code:
setalloccol = data.table::setalloccol
# further calculations
# cro(df$var1, df$var2)
'Setalloccol' is an experimental command in data.table used to allocate memory by reference to assure something more stable than a shallow copy is allocated by ':='. 'Expss' looks like a monster library. I won't load it now and track down your error. But since 'setalloccol' is an experimental command, you should find the 'expss' developers and file a defect. There is, however, already a whole gnarly open bug report on this exact issue here: https://github.com/gdemin/expss/issues/42. The developer of data.table ("Matt Dowle") has comment in that bug report. In practice setalloccol works like this:
help(setalloccol)
data.table::truelength(HMR)
[1] 1035
options(datatable.verbose=TRUE)
data.table::setalloccol(HMR,2 * 1035)
data.table::truelength(HMR)
[1] 2081
But it really isn't necessary for most data.table computations. Try to pour over the "expss" code and find why and when they use it. Sorry I am not more helpful.
Thanks to rferrisx for the thread from GitHub. The post from josie-athens from 3rd Nov 19 seems to fix this issue, though I didn't run R from Bash. So my process was:
Uninstall expss and data.table packages: remove.packages(c('expss','data.table'))
Reinstall above packages: install.packages(c('data.table','expss'))
This seems to bypass the error. Not entirely sure why though but hopefully helpful for somebody experiencing the same thing.
For what it's worth, I just ran into the same issue and wanted to give my two cents. This seems to be a matter of the order in which you load the packages, since the "expss" package masks several functions of the "data.table" package and vice versa. Try reversing the loading order. At least that solved the issue for me.
I am using the isoriX package in R and would like to update part of the source code. When I try to run it without making any changes yet, R doesn't seem to recognise any function preceded by a dot.
Am I missing any packages that should be installed in order to allow me to use those kind of functions or to update the source code?
The code I am trying to apply is quite long, but the bit R struggle with is the following function:
.complete_args()
Any ideas? Thank you!
The isoriX:::.complete_args() call worked.
You can access unexported function with ::: and in my case isoriX:::.complete_args() worked well.
I am fitting a GLMM and I had seen some examples where is used the function: overdisp_fun, deļ¬ned in glmm_funs.R, but I don't know which package contain them or how can I call it from R, can somebody help me?
Thanks,
If you google for glmm_funs.R, you'll find links to the script (eg here: http://glmm.wdfiles.com/local--files/trondheim/glmm_funs.R).
You can save the file on your local machine, then call it in your R session with source("path to file/glmm_funs.R").
You will then be able to use the functions contained in the script, including overdisp_fun().
You can think of it a little bit like loading a package, except the functions are just presented in a script.
My emacs/ess session crashes when I try to access help. This happens if I have two packages loaded with the same functions; for example:
library(lubridate)
library(data.table)
?month
In Rgui interface pops out and asks to choose from which packages I want help. Emacs just crashes. Similar issues happens with install.packages, but there is a way to specify mirror Is there a way to install R packages using emacs?
Is there a similar trick with help?
Well, there is no full proof solution for time being as nobody really understands why these crashes happen. I assume you are on windows, right?
There are plans in ESS to completely internalize all the help (and other) calls in order not to depend on R dialogs. Hopefully in the next version.
For time being put this into your .Rprofile
tis <- utils:::index.search
formals(tis)[["firstOnly"]] <- TRUE
assignInNamespace("index.search", tis, "utils")
It basically makes help system to pick the first package with the found topic. In your case month help page in data.table package will be ignored. Not a big deal as common topic names are quite rare anyways.
I found out that starting library(tcltk) solves this problem. Menu appears even after it is called from emacs+ess. I added library(tcltk) to my Rprofile.site and now everything works great, install.packages() and accessing help when multiple packages load same function