Category "r"

Aligning ggmap and geom_sf maps

I am having problems aligning two maps. They appear to have the same crs but still look off a bit. Notice the California-Nevada border and the California coast.

How to run cor.test() on two different dataframes

I would like to run cor.test() on two seperate dataframes but I am unsure how to proceed. I have two example dataframes with identical columns (patients) but di

The raster overlay function in R produces incorrect values for raster bricks

I'm trying to quantile match two RasterBricks. I am finding the percentile of value<=250 in old_data, which we'll call p. Then I'm finding the value at the p

Relative paths in R: how to avoid my computer being set on fire?

A while back I was reading an article about improving project workflow. The advice was not to use setwd or my computer would burn: If the first line of your

Strange ED50 with drc

I am trying to estimate IC50 values with the drc package. Plotting the model works fine. But when I use the ED I get unreasonable results. In my understandi

Using a matrix plot (matplot) as map and positions as locations

I'm interested in using a matrix plot as a field map and certain locations in matrix as specific plants (locations within field). I'm using this data: Field<

compare two tables having same column name but different date column names

I have table A id1 dt x1 2022-04-10 a2 2022-04-10 a1 2022-04-10 x1 2022-05-10 x2 2022-04-10 y2 2022-04-10 y1 2022-05-10 x1 2022-06 -10 Table B id1 dt a1 2022

R packge install from GitHub - "'' does not exist in current working directory

I have built a new package, and it is hosted on GitHub at github.com/kevinwolz/hisafer. I am trying to install the package via devtools::install_github(), but

Check how many downloads a CRAN package has?

How can I get simple download metrics for an R package on CRAN? I recently released my own package on CRAN and I want to monitor it a bit.

How to generate random correlated uniform data from a correlation matrix?

I have a very specific problem to solve that makes researching a solution quite hard because I lack the requisite math skills. My goal: Given a covariance/corre

Custom imputation function for MICE stopped working

Last year I used info from this question to build a custom function to impute missing data under a simple logical constraint using MICE in R. The following code

Using ggplot for confidence intervals display

I've got to build a plot of mean values and 99% confidence intervals (based on t-distribution) of data set cuckoos from package DAAG. Here is my solution ggplot

A difference of Python from R

Coming from R, the following Python code does confuse me: In [22]: a = [1, 2, 3] In [23]: b=a In [24]: b Out[24]: [1, 2, 3] In [25]: b[0]=100 In [26]: b Out[26]

How to connect R conda env to jupyter notebook

I am creating conda environment using following code conda create --prefix r_venv_conda r=3.3 r-essentials r-base --y Then I am activating this env by fol

How to do a Join and a Loop corectly using R

I have two sets of data that have a column mean_wage in common, but they are described differently. First one as 1 (wage), 2, 2.4 ... and the other one as 1256.

Is there any good reason for columns to be characters instead of factors?

This may seem like a silly question, but after working with R for a couple of months, I realised I often find myself converting strings to factors as, for examp

Is it possible to customize the size of rpivottable treemaps

This code works and the pivot table is drawn but the treemap is huge and I need it to render to about 50% of the current size, 500px would be fine for now. It s

Remove duplicate combinations in R [duplicate]

I am using R and I would like to remove combinations in a data.frame. Unique function does not seem to do the job. a b c 1 1 4 A 2 2 3 B 3

Making a while loop more efficient for use on a large data.table to delete rows based on certain conditions

I have a pretty big amount of data in a data table. I would like to delete a number of rows if there is a certain value in a cell. Below is an excerpt from my d

Include 'blank' filters in dplyr filter chain in Shiny app

I have a shiny application with numerous user inputs including numericInput and textInput and pickerInput. These inputs are used to filter a dataframe. In my fi