Quantcast
Channel: Active questions tagged r - Stack Overflow
↧

Image may be NSFW.
Clik here to view.

How to plot text only, without any margin, in a tiff file?

I want to build a tiff file with text only and no margins around the text, using R.I tried :library(ggplot2)plt <- ggplot() + geom_text(aes(x=0,y=0,label="test")) +...

View Article


For the same longitude or latitude raster data use the function based on terra

Assuming that I need to calculate the variance of the raster data for the same longitude, Is using the sapp function the right way to go? But I failed.I can now use the more complex method of...

View Article


is it posible to fit a multivariate linear model using lmtree?

I want to fit a lmtree where the response is multivariable. You know that you can fit a Multivariate Multiple Regression using lm function as follows:lm(cbind(Y1, Y2) ~ X1+X2+X3, data = my_df)so I...

View Article

Is there a way to calculate IQR for dates in gtsummary

I want to have IQR for dates but when I run the code there are columns with NA...library(tibble)library(gtsummary)set.seed(123) # Set seed for reproducibilitydate_tbl <- tibble( start_date =...

View Article

Conditional join in data.table?

I have the following data.table, dtgrouped2: MonthNo Unique Total 1: 1 AAA 10 2: 1 BBB 0 3: 2 CCC 3 4: 2 DDD 0 5: 3 AAA 0 6: 3 BBB 35 7: 4 CCC 15 8: 4 AAA 0 9: 5 BBB 6010: 5 CCC 011: 6 DDD 10012: 6 AAA...

View Article


How to loop through a list of data frames and assign the numeric portion of...

I have a list of data frameslist.files("data frame - 12345 - App", "data frame - 34567 - App", "data frame - 65849")Each data frame looks like thisCol1|Col2 |Col3Row1 Info1 NewInfo1Row2 Info2 NewInfo2I...

View Article

R shiny - Return json from server.R to POST request

I'm trying to use shiny to mimic an API.I've got a shiny app that reads parameters in the url (with parseQueryString(session$clientData$url_search)), computes a map based on those parameters, and...

View Article

Compare vector with all permutations of another vectors using identical()

Is there an argument for the R function identical that allows me to compare a vector with a permutation of the elements, such as in reverse order? Could not find anything in the help files. If not, how...

View Article


R - mice - machine learning: re-use imputation scheme from train to test set

I'm building a predictive model and am using the mice package for imputing NAs in my training set. Since I need to re-use the same imputation scheme for my test set, how can I re-apply it to my test...

View Article


Converting a "map" object to a "SpatialPolygon" object

I am guessing there is a simple solution to the problem I have been having, but I am having some trouble.I am trying to convert the following map object:require(maps)usa <- map("state")into a...

View Article

VSCode R: Outline view disappears after adding new section headers in R scripts

Describe the bug:I use the R extension in VS Code and have been using the outline view for years (REdditorSupport). Now, the outline view when I use R in VS Code initially displays symbols (functions,...

View Article

Weird behaviour of the car::boxCox() function when wrap into a homemade function

I'm trying to wrap the car::boxCox function into a homemade function so I can mapply it to a list of datasets. I'm using the boxCox function from the car package and not the MASS package because I want...

View Article

R Error in psych::polychoric() "Error in cor(x, use = "pairwise") : supply...

I'm pretty inexperienced in R so apologies!I'm trying to run psych::polychoric(), but each time I get this error messageError in cor(x, use = "pairwise") :supply both 'x' and 'y' or a matrix-like...

View Article


Programmatic way to apply list of functions to list of columns in dplyr...

I have about 40 columns that I want to summarize by group using dplyr::summarize(). But each column is going to be summarized with a different function: some with mean(), some with sum(), some with...

View Article

Image may be NSFW.
Clik here to view.

How do you stop ggcurve closed arrowheads looking like they have a "bite"...

When I draw an arrow with ggcurve, each end has a small piece missing. (Probably because I'm using a large size, but I want that aesthetically.) Is there a workaround? Code...

View Article


Is there a way to import multiple mdb files into R at once?

I would like to import multiple mdb files into R at once and join them into one data frame.Is this possible with RODBC?I have no problem reading individual files using the code below:df1 <-...

View Article

How to fix invalid command name "tk_messageBox" in R

Hello this is the error I have been getting on my Mac when I try to run R commander on R studio/R. I was wondering if anyone knows how to fix this. Thanks!Error: package or namespace load failed for...

View Article


Flip month and day around, creating a new column

I am trying to create a new column with the day and month of a date of birth flipped. For example, 1994-01-02 would become 1994-02-01. Any non-credible dates would be turned to NA, so for example,...

View Article

How do you calculate IRR in R (without using any packages)?

I am trying to calculate IRR from by using input from a existing dataframe. I have used Newton-Raphson method iteration for calculation. However, I am not able to get an output.Further, the warning...

View Article

Getting inputs from a separate module in R Shiny

I've scoured SO for the answer to this question, and I have tried solutions from multiple threads, so I am not sure what I continue to do wrong with this. I am trying to make a master filter list for...

View Article

How to pair stores, products by week and run computation in R?

I have weekly price data for the same 300 products in 10 stores for 5 years. Out of the ten, 7 are in states where a particular policy has been implemented and 3 where it hasn't been. This is indicated...

View Article


How to write warnings and error generated in rendering rmarkdown file in a...

I have a rmarkdown setup to take input of csv data and saves results in xlsx and word file. I am rendering the rmd file within trycatch to save the warnings created within in a log file. But looks like...

View Article


Image may be NSFW.
Clik here to view.

Plumber does not find request body

I am currently writing a webhook on a heroku server and for some reason I am having difficulty obtaining the values stored in the body of the request as it always seems to turn up as NULL. My app.R...

View Article

How to use rules to accomplish specific variable factors in synthpop?

I have run into a series of challenges using the "rules" function for the synthpop package on R and would greatly appreciate advice or assistance.In short, I have a dataset of several variables that I...

View Article

Image may be NSFW.
Clik here to view.

Making a plot in R, struggling with the formatting [duplicate]

I am currently making a barplot in R to compare two different attempts at the same experiment. However, the layout of the barplot is not how I want it to be. The order of the two experiments is wrong,...

View Article


How can I group_by/aggregate/collapse with keys that are approximate in R?...

Here is a small subset of my data as a result of using pivot_wider.df<-structure(list(`Component Name` = c("Compound1", "Compound1", "Compound1", "Compound2", "Compound2", "Compound2", "Compound2",...

View Article

Image may be NSFW.
Clik here to view.

ggplot2: Y-axis order not maintained when using ordered factor and facet_wrap

I'm generating a bar plot with ggplot2 using facet_wrap to show activity participation by municipality, with the Y-axis representing income ranges. I've preprocessed my data to order the 'Actividad'...

View Article

How do I scrape a dynamic website with Rselenium? [closed]

I can scrape data from static websites fairly easily; but I don't know how to use RSelenium to scrape dynamic web sites.I need to get the population totals for each of the electoral districts at...

View Article

fill() did not fill the variable value as expected

I try to fill variable value with the value that belong to the same ID. For some reason my code did not work. No error message but no fill happen.Could any one tell me why. Did I mess up anything?here...

View Article



Image may be NSFW.
Clik here to view.

terra::extract() leads to artifacts at map boundary / date line

I want to use terra::extract() to extract values from a pixel raster into a set of polygons (for later calculations). However, this leads to artifacts at the map boundary/date line.See some example...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>