509,118
questions
-1
votes
0
answers
16
views
Can you explain why the product gallery images appear the same size as the original image in a single column below it? [closed]
عند الضغط على اضف الى السلة على المنتج تظهر صورة المنتج وتظهر تحتها صور معرض المنتجات الخاصة بالمنتج ولكن تظهر على هيئة عمود بنفس حجم صورة المنتج الاصلية ولم اعرف ما سبب هذا التغير وطبعا الوضع ...
0
votes
0
answers
6
views
Select x-axis range by brush in a plot inside a box
In Shiny, I select an x-axis range by brushing a plot, as in the MWE below:
library(shiny)
library(ggplot2)
library(cowplot)
library(shinydashboard)
test_ui <- function(id){
ns <- NS(id)
...
0
votes
0
answers
9
views
Problems loading the “caret” library with R Language for IntelliJ plugin
When I try to load "caret" package in Pycharm with R Language for IntelliJ I have the following error:
Pycharm:
> library(caret)
Error: package or namespace load failed for ‘caret’:
....
0
votes
0
answers
6
views
Reporting multiple p-values with stargazer
I would like to export the p-values of coefficients from lm model. I also perform a randomisation inference test as I am interested in a treatment effect. I also have p-values on the same coefficients ...
0
votes
0
answers
5
views
Simulate Simple Linear model based on effect size (f^2) How to specify the beta coefficient?
I am manually simulating data for a specified effect size f^2 in R in a simple linear model with binary predictor. How do I specify the beta coefficient correctly based on f^2 and R^2 resp.?
I don't ...
0
votes
0
answers
8
views
ggplot2 density2d vs seaborn kde / Or shorter range in density2d
2D density plot seems to exclude some areas, I assume, because of too small number of points comparing to the 'main cloud'. Interestingly, it seems to work better in seaborn kde plot.
Below you can ...
0
votes
0
answers
11
views
How to show mean in time series graph reactively?
I want to achieve this sort of plot dynamically using shiny. It is to show the year on year set of data with the yearly average of within the year. I am able to get it outside of shiny, but I'd like ...
0
votes
0
answers
29
views
likert plot with categories and one factor in ggplot2 in R [duplicate]
I have a dataframe in R that has two columns: column A with likert values, and var column with values NO and YES. How can I use gglikert() with grouping category?
library(dplyr)
library(tidyr)
library(...
3
votes
1
answer
36
views
Subtract the previous number when another row is not NA in R
This is a simplified data example.
df <- data.frame(
SU = c(1, 1, NA, NA, NA, NA),
TIME = c(10, 20, 30, 40, 50, 60),
AMT = c(5, 5, NA, NA, 5, 5)
)
I want to generate a new column TFDS, if is....
5
votes
2
answers
45
views
Remove all punctuation AND the values after it at end of string in R
I have a ID variable that comes from 35 different hospitals, so has varying different arrangements of the variable, and sometimes it has the same root ID number with a secondary line number - e.g. -1, ...
0
votes
0
answers
40
views
How to add a row filter for a categorical variable?
I would like to add a filtering condition into my shiny app. Currently it is using plotly, but I am not married to plotly if another tool works better.
My data has a category called 'municipalities'. ...
0
votes
0
answers
37
views
Saving plots in Rstudio/R
I've been using ggplot for the most of data visualizations in R/RStudio.
It's fantastic and absolutely love the package.
However, it always gives me troubles when saving the plots using ggsave() or ...
1
vote
2
answers
26
views
Passing values from indexed vector into manually-entered labels in ggplot
I would like to pass values from an indexed vector into the expression() function in ggplot. Easiest just to show what I mean. Here is toy data. Three groups each with 11 values.
# Toy data
data.frame(...
0
votes
0
answers
23
views
Why are these R functions returning different vectors? [closed]
This function does not return a normalized vector, and I don't understand why.
g <- function(x, a, b){
return (x-a)/b
}
y <- g(x, min(x), max(x) - min(x))
This function works as expected, but ...
1
vote
0
answers
10
views
How to download plotly graphs with the hover data points in R?
I have a plotly graph in R where I want to download the graph as a .png with the "compare data on hover" at a specific x value. Since I need to do it for a lot of graphs, moving the mouse ...
0
votes
0
answers
19
views
How do you read each password protected excels in one folder and extract certain columns from each spreadsheets?
Per title, I have multiple weekly reports that have the exact same format/columns, and I want to extract all the rows and some columns and make an annually report. The filename for each spreadsheets ...
1
vote
2
answers
40
views
A magrittr pipe that adds side-effect functionality to %>%
I would like to make a custom magrittr pipe that is essentially the same as %>%, but has some extra functionality added to it, as a side effect. E.g. print some information, tabulate or plot the ...
0
votes
0
answers
16
views
How do I change specific factor level labels while keeping the existing ones in R? [duplicate]
I have a factor variable in R with four levels, each associated with a label. I want to change the labels for two specific levels while keeping the labels for the other levels unchanged.
# Example ...
0
votes
1
answer
27
views
Automatic assigning t-test and ANOVA to variables in tbl_continuous in gtsummary
trial |>
select(trt,marker,grade,response) |>
tbl_continuous(marker,
statistic = ~"{mean} ({sd})") |>
add_p()
I want to use t-test and ANOVA in add_p(), I ...
0
votes
1
answer
37
views
Specify ellipsis arguments as one object
I would like to loop through a function trying different combinations of parameters. I would like to specify the parameters in a list (i.e. a structured format)
In the following examples, I would ...
1
vote
0
answers
14
views
Dependent variable labels with multiple models in stargazer
I would like to include the dependent variable labels in stargazer with multiple models. This is straightforward when the DVs are different for each model, but I have the same. Yet, I would like to ...
2
votes
1
answer
18
views
svyby - how to call in different variables for by formula in a function?
I would like to pass an assigned variable to a function that would be used as part of a formula in the svyby function from the survey package. My reason for wanting to do this is I want to get ...
-1
votes
0
answers
24
views
Compute the Hurst exponent of a random walk in R [closed]
I'm studying the randomness of financial markets and want to compute the Hurst exponent of the logarithmic returns. To get a measure of the significance of the exponent, I want to do a Monte Carlo ...
5
votes
0
answers
53
views
Optimization of tail recursion in R
Since version 4.4.0, R supports tail recursion through the Tailcall function. I automatically assumed that it means an improvement for codes that use tail recursion.
However, consider the following ...
2
votes
1
answer
30
views
Error in tbl_continuous() in gtsummary when using themes
I was making a new theme in gtsummary package, but it seems it affects the tbl_continuous function, although I did not make any arguments regarding tbl_continuous in my theme. Also, I cannot find in ...
4
votes
1
answer
56
views
Retain overlapping ellipses if the center is not overlapped
Here is a code that creates ellipses of 1400 m length in the main axis and 1000 m in the side axis. Each ellipse is assigned with an ID.
library(sf)
library(ggplot2)
library(dplyr)
# coordinate data
...
-1
votes
0
answers
18
views
Runs test for more than two categorical variables (in R) [migrated]
I'm testing the randomness of the stock market, and want to do a runs test on the logarithmic returns. Now, financial returns can be either negative, zero, or positive. The standard runs test is ...
-2
votes
1
answer
62
views
Compile two identical rows into one [closed]
I have my data combined_dt like following :
X
ID
date_measure
Month
Age
compiled_metrics
25
2063
2016-12-28
12
63.7
258 NA
13274
2063
2016-12-28
12
63.7
NA 2948
Instead of having
X
ID
...
1
vote
1
answer
30
views
Change position of facet label fro right to top in ggplot2 in R
I want to change the facet label position from right to top. How can I do it in ggplot2 under the gglikert()
function ?
library(tidyverse)
library(ggstats)
likert_levels <- c(
"Strongly ...
1
vote
1
answer
19
views
How to make Queries and Post to a board in Monday.com from R? (with answer)
I had this question and I couldn't find solutions here. So I decided to share the basics that I found.
0
votes
1
answer
27
views
What does the n_unique value mean, when skimming list variables?
I do not understand the meaning of the n_unique value in skim about list variables:
library(tidyverse)
library(skimr)
skim(starwars)
The following is part of the result, about the three list ...
1
vote
0
answers
27
views
Adding a class to dplyr mutate .data argument gives Error in `vec_data()`: ! `x` must be a vector, not a <data.frame/myclass> object
After appending a new class to a data frame, I can no longer run dplyr functions on the data frame. Two examples here. Initially I can apply dplyr::mutate and dplyr::filter with no problems.
## Create ...
0
votes
0
answers
22
views
Using openai package. Is this the best practice to work with APIs in Shiny? [closed]
This is my App and code:
library(shiny);library(openai);
ui <- fluidPage(
textAreaInput(inputId = 'user_prompt',
label = 'Write your Prompt',
placeholder = '...
0
votes
1
answer
23
views
How to namespace when using shinyjs?
I am creating namespace modules but am having problems now when using shinyjs() functions like hidden() and show(). In the below Example 1: with module, clicking the action button testButton should ...
0
votes
1
answer
37
views
aggregate sf spatial dataframe values
I want to sum the values of each polygon, indicated as cod_area.
library(sf)
sf.data <- structure(list(cod_area = c(34275L, 34275L, 34347L, 34347L),
cod_reg = c(1664464L, 1664467L, 1665398L,...
0
votes
0
answers
13
views
image function does not work for sparseMatrix in R [duplicate]
test <- function(){
require(Matrix);
data(CAex, package = "Matrix");
image(CAex)
}
test()
It draw the plot
test <- function(){
require(Matrix);
data(CAex, package = "...
0
votes
0
answers
17
views
Rmd Officedown: Cannot get the table of contents to show up
I have tried several permutations and example code from other questions, but no matter what I try I cannot get a table of contents to appear when using officedown. I can get it to appear when using ...
2
votes
0
answers
33
views
How to outline a group of facets using geofacet and ggplot2?
Using ggplot2 with geofacet, I want to outline some group of facets with rectangles. I guess I could draw it after the image is saved on disc as .png or .jpg with the magick package, but I would ...
0
votes
0
answers
30
views
Use of glm with ri2
I am conducting a randomisation inference procedure with ri2 for a binary model. I use glm and specify as a family binomial (link = 'logit'). When I use the ri2 on this model apparently it is not ...
2
votes
1
answer
43
views
How does the data.table `on` logic work for unequal joins?
Please have a look at the following code. It constructs a data.table and does a kind of unequal self join (except that I copied the table before doing the join, so I know where what column comes from)....
0
votes
0
answers
32
views
Import File Names Only of Google Folders in R
I have a folder in my Google drive containing multiple subfolders. All I want to do is create an R script that import the files names into a dataframe in R. Ideally I would also like to have the ...
0
votes
0
answers
26
views
Using Polite with unnamed arguments
I want to scrape some data from IMDB and the URL structure is as following https://www.imdb.com/title/tt0903747/episodes/. I want to bow and the scrape some different codes. How can I achieve this ...
0
votes
0
answers
34
views
INCOMPLETE STRING error when using the source function in R [closed]
I am using the source() function in R to bring a CONFIG file into my R project.
source("C://Users//kated//OneDrive - University of East Anglia//Documents//Research Chapter 3//nature_markets_tool/...
1
vote
1
answer
29
views
How to Get Rising 'google_trends_queries_list' in DataForSEO API using R
how to extract all Rising related query of Google Trends from DataforSEO API integration into single/one column data frame?
I run below script with no error but still don't get the result. 'res_json' ...
0
votes
0
answers
11
views
Distance weighted mean - how to handle samples at the same location [migrated]
In R, I am calculating differences in community composition for several samples in a certain area. To get an overall measure of how different the communities are, I want to weigh samples that are ...
2
votes
0
answers
23
views
top align columns in quarto (r) and add column-lines between columns
I am trying to create a quarto document with a 3 column layout that is rendered to PDF in Rstudio. (see example below).
I would like all outputs to align at the top. how can I do that layout-valign=&...
1
vote
3
answers
44
views
ANY function used with dates to return the date/s in R
i have data like so:
Date of Dose 2
episode_1
episode_2
episode_3
episode_4
episode_5
2022-01-15
2022-02-01
2021-12-25
NA
2022-03-01
NA
I need to identify the dates which are 14 days greater than ...
-2
votes
0
answers
26
views
How to rename column in R with specfic numbers [duplicate]
I have columns the names of which are similar. For example
War.2025 War.2024 War.2023 War.2022 War.2021 War.2020 .... War.2010
I want to replace these column names, correspondingly with those column ...
0
votes
2
answers
44
views
Create rows which include values from previous and next rows [closed]
I have a longitudinal dataframe consisting of multiple IDs and multiple observations (OBS) per ID. Depending on the number of occasions (OCC) the observations are flagged with each new dose (ADMIN):
...
0
votes
0
answers
32
views
Building Docker image for Golem Shiny App fails due to own golem package
I am trying to create a Dockerfile for a Golem Shiny app, using the golem::add_dockerfile_with_renv function. I am new to using Docker and I can't get the image to build because I do not understand ...