Questions tagged [r]

R is a free, open-source programming language & software environment for statistical computing, bioinformatics, visualization & general computing. Please use minimal reproducible examples others can run using copy & paste. Show desired output entirely. Use dput() for data & specify all non-base packages with library(). Don't embed pictures for data or code, use indented code blocks instead. For statistics questions, use https://stats.stackexchange.com.

Filter by
Sorted by
Tagged with
0 votes
0 answers
5 views

Why does R conditional compilation fail using ggplot?

I would like to selectively build figures for my paper, regenerating only those which I have deleted. However, the following code produces a .tex file with only two comment lines; when run without the ...
Iiridayn's user avatar
  • 1,767
0 votes
0 answers
9 views

Mahalanobis distance between two columns containing two variables

Good evening, I'd like to calculate the Mahalanobis distance between each observation of the two vectors (O_Temp, O_Salin) and (D_Temp, D_Salin) in the attached image. So, the aim is to calculate the ...
Adel KACIMI's user avatar
0 votes
0 answers
5 views

Clicking on action button and other ui appears

I have a simple login page and I would like to click the button SIGNUP and appears my main page which I created using module. Simulating a login/authorization of the user. This is my 'fake' login page:...
Laura's user avatar
  • 727
1 vote
0 answers
11 views

Why is there no output R shiny problem with multiple Tabs

Im making an app using R/Shiny. Everything was working fine and then I added another tab, now neither of my tabs are working, so I"m assuming that i"ve done something wrong with how I"m ...
user20453870's user avatar
0 votes
1 answer
39 views

R Loops to help run through 100 different identical excel files, create bargraph and export to a folder

Please bear with me because I am not entirely sure how to create a reproducible example for my question. I am new to using loops and would love some advice. My task is to create barcharts for 100 ...
T K's user avatar
  • 405
0 votes
0 answers
23 views

how to produce max and min in summary statistics in r survey package [closed]

I am using the R survey package to produce summary statistics, in an analysis of complex survey data. Are there methods to produce the weighted values of the max and minimum values of a continuous ...
four77's user avatar
  • 185
-1 votes
2 answers
33 views

Check if a string contains at least one element from a vector [duplicate]

I have the below sample dataset. I would like to filter the dataset df based on the value of o3.cpt column. I want to keep o3.cpt column's rows that contain any of element in joint vector. Is there a ...
J.K.'s user avatar
  • 323
1 vote
2 answers
19 views

How to change the line type in the calibration.plot of the GBM package?

I have a model that I calibrated using a logistic regression. I plotted the data using the calibration.plot from the gbm package. Now that I am submitting the paper for publication, the publisher ...
Sayf Said's user avatar
0 votes
0 answers
8 views

representing CIs in hierarchical arima forecast (HTS in R)

My query is how to get confidence interval of forecast line to display as part of the plot produced with hts. I am not sure whether this feature is directly available in hts - if not, it'd be ...
John Hamm's user avatar
1 vote
2 answers
47 views

Find the rows with a single value in a column for each group

My current data frame looks like this: a b 1 - 1 - 1 R 2 - 3 R 3 R 4 - 5 - 5 - 5 - 6 R 6 - I would like to create a new column "c" that has a value of 1 if (and only if) each group of rows ...
jjw's user avatar
  • 11
0 votes
1 answer
32 views

Generating dataframe with conditional random variables

I'm trying to create a dataframe with two variables. The first one is binary physical activity status (active/non-active), the second one is presence of cardiovascular disease (also binary variable - ...
Olga Serebryakova's user avatar
0 votes
2 answers
27 views

How to build a function to extract data from column names over a list of dataframes

I am trying to extract data from column names over a large number of data frames contained in a list. The last column in each data frame will contain a unique number that I am trying to extract. ...
Jesse Shirton's user avatar
0 votes
0 answers
31 views

How to plot a wide range of values in R? [closed]

The values between precipitation and basal area are significant, I attached an example. So when I try to plot them normally using the plot code, it doesn't appear properly. i.e. - plot(treeringdata$...
Various_One_4737's user avatar
0 votes
1 answer
40 views

Why aren't double digits numbers included in my "less than" and "greater than" commands?

I am fairly new to R, and I am using it for my thesis. I tried to create a set of commands that recode a range of numeric values as a categorical variable. The range of possible values in my dataset ...
Vinh_PPH's user avatar
0 votes
0 answers
7 views

Unable to resolve parameters in JAGS hierarchical AR model for species interactions

I am trying to adapt a hierarchical model as described by Mutshinda et al., 2019 (DOI: 10.1556/168.2019.20.3.4) but have been having some issues. The original code was in BUGS and I've tried adapting ...
Josh's user avatar
  • 49
0 votes
2 answers
25 views

Cannot print results on a separate lines/new line

I am a beginner to R so I know this is easy. Can't make results print on a new line after each result. Problem: `x <- ("This is another way to figures out the decimal value in minutes") ...
Steven Herren's user avatar
0 votes
0 answers
11 views

How to randomly sample texts associated with Latent Dirichlet Allocation model output/topics in R?

I am running a Latent Dirichlet Allocation model in R. Here is the code I have written: # Load necessary libraries library(tidyverse) library(tidytext) library(SnowballC) library(topicmodels) library(...
w5698's user avatar
  • 179
-3 votes
3 answers
56 views

Subset R datafarme based on two columns using tiydverse, base R and loops

I have this dataframe: data <- data.frame( ID = c(111, 111, 111,111, 333, 333, 333,333), planes = c(2, 2, 3, 3, 4, 4, 5, 5), origin = c(3, 3, 6, 8, 5, 5, 7, 9), destination = c(9, 9, 10, 20,...
Xaviermoros's user avatar
0 votes
0 answers
16 views

FIxed effects with plm, problem with NaNs

I am trying to run a time-fixed effects regression with plm using the wbstats library. I have attached an image of the dataset for reference. I am rather new to this. Model: AfricaTotal <- plm(...
CWK's user avatar
  • 33
0 votes
1 answer
55 views

Multiple points with same label in ggrepel - avoid redundant labels

I want to annotate a scatterplot with several points that have the same label. I want to label all of them (not just a part of them) but it is a mess with so many redundant labels. Is there any way to ...
Pau Clavell-Revelles's user avatar
3 votes
2 answers
41 views

merging two data frames with different number of row without repeating row

suppose I have two data frames named df and df1: df<- data.frame("id" = c(1,1,1,2,2,3,3,4,4,5,5,5),"occ"=c(1,1,2,2,2,1,1,2,2,1,2,2)) df1<- data.frame("id" = c(1,1,...
mehmo's user avatar
  • 441
0 votes
0 answers
29 views

getting count of missing values in summary

i want to get the count of NA's in column with max and min. is there any way in expss already to get a count in below example library(expss) library(dplyr) example <- data.frame(org = c("A&...
samrr_tr's user avatar
-1 votes
1 answer
21 views

How to get the label positioned correctly in R?

I am making this graph for my project in school, and I have to have the name Cryptosporidium parvum in italics. Does anyone know howto move the name further down vertically?
wingardium_leviosa98's user avatar
0 votes
1 answer
15 views

I have a folder with many tsv files and want to create several dataframes depending on file names

I have never posted on this forum before and am not super good in r, but I am at my wits end, having searched for answers and tested solutions all day. The tsv files all begin with an ID and end in ....
IDA's user avatar
  • 1
0 votes
0 answers
15 views

Problem to transpose multiple observations with conditions in R [duplicate]

I have this problem when creating a database from another one, this is the original database: Country Code Year1 Year2 Year3 Country1 Code1 1 2 3 Country2 Code2 11 22 33 Country3 Code3 111 222 333 ...
Maria Can's user avatar
0 votes
0 answers
12 views

NA Each element of `...` must be a named string error when using matchmaker: match_df in R

I have been using the cleaning dictionaries tool in the package matchmaker:match_df. The code is as follows: dat <-import("coded-data.csv") dict <- import("dict.csv") ...
jwell123's user avatar
0 votes
0 answers
24 views

Generate network graph to look at similarity between groups

I have some data CM (below) which comprises 6 gene panels. Some of the genes in the panels overlap. I created a venn diagram, but my supervisor wants the data presented in a different format. They ...
lecb's user avatar
  • 407
0 votes
0 answers
12 views

JAGS error: negative length vectors are not allowed

I am running a Bayesian model on a high performance computing cluster, and I keep running into the following error: "Negative length vectors are not allowed" It occurs whether I run the ...
hoganhaben's user avatar
0 votes
1 answer
41 views

Patchwork inset_element() with facets

I am trying to plot a facet plot. My idea is to display inset plots according to the facet. Here's a reproducible example using mtcars. The idea would be to get density plots for am=0 on the proper (...
Matias Andina's user avatar
0 votes
0 answers
14 views

Program Multiple Imputation in R via EM Manually [duplicate]

I am trying to implement multiple imputation using EM (Expectation-maximization) with importance resampling in R. I want to do this manually to evaluate the algorithm I am using, rather than using the ...
flâneur's user avatar
  • 645
-1 votes
1 answer
16 views

split rows of an R data frame into a list of lists by splitting on an element

I have a data frame something like this data <- data.frame(x1 = c("10",20,50,10,90,30,40), x2 = c("50",20,10,80,-99,100,60), x3 = c(&...
user3156942's user avatar
0 votes
0 answers
21 views

Program Multiple Imputation in R via EM with importance resampling Manually without MICE or Amelia [closed]

I am trying to implement multiple imputation using EM (Expectation-maximization) with importance resampling in R. I want to do this manually to evaluate the algorithm I am using, rather than using the ...
flâneur's user avatar
  • 645
0 votes
0 answers
7 views

Error using basemaps in R, 'Access window out of range in RasterIO()'

I am new to mapping. I am trying to get a basemap of Virginia, but I keep running into an error (though the code technically runs). I am using the basemap_ggplot() function in the basemaps library. ...
Brendanb's user avatar
0 votes
1 answer
31 views

Find the binary version number of an R package from a repository

If I use old.packages() this will give me a dataframe with, among other things, the actual version of a package in the repository. This is, however, the version of the package that has to be compiled. ...
arnyeinstein's user avatar
0 votes
0 answers
10 views

Difficulty Reproducing log Fold Change Calculation Using tmod Package in R

I want to calculate the minimum significant differences (MSD) of genes expressed in treated cells compared to control cells. The MSD can be used to rank genes for gene set enrichment analysis. ...
Adrian_Schm's user avatar
0 votes
0 answers
24 views

How can I add a colour gradient or scale to vertices of an igraph?

This is a subset of my edge list. Source Target Freq 1 2 18 1 3 17 1 4 32 2 4 17 3 4 37 2 5 32 1 6 ...
user23078046's user avatar
0 votes
0 answers
10 views

Alternative functions to gDistance from rgeos package in sf or terra package

I need to use the gDistance function to calculate the distance between my points on a line, as line <-as(l, 'SpatialLines') points <- as(p, 'SpatialPoints') max.dist <-max(gDistance(points, ...
Drûswides's user avatar
0 votes
0 answers
21 views

Error when feeding new dataframe to predict with mlogit

I'm trying to recreate the example from this tutorial but there seems to be something wrong with how I feed the dataframe called by into the predict function? This is from the tutorial https://www....
jonas's user avatar
  • 13.7k
0 votes
0 answers
17 views

Create areas of interest for a face based on landmarks in R

I am using OpenFace to analyse videos of faces which gives me a CSV with detected landmarks (x and y coordinates) for each frame. Based on these landmarks, I would like to create areas of interest (...
Max's user avatar
  • 425
0 votes
0 answers
10 views

Regarding multiplying PCA values by -1 in R during Principal Component Analysis [migrated]

I have started learning Principal Component Analysis using R and applied it on **UsArrests **dataset. I have read in an article that eigenvectors in R point in the negative direction by default, so we’...
SKB's user avatar
  • 1
0 votes
0 answers
9 views

Arcgis PRO can't read X and Y fields

I used R to convert my X and Y coordinates to the correct Coordinate System, but after this conversion Arcgis PRO does not allow me to specify the X and Y fields anymore. After searching online this ...
TvCasteren's user avatar
0 votes
0 answers
17 views

Having trouble getting stat_pvalue_manual to facet across my ggplot

I'd like to make a facetted plot, with the p-values from my emmeans() table added using stat_pvalue_manual(). However, I can't seem to get them to facet. Any help would be very welcome! Here is some ...
Mike's user avatar
  • 959
0 votes
1 answer
27 views

plot world map with areas coloured according to categorization based on latitude in R

I would like to colour geographical areas according to the values of a specific column ("Value), where the geographical areas are not Countries nor Continent, but areas defined by latitude ("...
jeff's user avatar
  • 323
1 vote
1 answer
45 views

Barchart with 2 bars each group

I want to plot mean_1 and mean_2 separately by each value of grouping variable x. Thus, I need two bars for each group. Data: n <- 100 set.seed(123) data <- data.frame( x = round(runif(n, ...
geek45's user avatar
  • 422
0 votes
0 answers
11 views

How to achieve color gradient across polyline in R

I have a leaflet map with a polyline. I would like to give the polyline a color gradient from the beginning of line to the end of line. The color will not be dependent on any other variables. The line ...
mafra's user avatar
  • 1
0 votes
0 answers
20 views

why i obtain integer(0) if i have the value at the vector? [duplicate]

i am creating a vector with a numerical sequence in R: bins<-seq(-4,6,0.01) i get 1001 values from -4.00 to 6.00 (-4.00,-3.99,-3.98, etc) but when i use the function which() certain values return ...
Jorge Compean's user avatar
2 votes
1 answer
24 views

How to perform Gray's test with R package tidycmprsk for competing risk data

I have survival data with competing risk (censored 0, relaps 1, death 2) and I want to use Grey's test to check the difference between groups of a variable rh (categories 0, 1 and 2). This is my data: ...
anso_s's user avatar
  • 21
0 votes
0 answers
10 views

Estimating the alpha tail index of a stable distribution using the HTailIndex() function returns nulls for all k values

I am trying to replicate the 1st form of analysis, namely, estimating the alpha tail index, demonstrated in Python in this Medium article, but in R. The datasets used are here, this link is in the ...
Marlen's user avatar
  • 163
0 votes
1 answer
17 views

Change row names in kable (RMarkdown)

I have produced the following table with kable package, in RMarkdown. Here's the dataframe: structure(list(...1 = c("Catalunya", "PIB", "Demanda interna1", "Demanda ...
Maria's user avatar
  • 193
-1 votes
0 answers
23 views

What is a "directional or asymmetrical correlation matrix" called? [closed]

I have to recreate what I would describe as a "directional or asymmetrical correlation matrix" The problem is, I have no idea what one of these is called... The table I am trying to recreate ...
DJD's user avatar
  • 49

1
2 3 4 5
10022