Category "r"

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

How does ggplot2 split groups using cut_number if you have a small number of data points?

I am wondering about the "behind-the-scenes functionality of ggplot2 and cut_number. I have some pretty complex data that has many subsets of data with a relati

Transform code of two loops ("For") with lapply or sapply

I am learning how to code in R and I have written a piece of code that calculate the Net Present Value (NPV) of various assets at different points in time, give

Strahler stream order using igraph or sfnetwork in R

I cannot fathom how to derive strahler order in R. Here's an example in postgres and neo4j. An attempt in R There are three rules (from the GRASS 7.8 Manual): i

Is there a way to add the bin range label into the tooltip for a histogram using ggplotly in R?

library(tidyverse) library(ggplot2) library(plotly) data(mpg) ggplotly( mpg %>% ggplot(aes(x=hwy)) + geom_histogram(), tooltip = ("all")) When you

separate_columns for tidyr

Let's say I had a survey question that read: What did you eat? [ ] apple [ ] pear [x] banana [x] grapes Now, I have the endorsed options as comma-separated st