Get Screen resolution for any Operational System with R
How can I get screen resolution (height, width) in pixels for any OS with R? The closest approach I could find is below but still could not work in Linux? Any suggestions?library(rJava) .jinit()...
View ArticleIs there an R function for adding categories to simulated data?
I have the mean and the standard deviation of 8 different schools from Gelman's school data example for hierarchical models. The thing is that you only have 8 observation and since I have the mean and...
View ArticleForce / edit axis values in latticeExtra
I'm using one dataset where the variable present in X has only two possible values - 2009 or 2010. 2009,01,52.4 2009,01,49.5 2009,01,53.2 2009,01,48.2 2009,01,53.9 2009,01,42.8 2009,01,56.4 2009,01,57...
View ArticleHow does shiny determine dependencies
While working on an app, I noticed shiny recalculates an output when it is not necessary (in my opinion), and it seems to depend on the nesting in reactiveValues.UI:library(shiny) n <- 5 o <-...
View Articlecorrelation plot (with unique values) based on 2 variables
I have a dataframe like this:df <- data.frame( "var1" = c("A", "A", "A", "B", "B", "C"), "var2" = c("B", "C", "D", "C", "D", "D"), "corr" = runif(6, -1, 1), "p_cat" = sample(1:3, 6, replace=T))...
View ArticleHow to show boxplot flipped with another plot without flipping it?
I want a boxplot to be overlayed on histogram. to avoid missing with the histogram, I am forced to draw the boxplot like that:library(ggplot2) ggplot(iris) + geom_boxplot(aes(x = Sepal.Length, y =...
View ArticleRemove trailing punctuation from string
I am trying to delete all dashes that appear at the end of a string and my code is causing R to crash. Any tweaks or code fixes that might not cause this would be greatly appreciated!acct_nm =...
View Article'math.h' file not found when using Rcpp on MacOS Catalina
I am aware of many other questions where this has been asked, but I have not found any that concerns Mac OS Catalina. I have seen this and this are relevant.I recently updated my Mac to Catalina, and I...
View ArticleKolomogorov-Smirnov test: C to R translation issue
I am having difficulty with translating an algorithm from C to R. It's about Kolmogorov Smirnov test, and more specifically the KS probability function In 'Numerical Recipes in C', 'probks', it's coded...
View Articleroots argument in shinyFileChoose() is not reactive to input
I'm trying to use shinyFileChoose() in one of my applications, the problem is, the top-level directory where I need to let users search is fairly large and has thousands of subdirectories, thus slowing...
View ArticleHow to convert to genre, production companies, cast which are JSON column...
https://www.kaggle.com/rounakbanik/the-movies-dataset this is the dataset I was using. I tried the following code in R:toJSON(movies) %>% validate() json_to_df <- function(df, column){ column_1...
View Articleplotly with rmarkdown on pdf
I tried to use a plotly figure in a pdf through an rmd file. I used the simple method described in: https://plot.ly/r/knitr/ I have the following sessionInfo:> packageVersion('plotly') [1] ‘4.9.0’...
View ArticleAdding buttons to Shiny DT to pull up modal
I am trying to add a column of buttons in my datatable that when clicked will pull up a modal but I am having trouble using the examples I found online here and here.Some of my requirements:Needs to...
View ArticleR Customer state concatenate string
I would like to use levenshtein distance to calculate the behaviour of a customer and in which status the customer was in each year concatenated with the previous status. In Tableau, I have calculated...
View ArticleWhy names() function does not show up in sys.calls() output stack - R
I defined the following function in R to test the output of sys.calls(), a function that returns the function calling stack:show_syscall_stack = function() { print(sys.calls()) invisible(list(x=2,...
View ArticleCreating an R loop for writing CSV files from tables
I have a number of tables in R studio, named "zero.cells", "one.cells" (etc) up to "fifteen.cells".I would like to write all of these tables in csv using write.csv2, for example write.csv2(zero.cells,...
View ArticleIn R: find the closest value within group_by excluding self comparisons
I would like to find the value in a column that is has the absolute lowest difference to the each row in the same column.I've tried solutions from find value closest to x by group in dplyr and return...
View ArticleRanking continuous data in decreasing order
I have a dataframe like this one:set.seed(123) df0 <- data.frame(x1 = rnorm(5, 0.1, 1), x2 = rnorm(5, 0.0, 1), x3 = rnorm(5, 0.3, 1), x4 = rnorm(5, 0.2, 1)) df0 x1 x2 x3 x4 1 -0.4604756 1.7150650...
View ArticleCamTrapR help! including another subfolder (number of individual occuring) to...
I'm stuck on with camTrapR. Creating a record table based on how I have arranged my "directory".7000 camera trap images were saved into a main folder and two sub folders as: camera station > species...
View Articlehow to solve nonlinear with BBsolve
I tried to solve a nonlinear system using BBsolve, but it did not work i got this:Error in optim(par = par, fn = U, method = "Nelder-Mead", control = list(maxit = 100), : function cannot be evaluated...
View Article