Questions tagged [r]

R is a free, open-source programming language and software environment for statistical computing, bioinformatics, visualization, and general computing. Please provide minimal and reproducible example(s) along with the desired output. Use `dput()` for data and specify all non-base packages with `library()` calls. Do not embed pictures for data or code, use indented code blocks instead. For statistics related questions, use https://stats.stackexchange.com.

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

Questions with ggplot() and geom_smooth()

Currently I want to do a plot in ggplot where the size of the line and the color changes according to the geom_smooth done. I've been trying to add this in the geom_smooth aes option but it displays ...
0
votes
0answers
3 views

shinydashboardPlus: Opening a closed boxPlus

How can I open (using code) a closed boxPlus? https://cran.r-project.org/web/packages/shinydashboardPlus/vignettes/improved-boxes.html
0
votes
0answers
11 views

How does agnes() in R treat factor columns?

I'm new to R, and I haven't seen this discussed anywhere, so I'm only 95% confident of my results. Reading the agnes() documentation, I see that in the input "matrix or data frame, each row ...
2
votes
1answer
19 views

referring to lists within larger lists from a loop

I want to cycle through many models and output the coefficients Basically I want to do what the code below does. But then refer to each object in the list that is generated that contains the object ...
0
votes
0answers
10 views

Error: leaps requires full-rank design matrix

I imported the following data set, > APPENC05 V1 V2 V3 V4 V5 V6 V7 V8 V9 1 1 0.651 0.5599 15.959 50 0.0000 0 0.0000 6 2 2 0.852 0.3716 27.660 58 0.0000 ...
-1
votes
1answer
15 views

dplyr mutate_if with multiple conditions?

I have data that looks as the following: dt <- data.frame(id = sample(LETTERS, 100) ,A = seq(1:100), B = sample(1:100000, 100), C = rpois(100,1), D = seq(1:100)^3) I am trying to transform any ...
0
votes
0answers
8 views

create smooth plots from different variables of same data set

I'm trying to create a smooth plot in which color represents manufacturer and the lines represent the overall relationship between disp and hwy. I can do that with this: df <- subset(mpg, ...
0
votes
0answers
6 views

How to show “Please wait” in self-hosted shiny app until packages are attached

In the applications hosted in the shinyapps.io we find a "please wait" message until the libraries are attached or server is ready. Do someone know how we can achieve the same with a self-hosted shiny ...
-1
votes
0answers
14 views

How to make an animated bar chart like this

Is it possible to use R---perhaps ggplot2 + gganimate---to make an animated bar chart graph like the following?
0
votes
0answers
11 views

how can i make the x scale bigger in python plot

how can i change the scale of this code to make the plot looks bigger? import matplotlib.pyplot as plt import numpy as np SMALL_SIZE = 15 MEDIUM_SIZE = 30 BIGGER_SIZE = 12 ...
0
votes
0answers
12 views

Trouble accessing help documentation for a package I created

I'm new to R so I hope this isn't incredibly obvious. I created a package that contains two functions. I provided documentation using roxygen2 for each of the functions, documented and built the ...
0
votes
0answers
10 views

Working code stopped working when reloading rStudio

I have several chunks of code that use pipes and many of them have stopped working when I reloaded rStudio that did not happen before. The following code was working before: library(dplyr) df <- ...
0
votes
1answer
12 views

Apostrophes and optional argument (?) in grep vs agrep

When I run the below 4 lines of code I dont get the same result from all 4. Why is the last line not finding a match? grep("CPA's", c("CPA's")) agrep("CPA's", c("CPA's")) grep("CPA'?s?", c("CPA's"))...
-2
votes
0answers
11 views

extract a text string after spaces and a symbol with gsub R

I need to extract the first word (German) from the following text string substr(details[1],0,50)%>% + gsub("[^a-z/A-Z/,/ ]","" ,.)%>% + gsub("A-Z.*" , "", .) [1] " , German, European,...
-1
votes
1answer
17 views

Range Bar Graph in R

The plot is just for visualization. The bars rather than starting at a common zero point, begin at min value for that particular bar and end at max value for particular bar. When I use ggplot geom_bar(...
0
votes
0answers
11 views

Why does my calculation of variable importance (Using Gini Impurity) yield negative results? (Ranger Package)

I am currently creating a model for class that aims at predicting movie ROI based on five independent variables. For the model, I have made the ROI categorical with 4 different classifications. ...
0
votes
0answers
14 views

How to print beta symbol before regression coefficients in export_summs (R)

I am using the export_summs function to format the output of a linear model. The default is to print the regression coefficients, but I want to add a "β = " before each coefficient. I have looked ...
0
votes
0answers
22 views

Accessing individual dataframes from a split function in R

I'm new to R am trying reorganise my data based on the sampleID I've used the split() function in R which has does exactly what I wanted it to and stored my information in new data.frames My question ...
1
vote
2answers
20 views

R : creating a variable conditionally if another variable increments by one

I am currently using data.table in R and I have a data set like the following: ID mon age 1 1 22 1 2 56 1 5 106 2 1 34 2 3 65 2 4 76 I would like to ...
0
votes
0answers
25 views

Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :

My csv file osagecreekfinal has dates (Date) in (YYYY-MM-DD) and L.s.ha is a continuous variable. I have performed this same code on 14 other files but it will not work for this one. I am simply ...
0
votes
0answers
12 views

Toggle input options and slider range

I gotten some great help to have reactive function working from Chris. However, there is still some issues I have and hoping there could be suggestions. Firstly, within the reactive function, I am ...
0
votes
0answers
7 views

How to include YAML when using includeMarkdown inside Shiny app

When using rmarkdown::render() outside of a shiny app the title, date, author and other options set in the YAML header are included at the top of the rendered HTML file. However, when using ...
0
votes
0answers
20 views

How can I exclude rows from a table, using the rows' names from another table? [duplicate]

I have a .csv table1 A B C D E gene1 1 3 5 9 gene2 0 0 4 4 gene3 1 0 1 2 gene4 5 5 0 10 gene5 2 0 0 2 I also have another .csv table2 A B ...
1
vote
2answers
29 views

Separate a string of characters space-separated of dataframe in different columns

I am pretty new at using R and I have some data that I need to tidy a bit before I can use it. Basically I have a dataframe with a bunch of rows and columns and in every cell of this dataframe I have ...
0
votes
0answers
14 views

dbFetch, write to another table, and dbFetch again?

I would like to work on a large database table. The idea was to read some rows, process them, append the result to another table, and so on. In code: stmt <- "SELECT * FROM input_table WHERE ...
0
votes
0answers
18 views

Is a Two sample T-test appropriate for my data? [migrated]

sample 1: 9, 13, 30, 23, 34, 43, 39, 113, 4, 5, 11, 17 sample 2: 16, 25, 22, 67, 88, 43, 59, 39, 69, 93, 41, 231 The data is unpaired I want to calculate a confidence interval for the difference in ...
0
votes
1answer
24 views

how to make a data frame of pre-post score with two columns, group and score

I had two set of test scores: pre <- c(0,0,0,0,0,0,0,0) post <- c(0,4,0,5,0,5,4,2) I want to create a data.frame that has two columns, one is "group" that shows pre-test and post-test score (...
-1
votes
0answers
27 views

Filter Columns Based on Specific String Pattern in R

I have 70 + columns with random string names as the column names. [1] "ID" [2] "Label_926" ...
2
votes
1answer
23 views

Width of shading lines without affecting border width in R

I'd like to draw thick angled lines in R without changing the border width. Here's an example where the border width is also changed: barplot(c(3,4,5),col="red") par(lwd=8) barplot(c(3,4,5),col="blue"...
0
votes
0answers
12 views

US Map in Shiny App does not change with option

I am trying to make this shiny app where I want to show the Average Passing Yards per Season of all NFL players in that state. football <- read_csv("Football.csv") inputPanel( selectInput(...
1
vote
2answers
19 views

Cluster observations based on multiple variables

I am looking for an r function to create clusters in my dataset based on two variables (hope "cluster" is the right name for what I want to do) . Every two observations with the same value for ...
2
votes
1answer
27 views

How to plot copy number variation profile in R?

I'm trying to plot a copy number variation profile plot in R. This is what I'm looking for but with all the cells in my data. Ploidy is on the Y axis and chromosome number is on the X axis This is ...
0
votes
0answers
7 views

R, keras, TypeError: Input 'b' of 'MatMul' Op has type float32 that does not match type int32 of argument 'a'

I'm very new to keras/tensorflow and I'm getting an error when predicting with my trained model and I have no idea why. My aim is to predict demand for a product (please ignore that I call it ...
-2
votes
0answers
21 views

How to change the date format like “Aug- 19” to “yyyy-mm” in r? [duplicate]

I have a dataframe that the column of date is like "Aug - 19" and it is a character. How can I change it to the format like "2019-08"?
0
votes
0answers
12 views

R Shiny - Managing the return values of dynamically inserted Shiny modules

The app below inserts a module each time the Add button is clicked. Each module's UI contains two selectInputs, letter and state. The module server function records the user's selection for each ...
0
votes
1answer
20 views

create virtual patient data set [duplicate]

I would like to create a virtual patient data set in R , where in I would like to have the following time points TIME = seq(1, 10, 1), be repeated for 3 unique patient IDs
0
votes
0answers
4 views

Install TSclust on Mac Sierra, RGL issues

System in: Mac, os: Sierra 10.12.6 I was attempting to install TSclust using the following command on my xterm command line after opening Xquartz. I have also tried running this command from the mac ...
0
votes
0answers
19 views

What determines whether a package will compile from source and how to change?

The symptom I can see is that when install.packages("dplyr") is run from one mac, it installs almost instantly, whereas the exact same command from another macbook takes ~5 minutes to install, and has ...
0
votes
0answers
9 views

Add large .rda file to a github package

Around two years ago, I wrote an R package with a dataset with all the reimbursements by Brazilian congresspeople from years 2009 to 2017. However, we are in 2019 and the .rda with my data has 103.7MB ...
0
votes
1answer
22 views

Convert column of a data.frame to Named vector

I have a data.frame that has a column which its attributes look like this: $ variable : Named num 0.887 0.886 0.887 0.887 0.887 ... ..- attr(*, "names")= chr "2010-01-04 00:00" "2010-01-04 00:01" "...
0
votes
2answers
19 views

R interpreter missing in zeppeling docker image

I´m working with zeppeling notebook on a Docker container from the oficial apache image: https://hub.docker.com/r/apache/zeppelin The issue is that I´m not finding the R interpreter there If I try ...
0
votes
0answers
14 views

R and Shiny App Secure Connection to Third Party Robinhood API

The R package RobinHood allows users to connect to their accounts and do various things. All of the functions within the package rely on one function called RobinHood which takes in your username and ...
0
votes
0answers
20 views

Interpretation R results linear Model with Interactions

I´m trying to analyse the effects testosterone in combination with a specific pill type can have on reactiontimes.For example, if there is a difference in the reactiontimes between people who have low ...
0
votes
0answers
38 views

Coloring under a specific area with another ggplot geom_area

I am desperately trying to put another geom area with ggplot in a specific area of my plot. -I would like to have the area where I put the geom_rect colored under the first line of Probe "0.415cm/s". ...
0
votes
1answer
13 views

Center Tabs and Header in R Shiny

I would like to center both my tabs and header within my R Shiny page. I have tried to use div() with class=span7, but it throws an error of missing an argument. shinyUI(fluidPage( headerPanel("...
2
votes
1answer
39 views

How to save a large dataframe and quickly load it in R? [duplicate]

I'm currently working on a project to extract qualitative and quantitative (statistics) data about the Acadie portal in Wikipedia FR. There are 1905 entries to work with and 16 variables. Every time ...
0
votes
0answers
7 views

Different Legend for each layer in multilayer-raster in Leaflet

I have a raster that consists of 8 layers. Each layer has a slightly different range in their cell values. The layers itself cotain values about population etc. I'd like to select a layer in the ...
1
vote
2answers
39 views

R : Finding minimum value on the basis of changing preceding and suceeding values in group by column

Adding for replicability: data.frame( product=c(rep("x",2),rep("y",3)), price_category_from=c(10,20,10,20,30), price=c(30,31,31,30,27) ) As shown below, I have a table which I would like to group ...
0
votes
0answers
11 views

How can I calculate the Sobol sensitivities of the area under a curve in R?

I have written a fairly complex ordinary differential equation pharmacokinetic / pharmacodynamic model in R using the dMod package. I’ve converted this into equations readable by the ODEsensitivity ...
0
votes
2answers
36 views

How to replace values in df that are NOT fulfilling condition

I am trying to clean my data and can't find a way to replace values that are not according to my conditions like in the following example: df1<- data.frame( A=c("a","b","c"), Ch=c("c1","xyz","c2")...