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.
508,401
questions
0
votes
0
answers
27
views
How to add count labels to clustered stacked bar chart in ggplot? (R) [closed]
I have a bar chart that looks like this:
I am happy with how it looks except that I am trying to add labels to my bars showing the count of each bar.
##Current Code
library(ggplot2)
typeXsize <- ...
0
votes
0
answers
26
views
Speed up of the workflow: masking + global summing for 50 not-so-small tiles using terra R package
As a newbie of terra I am finding difficult to speed up a very simple task:
I have 50 tiles of 200 x 200 x 9000 (a list of SpatRaster).
I need to apply a mask to each tile and compute a global sum for ...
1
vote
1
answer
33
views
How to convert a graph into a sparse adjacency matrix having a given type (other then "dgCMatrix")
How to convert a graph to a sparse ‘dgTmatrix’ in one step?
library(igraph)
library(Matrix)
g <- make_ring(5)
adj <- as_adjacency_matrix(g, sparse = TRUE)
class(adj)
# [1] "dgCMatrix"
#...
0
votes
0
answers
15
views
How to apply cld() on specific groups of lsmeans() output?
I have a pretty large model (MLM_LAI_10_DIC), with more than 7000 values. When I use cld() on lsmeans() on my model, I get too many groups. Is there any way to apply cld() on just some of the values? ...
-1
votes
0
answers
11
views
I have below error for running PLS-SEM for a formative model:
> simple_mm <- constructs(
+ composite("eco", multi_items("eco", c("BC", "PI", "LRP", "RMI")), weights = mode_B),
+ composite(&...
0
votes
0
answers
29
views
How to get VennDiagram to include 0s
I am trying to work out how to create a Venn diagram using the VennDiagram package that keeps 0s in. At the moment I have the issue below where if there is not overlap between the groups the circle is ...
3
votes
2
answers
48
views
compress files in R without structure of directories
I want to compress some files in R using tar(). My code is quite simple:
f <- "C:/TEMP/tarfile.tar.gz"
files_to_compress <- dir(path=tempdir(), full.names = TRUE)
tar(tarfile = f, ...
0
votes
1
answer
49
views
Use rows of dataframe to apply conditions on another dataframe in R
I have 2 data frames, one I want to use each row of it as a condition to apply it in the second data frame. This is an example of them:
condition_df <- data.frame(
type = c("3701","...
1
vote
0
answers
26
views
Extract the Variables with the Most Influence on the Ordination in an LDA
I performed an LDA analysis on my data, and I want to extract the variables that most impacted the ordination. If I understood correctly, I can obtain that information from the "scaling" ...
0
votes
1
answer
16
views
R devtools::install(): how to install to user-local library?
I'm trying to install a package developed locally, via devtools::install(), within an R session started as normal user (not sudo) in a Linux machine. The installation fails with the error
no ...
0
votes
1
answer
36
views
Failing to automate slide creation for each plot (pptx format, R)
I have a list with 100 plots which I want to automate via quarto such that each plot is produced in a new slide of a power point presentation.
I am using Quarto 1.4.555 with R 4.4.0 via RStudio 2024.4....
1
vote
1
answer
42
views
R split 1 column into several columns based on regex value
I have dataframe like this
col_names
Aceh..........................................................66.29..........................56.49..........................64.01....................................
0
votes
0
answers
20
views
SVC GAM in the presence of factor variable and transformation of coefficients into relative risk
I would like to get your confirmation on two doubts I have on the application of SVC GAM.
Basically, I would like to know
how to deal with factor variables when predicting spatially varying ...
0
votes
1
answer
37
views
R index, filter then match on multiple criteria. Easy in excel, not so in r
I want to extract the 'untreated control' value for each variable and weed_type. In excel is easy to lookup the filter the value in the row and return the "untreated_contol" result for that ...
1
vote
0
answers
29
views
Need help using "reframe" to run multivariate regression across multiple data sets (changing model from one year to multiple years)
I have a simple multivariate regression model testing the impact of two variables on another over one year (1971). I have a large data set that includes these data over a number of years and am being ...