So, I'm currently converting my R script which runs just perfect into a RShiny app. The code is very long and I can't share it all but it involves forecasting various variables under different scenarios. While running it as an R code, I load equations from .Rdata file which has all equations & coefficients stored. However, when I;m trying to do it in Rshiny, it says object not found. Here eq_asset is the equation for asset variable I'm loading, pfw_test is a database. Error is Error in paste0: object 'z' not found which is coming from equation I'm loading because when I type equation (not load it), it runs just fine. I've tried loading equations .Rdata file in server, in UI etc but the same error shows up.
Related
First, I'll apologize for not having a fuller reproducable example, but I'm not entirely sure how to go about that given the various layers to the question/problem.
I'm moving a blog over from Blogdown to a new Quarto-based website and blog. I have three saved brms object files that I'm trying to read into a code chunk in one of the posts. The code chunks work fine when I run them manually, but when I try to render the blog post I get the following error:
Quitting from lines 75-86 (tables-modelsummary-brms.qmd)
Error in stri_replace_all_charclass(str, "[\\u0020\\r\\n\\t]", " ", merge = TRUE) :
invalid UTF-8 byte sequence detected; try calling stri_enc_toutf8()
Calls: .main ... stri_trim -> stri_trim_both -> stri_replace_all_charclass
Execution halted
I've checked the primary data frame contained in the brms model object and all of the character vectors there are valid UTF-8 vectors. These models objects can be quite large, so it's possible I'm missing something buried deep within the model object, but so far it's nothing apparent.
I tried re-running the models again to ensure that the model objects' files weren't corrupted, and also to make sure that the encoding issue wasn't somehow introduced the last time they were run, which would have been on a Windows machine and a different version of brms.
I've also moved the brms files around to different directories to see if it's a file path issue. The same error comes up regardless of whether the files are in the same folder as the blog post qmd file or in a parent directory file I use for storing site data.
I've also migrated several other posts to the new Quarto site successfully, and some of them also contain R code, but it's all rendering without a problem.
Finally, I don't quite understand how to implement the suggersted alternate function found in the error message either.
I tried to transfer some ggplots from my work computer to my home computer. I saved the plots as an .Rdata-file with the standard save function. I loaded the object with the load function at home. I get the following error:
"Error in coord$backtransform_range(panel_params) :
attempt to apply non-function"
I have no problems making new ggplots without getting the error. Neither when I save these plots locally and load them again. I've also tried transferring the plots both through gmail and with my cell phone as a storage unit. Both computers use Windows 10 operating system.
I get the error when I run the following bit of code
library(tidyverse)
load("Object.Rdata")
object$main_plot
I did not expect that this would cause an error. Am I missing something obvious?
I get this error when running;
me_1 <- maxent(pred, occ, args='biasfile=bias')
Error: Bias grid cannot be used with SWD-format background
where 'pred' is a raster stack, 'occ' is a csv file of lat/lon, and 'bias' is a raster. The model runs fine without the 'args'. The error suggests that it thinks I'm using a SWD (species-with-data) file but I'm not. Have checked the str() on each input file. I've updated everything (R, RStudio, dismo, maxent.jar). Running on Windows 10. I see others have had this problem on the Maxent user group, but no solutions. Any help appreciated. thanks.
To update - it may be that dismo does not have biasfile implemented. However a workaround can be found here
https://groups.google.com/forum/#!msg/Maxent/kUZTkSiDxbU/i_-cDR4aN8MJ
I do have a *.r file where I order it to coduct a Chi Square of Independence and write it to an html file. It's working fine but I'd like to add a graph.
Doing by hand in R with linecommands works perfectly, but the exact same commands do not work in the *.r file but i want it to do it automatically.
mat1 <-matrix(c(12,3,2,12),nrow=2,byrow=T)
attach(mat1)
png('independence.png')
barplot(mat1,beside=TRUE)
dev.off()
Is there an additional command necessary?
kind regards
If you have an error in a script with no try or tryCatch, then entrie script fails. By trying to attach a matrix, you throw an error with the message:
Error in attach(mat1) :
'attach' only works for lists, data frames and environments
So you should pay more attention to the error messages in interactive mode, and if you are planning to use .r files for production you should learn to use error handling routines in R. The `attach function is a common source of new user errors, although this error is not particularly common. The more common errors with its use involve regression functions where the authors of the functions are expecting entire objects, usually dataframes, to be passed to a data argument.
If I have more data loaded in R I'm having difficulties with opening and choosing new file via file.choose() and later upload via read.csv(), but I would not get to that point since the file.choose function stacks and the R "crushes" and reports something like "unidentified error occurred and that the R must restart".
I'm using RStudio and running this on Windows 7. The hardware is up to date.
Could someone point me on why this is happing and what would be a remedy against this. Are there other options to select file? I know I can insert the path right into the read.csv command, but the (file is different every time).
EDIT:
The error just happened again. I can not reproduce the error so it happens rather only with high likelihood if the conditions for it are met.
The error reads as: R Session Aborted.R encountered fatal error. The session was terminated. And in window: "Start New Session".
EDIT 2:
I would just rephrase my question. The question is whether there is other option like command or package that deals with choosing a file. [file.choose()]
The error can not be reproduced and hence I can not expect someone gives reasonable comment on this. But if this occurred someone in the past and solved it, I would like to hear about it. Thanks.
EDIT 3: Further to the error. I have spotted just now sentence in red in Console: Error: Unable to provide connection with R