Why does R Studio freeze when I enter a non-existing variable?
Sometimes when I misspell a variable/function (and in particular when the RAM usage is >80% and some of the data is on SWAP) the R freezes and uses 1 core of the CPU. After (more than) a few minutes I get an error message. During this time I am unable to terminate R.
Why is this happening and is it possible to fix it?
I am on
Linux Mint 18.1 64bit, Cinnamon V3.2.7, Linux Kernel 4.4.0-138-generic, RStudio Version 1.1.456, R version 3.5.1 (2018-07-02)
See also questions close to this topic
Why is .png file not looking clear after arranging using grid.arrange?
I am trying to arrange 9 png files (which I had created using plot() function) in 2 columns. But these files are not looking clear after using grid.arrange to arrange them.
I think if page size is increased, the images will be clearly visible. Or there might be some problem with the size of my plotes converted to .png.
Please suggest me a solution.
Following is the code I am trying:
[install.packages('png') install.packages('gridExtra') library(png) library(grid) library(gridExtra) p1 <- readPNG('p1.png') p2 <- readPNG('p2.png') p3 <- readPNG('p3.png') p4 <- readPNG('p4.png') p5 <- readPNG('p5.png') p6 <- readPNG('p6.png') p7 <- readPNG('p7.png') p8 <- readPNG('p8.png') p9 <- readPNG('p9.png') grid.arrange(rasterGrob(p1), rasterGrob(p2),rasterGrob(p3),rasterGrob(p4),rasterGrob(p5), rasterGrob(p6),rasterGrob(p7),rasterGrob(p8),rasterGrob(p9),ncol=2)]
How to use map/reduce and read_csv to import a subset of columns from multiple files
I need to import multiple files into R. From each file I only need a subset of columns. I have working code that will import ALL 97 columns from an arbitrary number of files, but cannot figure out how to limit the import to only the 4 columns I need.
I rely on the tidyverse for many of my functions. R version: 3.6.0
I have created code that imports limited columns from a SINGLE file but cannot expand this to all files.
#this code works correctly and imports all columns from multiple files setwd('R:\\Data\\Raw Data Files') files <- c('686960.csv','686962.csv','686963.csv','623056.csv','608910.csv','608911.csv','609248.csv','609246.csv', '722178.csv', '722177.csv', '756542.csv') data <- files %>% map(read_csv) %>% reduce(rbind) #this code works correctly and imports 4 columns from 1 file test <- test_file %>% read_csv( col_types = cols_only( 'Member ID' = col_character() ,'Patient Age' = col_character() ,'Plan Payment Amount' = col_character() ,'Check Date' = col_character() ) ,n_max = 10 ) #this code produces an error setwd('R:\\Data\\Raw Data Files') files <- c('686960.csv','686962.csv','686963.csv','623056.csv','608910.csv','608911.csv','609248.csv','609246.csv', '722178.csv', '722177.csv', '756542.csv') data_test <- files %>% map(read_csv( col_types = cols_only( 'Member ID' = col_character() ,'Patient Age' = col_character() ,'Plan Payment Amount' = col_character() ,'Check Date' = col_character() ) ,n_max = 10 )) %>% reduce(rbind) #Error in read_delimited(file, tokenizer, col_names = col_names, col_types = #col_types, : # argument "file" is missing, with no default
How to make sure the user of a shiny app is using the right package versions in R
Due to recent experience with several bugs created by updating packages, I wonder what the best approach is for the following problem:
I currently provide a stand alone version so to say of my shiny App (just the script files to run it locally) and run a long list of require() functions to load / install the needed packages. However, in the end I would like to use fixed package versions to avoid bugs created by changes in packages.
Is there a way to ensure that the user, who may have older or newer versions of packages on their computer, is using the right version of all the packages my app needs?
http://localhost:6000/__swagger__/ might be temporarily down or it may have moved permanently to a new web address. Plumber swagger-UI not working
In RStudio when I try to run a plumber server with a specific port number, the swagger-UI is not working. If I run the server without specifying the port it will work fine. Notice that the API is working, is just the swagger-UI that is missing.
How can I fix this? Also, there is a way to get to see the swagger file?
Here is the R and RStudio versions:
RStudio v1.2.1335 Build 1379 (f1ac3452)
This is the output of the 'version' command:
>version platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status major 3 minor 6.0 year 2019 month 04 day 26 svn rev 76424 language R version.string R version 3.6.0 (2019-04-26) nickname Planting of a Tree
Passing this code swagger-UI works:
# my-script.R library(plumber) r <- plumber::plumb("server.R") r$run()
Passing a specific port number it won't work:
r$run(port = 6000)
Api working but swagger-UI not available even if the output shows otherwise. Thanks in advance for your help.
Calculate α and β in Probit Model in R
I am facing following issue: I want to calculate the α and β from the following probit model in R, which is defined as:
Probability = F(α + β sprd )
where sprd denotes the explanatory variable, α and β are constants, F is the cumulative normal distribution function.
I can calculate probabilities for the entire dataset, the coeffcients (see code below) etc. but I do not know how to get the constant α and β.
The purpose is to determine the Spread in Excel that corresponds to a certain probability. E.g: Which Spread corresponds to 50% etc.
Thank you in advance!
Probit model coefficients
probit<- glm(Y ~ X, family=binomial (link="probit")) summary(probit) Call: glm(formula = Y ~ X, family = binomial(link = "probit")) Deviance Residuals: Min 1Q Median 3Q Max -1.4614 -0.6470 -0.3915 -0.2168 2.5730 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.3566755 0.0883634 -4.036 5.43e-05 *** X -0.0058377 0.0007064 -8.264 < 2e-16 ***
How to add multiple affiliations to one author in Rmarkdown?
I am using Rmarkdown to write a scientific paper. I struggled in add 2 universities to 1 author. After sexrch a lot, still didn't find suitable solution. My expectation just like this Authora,b.
--- title: my title author: - affiliation: group1 name: Author1 - affiliation: group2 name: author2 address: - address: abc code: group1 - address: b code: group2
I hope author1 could have two groups as their address.