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
10 views

R: sample equal Ns, within groups

I have a data set, in which observations are divided into groups and subgroups, and into types. Here's an example of such data: data <- data.frame(group = sample(c(1:30), 10000, replace = ...
BoTz's user avatar
  • 477
0 votes
0 answers
4 views

How to replace with NAN no more than 30% of the values with the specified flag in R

I have such dataset (example) dat=structure(list(Y = c(2282L, 2565L, 2242L, 2109L, 2704L, 2352L, 2492L), is_red_ndvi_v_down = c("yes", "yes", "no", "yes", &...
psysky's user avatar
  • 3,115
0 votes
0 answers
16 views

How to display colors when typing their names in R studio console?

When I was using R studio v.4.2.2. on another computer, when I typed a colour, like "dark green", the word "dark green" was coloured in dark green (something like this). I am now ...
LT17's user avatar
  • 227
0 votes
1 answer
10 views

Dynamic Y-Axis Limits for Multiple Dataframes in ggplot2

I have a problem with axis limits. My problem is that I have different dataframes to plot (i.e. bigdata and smalldata provided in the code example). I want the y-axis limit to always be greater than ...
trytolearn's user avatar
0 votes
0 answers
9 views

multiple linear regression and predict in r-studio?

load dataset marketing from library datarium apply multiple linear regression and verify the hypotesis Can the amounts spent on the different channels influence sales? apply two other methods and ...
Francesco's user avatar
0 votes
2 answers
38 views

How to create a equally spaced number within a fixed range with a group in R

I have the following dataset: df <- tribble( ~opp_id, ~month, ~count, "304956938","Oct 2023","2", "304956938","Oct 2023","2", "...
Jianyang Tai's user avatar
0 votes
0 answers
10 views

Web scraping with R - can't avoid error 403

I'm working on my HW, i need to scrape date of review, score and time of usage, but it's not the problem. Problem is that website detects somehow webdriver even though special site to check says that ...
Александр Е.'s user avatar
0 votes
0 answers
7 views

Can't display the chart using vistime

I have run the sample program from the following site using the vistime package in R. The browser starts, but the resulting chart is not displayed. https://cran.r-project.org/web/packages/vistime/...
koba-3's user avatar
  • 1
0 votes
0 answers
21 views

Chi-Square Test with given expected numbers in R

I need to perform Chi-Square test regarding is there a relationship between indoor and outdoor. So far the examples I have searched in the internet are that the expected number either not be given, or ...
Gambit's user avatar
  • 101
0 votes
1 answer
19 views

Displaying one response level when using plot_model function of sjplot

I have successfully used the plot_model function of sjplot to plot a multinomial logistic regression model. The regression contains an outcome (Veto Type, with 3 levels) and 2 continuous predictors (...
Jair Moreira's user avatar
0 votes
0 answers
20 views

Only some alphanumeric values imported into R

I have imported multiple Excel files with multiple spreadsheets into R, using the list.files and map_df functions and including the names of the files and sheets. It has worked well except for a ...
James's user avatar
  • 1
1 vote
3 answers
40 views

take differences between consecutive pairs of rows

I am trying to create a new variable computed from the difference between two pairs of rows that are consecutive (1 and 2, 3 and 4, 5 and 6, 7 and 8, 9 and 10 etc.) I am using the lag function but ...
four77's user avatar
  • 185
0 votes
0 answers
10 views

How to extract the correct unit decrease and confidence intervals from glmmTMB zero-inflated (count) model?

I am using this model to calculate the unit decrease of number of fledged birds (as a count) by a certain percentage of increase in ISA levels (percentage of impervious surface areas), this is the ...
Parus major's user avatar
0 votes
1 answer
15 views

R, ggplot2, patchwork: combine legends with comparable (but different) sets of values

I've reviewed other questions along these sames lines about combining plot legends with the patchwork package, but my question is different in that 3 of the 4 combined graphs have overlapping values. ...
Wangana's user avatar
  • 85
0 votes
0 answers
11 views

Format groupby rows in reactable

In reactable, is there a way to style the entire row of groupBy header? e.g. to add a border to the bottom like this: Code for table: library(reactable) data <- MASS::Cars93[10:22, c("...
Abigail's user avatar
  • 370
1 vote
1 answer
21 views

R, ggplot2: Centering and aligning wrapped text in geom_rect

I have the following data: Channel <- c("Episode", "Episode", "Episode", "Episode", "Episode", "Episode", "Episode", "...
Wangana's user avatar
  • 85
0 votes
0 answers
12 views

Kerning irregularities in ggtext markdown titles

I keep generating irregularities in kerning when using ggtext for ggplot titles. For instance: library(tidyverse) library(showtext) library(ggtext) font_add_google("Public Sans") p1 <- ...
tomw's user avatar
  • 3,114
0 votes
1 answer
17 views

ggplot2 geom_ribbon not plotting

For some reason I can't figure out my geom_ribbon are not working Data: structure(list(row = c("1", "2", "3", "4", "5", "6", "7", &...
piblo95's user avatar
  • 175
0 votes
0 answers
72 views

Different PCA results in R and Python

I'm trying to get PCA done for my data, which is dataframe with 16 observations in rows, and 11 features in columns. In R, with prcomp the matrix format consists of features in the rows and principal ...
isturdyb's user avatar
-7 votes
0 answers
28 views

How can one convert an irregular time series plot into a regular time series in Excel, involving earthquake data as an example [closed]

I'm working with earthquake data, and it's irregular. I'm attempting to convert it into a regular format, considering factors such as the annual frequency. However, I'm uncertain about the steps to ...
Brandon Vargas - Bines's user avatar
0 votes
0 answers
8 views

How to set R_Home in the environment or registry in PyCharm (Anaconda)?

I am trying to run some code in PyCharm that also needs an R environment within Anaconda. I have used the https://support.anaconda.com/hc/en-us/articles/360023857134-Setting-up-rpy2-on-Windows, to add ...
pemb_bex6789's user avatar
1 vote
1 answer
52 views

Turning off Automatic Row Numbers [duplicate]

I have the following table: table_a = structure(list(elephant = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 4L, 4L, 5L, 5L), elephant_status = c("performing", "performing", "...
stats_noob's user avatar
  • 5,315
0 votes
0 answers
11 views

Displaying .tif band values using R

I'm very new to programming in R and i'm having some problems. I have a .tif raster with a lot of bands, and I needed a vector to read and display the values from each band, but i don't seen to know ...
Joao Pedro Tanaka's user avatar
1 vote
1 answer
27 views

Render text from other column with styling in DT

I have a table with values and their associated delta and would like to present both info in a single column. Below is a reproducible example where a,b are current values and their deltas are a.delta,...
yben's user avatar
  • 13
0 votes
0 answers
17 views

Problem with SelectInput and SliderInput in changing axis in scatterplot, R Shiny

I am trying to create a scatterplot where we can change the axis, and if a certain axis is selected, we have a sliderInput that permit to change the max and min of the axis. But I can't manage to do ...
Maxxss's user avatar
  • 1
0 votes
0 answers
30 views

Error: specified cast is not valid in rstudio

I‘m running a R script which downloads data from a web site using a SNB API. Subsequently, I‘m loading this data into Macrobond using its API, too. I do this in R but when I run the script, I now get ...
TFT's user avatar
  • 141
0 votes
1 answer
17 views

R use propagate() to calculate the propagated error for summing up a column

I am learning the propagate function and want to use it to calculate the propagated error of summing the raw data in a data frame column. Each row in the data frame is a record, provided with raw data ...
Elizabeth's user avatar
  • 209
0 votes
1 answer
28 views

How to adjust the width of the bars in a pyramid graph using the "age_pyramid" function from the "apyramid" package?

I'm using the R package apyramid to build a pyramid like graph, but I can't find the option to set the width of the bars. The readme notes established that the graph generated is a ggplot2 object so ...
Marco A Díaz 's user avatar
-1 votes
0 answers
16 views

How to solve "-----Error: udunits2.h not found-----" when installing "udunits2" in R 4.1.2 from macOS Sonoma? and same thing with proj4

I have updated my mac to sonoma, and I'm trying to install udunits2 and proj4 in R, but alwways got these errors for udunits2 -----Error: udunits2.h not found----- and for proj4 configure: error: ...
samo diatta's user avatar
0 votes
0 answers
19 views

How to fix the error in glmnet? Error: inner loop 1; cannot correct step size

I am doing a loop. all_datasets[["X19"]] [1] 2.000000e+00 0.000000e+00 0.000000e+00 1.700000e+01 0.000000e+00 2.300000e+01 1.100000e+01 1.470314e+51 0.000000e+00 [10] 0.000000e+00 7.000000e+...
Sofia Delacruz's user avatar
-2 votes
0 answers
31 views

Add a column in dfs within a list on a certain position and use data from other df to fill it [closed]

I want to add a new column (Scannumber_1m) in dfs within a list (=dfs_list). Another df (single_df) contains values in the column row_start. I want now to take the value from df$row_start, go within ...
timtams's user avatar
  • 97
1 vote
2 answers
64 views

ggplot colorbar align to top when using facets

I am using facetted plots via ggplot that contain a colorbar. I want to scale the colorbar to the size of the facetted plot. Following the ideas of @AllanCameron in this post regarding a single plot ...
carl's user avatar
  • 395
0 votes
1 answer
70 views

calculate a sequence of expressions efficiently

I have some data set.seed(1) n <- 100 df <- data.frame( x = sample(1:30, n, replace = T), y = sample(1:30, n, replace = T), z = sample(1:30, n, replace = T) ) and vector with expressions, ...
mr.T's user avatar
  • 279
1 vote
1 answer
21 views

R kernel constantly crashes in Jupyter Notebooks due to graphics

I'm running R 4.3.2 on a Ubuntu 22.04 remote machine. I use vscode to SHH into it for all coding purposes except for R, as every time I run a Jupyter Notebook and execute code, the R kernel crashes ...
Comfort Eagle's user avatar
0 votes
0 answers
27 views

Force edges in graphviz to overlap each other

I am trying to create in DiagrammeR the flowchart below. Although I am using the concentrate=true attribute option it appears that the edges cannot forced to overlap each other and have common arrow ...
SpyrosR's user avatar
0 votes
0 answers
19 views

Create irregular spatial point based radius from real data in R

I want to create a spatial point grid for specific area. Since I have a real point in all over the area I decide to design this grid based on radius from my data. For instance create a grid that ...
rezgar's user avatar
  • 114
0 votes
0 answers
33 views

how to resolve write_csv() function error message

I am working on Rstudio Cloud. write_csv will not work and keeps returning this message: "Warning: cannot open file 'cloud/project/covid.csv': No such file or directoryError in file(file, ifelse(...
ghada al yamani's user avatar
0 votes
5 answers
94 views

How to convert a column of characters of a dataframe into multiple binary columns?

How to convert a column of characters of a dataframe into multiple binary columns? For instance, turn > df id name 1 A 2 B into > df id A B 1 1 0 2 0 1
monotonic's user avatar
  • 508
0 votes
1 answer
17 views

Using limits in scale_x_continuous with geom_histogram removes values even when they are well within the limits

I want to set wide limits on the x-axis of a histogram for compatibility with previous plots in the same document. I thought I should be able to do this setting the limits in scale_x_continuous() as ...
cpsyctc's user avatar
  • 41
1 vote
3 answers
56 views

Find months between two dates

I have this tibble library(tibble) tibble(site = c("a", "b", "c", "d"), date = c("01/12/21", "07/06/22", "02/12/22", "30/07/...
luciano's user avatar
  • 13.2k
-2 votes
0 answers
17 views

A code that calculates the degree of interspecific association using R's spaa package [closed]

"spaa" means species association analysis, i want to calculate the overall correlation of species within a community and the association between two species, and completed my dissertation. I ...
乐悠悠's user avatar
2 votes
1 answer
40 views

only having outermost border when using facet_grid() in R

I would like to be able to create a plot with just the outermost borders when using facet_grid(). This has been answered before here: ggplot2 outside panel border when using facet but this example ...
confusedindividual's user avatar
0 votes
0 answers
22 views

Trying to Knit a template

After creating an rmd file, I keep getting this error on my Render while trying to knit a CV template and i have tried everything yet no breakthrough. I'm using R-stuiod cloud ! Undefined control ...
Chris Okorie's user avatar
2 votes
3 answers
52 views

How to convert a list of vectors of unequal length to a binary data frame?

How to convert a list of vectors of unequal length to a binary data frame? My dataset looks like: > gene_annot [[1]] [1] "lipid binding" "catalytic activity" &...
monotonic's user avatar
  • 508
0 votes
0 answers
28 views

exporting multiple regression results in R

New R user here. I have a bunch of regression models that can get quite big, and I'm trying to find some way to export the results into a latex table using stargarzer. structure(list(country = ...
CF96's user avatar
  • 87
0 votes
1 answer
33 views

ggplot: adding data from a different data frame as an additional facet grid

I have the following data and code: #first data set channel <- c("Channel 1", "Channel 1", "Channel 1", "Channel 2", "Channel 2", "Channel 2&...
Wangana's user avatar
  • 85
0 votes
0 answers
10 views

Loading an SF item to an AGOL Feature Layer via Arc Rest API

Im having difficulty using R to load the geometries from a kml to a feature layer stored in AGOL. Im using sf in R to process the kml file, convert it to a geojson, take the geometry from the geojson,...
Charles Ross's user avatar
0 votes
0 answers
33 views

Legend not showing in ggplot graph

Help! Trying to plot a scatter plot, with a regression line, and a horizontal line marking a target level. Below is my code - I can't seem to figure out how to get the legend to show up. ggplot(...
Whit Altman's user avatar
0 votes
1 answer
41 views

Identifying crisis episodes

New R user here. I have a relatively large panel of countries, and I want to identify recession episodes. labor_pivoted_crisis=labor_pivoted%>% group_by(country)%>% mutate(crisis=ifelse(...
CF96's user avatar
  • 87
0 votes
1 answer
18 views

checkboxInput within mainPanel to display different images

I'd like to use a checkbox to select the image to output in a mainPanel() or tabPanel() in RShiny. A reproducible example: (to make it easier to run anywhere, we can replace "image1.png" ...
Dylan_Gomes's user avatar
  • 2,130

1
2 3 4 5
10014