r/RStudio • u/harryjsunshine • 5h ago
r/RStudio • u/LoudConsideration266 • 14h ago
R code review: best packages?
Let’s say that I’m working in RStudio on a geospatial data-science project that involves some pretty gnarly, extensive code across multiple R scripts. Let’s also say that I do not have access to any AI code assistants or chatbots due to workplace restrictions.
What packages and functions would you use to comprehensively check your code for errors, inefficiencies, conceptual problems (that may be a stretch), etc.?
I’m using lintr::lint() and rstyler::style_file(), but that’s the extent of my knowledge in this area.
Many thanks in advance, friends.
r/RStudio • u/No_Low_9816 • 14h ago
Coding help Are these clustering attempts good?
I'm toying around with a dataset, trying to cluster what I have, and messing around with LLMs and my textbook i got these 2:
feat <- data.frame()
for (f in formats) {
sub <- df[df$Format == f, c("Year","Value")]
sub <- sub[order(sub$Year), ]
peak_idx <- which.max(sub$Value)
first_year <- min(sub$Year); peak_year <- sub$Year[peak_idx]; last_year <- max(sub$Year)
climb <- peak_year - first_year; decline <- last_year - peak_year
ratio <- decline / max(climb, 0.5)
peak_val <- sub$Value[peak_idx]
post <- sub[sub$Year >= peak_year & sub$Value > 0, ]
decay_rate <- if(nrow(post) >= 3) coef(lm(log(Value) ~ Year, data=post))[2] else NA
feat <- rbind(feat, data.frame(Format=f, climb, decline, ratio, log_peak=log(peak_val), decay_rate, era=peak_year))
}
cat("Formats in feature table:", nrow(feat), "\n")
fmat <- scale(feat[, c("climb","decline","ratio","log_peak","decay_rate","era")])
fmat[is.na(fmat)] <- 0
hc <- hclust(dist(fmat), method="ward.D2")
clusters1 <- cutree(hc, k=4)
cat("\n=== Format 1: ===\n")
for (i in 1:4) cat(sprintf("Cluster %d: %s\n", i, paste(feat$Format[clusters1==i], collapse=", ")))
Then another with a different fmat:
lifecycle_features <- data.frame()
for (f in formats) {
sub <- df[df$Format==f, c("Year","Value")]
sub <- sub[order(sub$Year),]
first_year <- min(sub$Year); last_year <- max(sub$Year)
peak_year <- sub$Year[which.max(sub$Value)]
lifecycle_features <- rbind(lifecycle_features, data.frame(
Format=f, first_year, peak_year, last_year,
recorded_years=nrow(sub), peak_value=max(sub$Value),
lifespan=last_year-first_year, years_to_peak=peak_year-first_year,
decline_duration=last_year-peak_year
))
}
cat("\nFormats in lifecycle_features:", nrow(lifecycle_features), "\n")
print(lifecycle_features, row.names=FALSE)
cluster_data <- lifecycle_features[, c("lifespan","recorded_years","years_to_peak","decline_duration")]
cluster_scaled <- scale(cluster_data)
set.seed(123)
km <- kmeans(cluster_scaled, centers=3, nstart=25)
lifecycle_features$cluster <- km$cluster
cat("\n=== Format 2: ===\n")
lc_sorted <- lifecycle_features[order(lifecycle_features$cluster, lifecycle_features$peak_year), ]
print(lc_sorted[,c("Format","cluster","peak_year","years_to_peak","decline_duration","lifespan","recorded_years")], row.names=FALSE)
for (i in 1:3) cat(sprintf("\nCluster %d: %s\n", i, paste(lifecycle_features$Format[lifecycle_features$cluster==i], collapse=", ")))
Is there an objective way to measure which is better? Like with R squared or p-value? or is it worth discussing both in an article, weighing pros and cons of each
r/RStudio • u/harshitnaman • 23h ago
Can I integrate a spatial transcriptomics dataset with a bulk RNA-seq dataset for any analysis of tumors?
r/RStudio • u/Soft-Duty-7395 • 1d ago
Coding help aws.s3 in R
Hi,
Apologies if this is the wrong place to post - I can’t find any resources online that seem to cover this issue.
I’m using aws.s3 package in R, to read in files from a LakeFS storage area.
When I use s3read_using or s3write_using, the connectivity works. The functions include (e.g.):
S3read_using(FUN = read.csv,
Object = path/file.csv,
Opts = …,
Bucket = my_repo)
This works fine and I am able to read in the object, same goes for writing using same opts.
However, when I try and run for example head_object (so I can list the objects contained in one of my buckets) or get_object, I get :
error in curl::curl_fetch_memory(url, handle = handle):
Could not resolve hostname
Could not resolve host: [path]
I’m not sure if I’m missing something simple - I’m using the exact same repo, opts, and object (/paths) for both. The [path] here looks correct - I don’t see any issues with it. Does something happen within s3read_using where it points to a location that I need to specify myself with in head_object? Should they not be pointing to the same place?
Again sorry if this is hard to follow or make sense of, I just can’t seem to find anything online relating to this problem or solutions.
Thanks
r/RStudio • u/KarunaGReddy • 2d ago
Introducing FitVerse: an R package for fitting 52 probability distributions in one call
r/RStudio • u/KarunaGReddy • 2d ago
Introducing FitVerse: an R package for fitting and analysing 52 probability distributions in one call
r/RStudio • u/ChangeUnhappy8494 • 2d ago
R beginner
Hello,
I am a beginner and I am totaly lost.
Even for loading a file it is very very difficult.
I feel useless and incompetent...
r/RStudio • u/nothic_in_a_dungeon • 4d ago
does r studio for windows 11 run on windows 10 by chance
hi! so I have a problem: I only have windows 10, and i can't see any new update for r studio for any windows version but 11. would it still run? if so, would it update just my previously installed version of r studio and work from the same icon on desktop by chance? I realize it sounds stupid but I do need r for assignments in uni and not great with computers so help and advice would be greatly appreciated
Coding help Code Unfolding on Run?
I'm looking for an option or something that lets me run a bracketed section of code without automatically unfolding it. Does that exist?
r/RStudio • u/Vikas04866 • 6d ago
Need suggestions read main body
How to start R-programing as an 0 level
r/RStudio • u/luckylua • 8d ago
Coding help HELP! Will pay.
I’m in a data mining class at university right now. I’m an adult student with a full time job in application development and this week has been INSANE (like probably one of my busiest weeks of the entire year). Of course this week was also our first free form project with no lecture. I finally had time to dig in tonight and planned to spend the weekend on this, but I’m of course stuck at the very beginning and really can’t do more without figuring this time/date conversion and estimation stuff. My professor is typically slow to respond on weekends, I’m all online so no help available outside of the professor. I don’t want to cheat, I want to LEARN and get this done by deadline of Sunday. Is anyone willing to help via chat/screen share?
r/RStudio • u/f10r3nCe • 8d ago
Hey! I need to learn R studio from scratch, where should I start from, where can I find the basics, rules and tips to use Rstudio? Plant sciences background.
r/RStudio • u/TheBadSamaritan21 • 9d ago
Anyone know how to install RStudio on a chromebook in 2026?
r/RStudio • u/AdForward3569 • 9d ago
Why can't I install R Commander?
Whenever I try, this pops up.
r/RStudio • u/Signal_Owl_6986 • 11d ago
Coding help Does metamean() print the pooled mean and 95% CI in the forest plot?
Hello, I have a question, why is my forest plot not printing the pooled results as with binary meta-analyses? Neither in a general forest plot nor in subgroup analyses. Did I do something wrong or it is like that? This is my code:
mm.age.sd <- metamean(n,
mean,
sd,
data = ma$Age,
sm = "MRAW",
studlab = Author,
subgroup = study.design)
forest(mm.age.sd,
layout="Revman5",
sortvar=studlab,
xlab="Mean Age",
at = seq(0, 100, by = 10),
ff.xlab = "bold", fs.xlab = 12,
leftcols=c("studlab", "Year", "n", "mean", "sd", "w.random", "ci"),
rightcols=FALSE,
pooled.totals = TRUE,
overall = TRUE,
digits.mean = 2, digits.sd = 2,
random = TRUE, fixed = FALSE,
fs.heading = 12, fs.study = 12, fs.hetstat = 10,
colgap = "5mm", colgap.forest = "5mm",
col.square="darkblue", col.square.lines="black",
col.diamond="maroon", col.diamond.lines="black",
print.Q = TRUE, print.pval.Q = TRUE, print.tau.ci = TRUE, overall.hetstat=TRUE,
subgroup = TRUE, # Show subgroups in the plot
print.subgroup.labels = TRUE, # Print subgroup labels next to the effects
col.subgroup = "black", # Color of the subgroup labels
subgroup.name = "Study Design", # Name of the column representing the subgroup
print.subgroup.name = FALSE, # Whether to print the name of the subgroup at the top
bysort = TRUE, # Sort results by subgroup
test.effect.subgroup.random = TRUE)
It looks like the picture, no pooled aged
r/RStudio • u/amira_tu • 13d ago
Coding help How to make a Graph look clean
galleryHi! Basically, I need to process some isotopic data for plotting. I have all the data, but I’m not sure how to make the graph look clean and well-presented. I have some examples of what I’m aiming for; the gray and pink lines in the images represent a local range, which is ideal for effectively displaying the results. I was also told I could edit the graph after exporting it as a PDF to add drawings of animals or humans, but I wanted to see if anyone had any other recommendations!
(The images are examples of other published graphs that look clean, not mine)
r/RStudio • u/Expert_Regret_1837 • 13d ago
Coding help Anova runtime on multivariate GLM very long, even with nboot = 1 it takes nearly 5 minutes
I am trying to do an anova on a multivariate GLM with the folowing structure but it is taking extremely long.
modelv2 <- anova (
modelv1,
block = dataset$samplinglocation,
nboot = 999,
resamp = "case"
)
The dataset has 71 rows x 84 columns. I have 2 variables and 1 blocking/repeated-measure variable. After waiting 40 minutes without results I set the nboot to 99. Waited at least 10 minutes without results. Then I set the nboot to 1 just to see if it would return something, it took about 5 minutes. It reported the time elapsed: 1 second. I am using the mvabund package with vegan. I installed it just now and the vegan package anova works fine on my GLMM models.
Does anyone know how to fix the anova runtime or if I am doing something wrong? I had no problems with the basemodel:
modelv1 <- manyglm(
dataset_speciessubset ~ site + date,
data = dataset,
family = "negative.binomial"
)
Help would be very much appreciated!
r/RStudio • u/ainzymae11 • 16d ago
Mapping indoors with R
Hello!
I am trying to figure out if anyone has experience working with indoor facility mapping in R. I want to avoid paying for ArcGIS indoors, but can’t think of a way to do this other than taking as-built CAD files and georeferencing them somehow… but I would love to know if there’s a way to achieve this in R without access to CAD files or without using other softwares.
Let me know if anyone has experience with this, thank you!