Launching R help: Error in file(out, "wt") : cannot open the connection
I want to launch R help, I type ?dir.create. It is giving me this strange error:Error in file(out, "wt") : cannot open the connectionIn addition: Warning message:In file(out, "wt") :cannot open file...
View ArticleUsing match on multiple criteria to generate value in R
I currently have the following data format:df = data.frame(c(rep("A", 12), rep("B", 12)), rep(1:12, 2), seq(-12, 11)) colnames(df) = c("station", "month", "mean") df df_master = data.frame(c(rep("A",...
View ArticleUse sf polygon object as window in spatstat
Hello all potential helpers,I have a SpatialPolygonDataFrame object obtained from the tigris package and I would like to use it as a polygonal window in the creation of a ppp object. Here is what I...
View ArticlePorting bookdown to distill::distill_article doesn't support theorem environment
Trying to implement theorem environment to R distill::article. Followed the instructions from the books on Rmarkdown and Bookdown, and the R Markdown CookbookI found that theorem environments were...
View ArticleSelect the last n columns of data frame in R
Is there a way to systematically select the last columns of a data frame? I would like to be able to move the last columns to be the first columns, but maintain the order of the columns when they are...
View ArticleHow to get around a limit in an R function?
I am doing data analysis on the Acadie portal in fr.wikipedia.org. I am using WikipediR::pages_in_category to make a list of the pages in the portal: library(WikipediR) portal_acadie <-...
View ArticleLabels length 2 should be 1 or 0
I have this data:library(dplyr) dframefull <- data.frame(id = c(1,1,1,1,1,1,1,1), name = c("Google", "Google", "Google", "Google", "Google", "Google", "Google", "Google"), date = c("12/8/2014...
View ArticleR: Find Minimum Value in Column of Data Frame that is Greater Than or Equal...
First time asking a question (be gentle) since I haven't been able to find anything that works.In R I have two data frames. One (DataFrameA) has a column with a list of unique dates. The other...
View ArticleR : quick way for assigning a value to each member of a group
I need to attribute a weight to each member of a group. I have made the following loop to create the weights_ind vector (vector of individual weights), but my loop is too slow (2 seconds for 2000...
View ArticleApplying a custom function to every row in r
I created a function to calculate the rollmean of a row in a dataframe:rollmean_circular <- function(x) {t(rollmean(t(cbind(x[9:10],x,x[1:2])),5))} df <- structure(list(X1 = c(5L, 5L, 9L, 0L, 9L,...
View ArticleCounting the number of elements in a list and then taking the counting as a...
I have a vector: x <- c(0.8,1.0,661.7,661.8,661.9,662.3,662.6,662.7,663.3,663.6,663.7) I have used function as.data.frame(x) to make following data frame: X1 1 0.8 2 1.0 3 661.7 4 661.8 5 661.9 6...
View ArticleEnvironmental problems while predicting from gaulss-gams with a custom...
A variance function available within an R package is not found by the predict function while doing predictions from a gam-object constructed previously (mgcv 1.8-31).The R package shall (amongst other...
View ArticleIs the order always kept and respected when programming in R?
What I mean is that when I have a matrix or data frame with 10 rows, if it's newly created row names go from 1 to 10. I want to make sure that if I type a vector with given names (like:...
View ArticleHow can I configure the default settings of RStudio?
I launch RStudio in a Docker container and access to it via the browser in the host OS. I prefer the settings Console on Right and Emacs Key Bindings, so usually check these options by hand in GUI. The...
View ArticleR Shiny - cache big dataframe
I'm quite new to Shiny, so my apologizes if my question is an easy one. I tried to check on google and stackoverflow but couldn't locate a simple and helpful answer so far. What's my goal/issue: I'm...
View ArticleIn R, how to prevent blank page in pdf when using gridBase to embed subplot...
As explained here, it is easy to embed a plot into an existing one thanks to gridBase, even though both plots use the base graphics system of R. However, when saving the whole figure into a pdf, the...
View ArticleRandom sampling by category, different number of samples needed per category...
This question already has an answer here:Stratified random sampling from data frame 5 answersI have a question to do some random sampling in R. I have two datasets. One dataset, say df1, is organized...
View ArticleHow do I start up RStudio to point to a non-default version of R on Windows
I have R 3.5 and 3.6 installed on my Windows machine. My RStudio by default points to 3.5. I want to start up RStudio to point to 3.6 for some sessions. How do I do that without messing with the global...
View ArticleLeaflet - europe spatial network plot and distanced island removal
I probably have very complex question related to leaflet, I am trying to plot multile countries of Europe (data downloaded from GADM), and then create a network matrix for countries, however france...
View ArticlePlotly Sankey finetuning; node alignment along x-axis, drop-off
The following diagram is close to what I am looking for, however I would like to know if the following is possible:Left-alignment of nodes rather than justified along the x-axis?, so for e.g., a flow...
View Article