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.

1
vote
0answers
10 views

Match multiple changing time periods between two datasets

I have two data frames, the first of which spans 3 months and has recordings of depth every 2.5 minutes. shark depth temperature datetime date location A 49.5 26.2 20/03/2018 08:00 ...
0
votes
0answers
8 views

Imputed predictions for missing time-series data nearly stationary (flat line)

I have player over time data that is missing player counts over several years. I'm trying to fill in/predict the missing player count data over different intervals. Data available here: https://1drv....
0
votes
2answers
15 views

separate (dplyr) with key in-between specific characters (after space and before capital letter) [duplicate]

I want to dplyr::separate on a minus (-) that has to be after a space and before a capital letter. My regex [\s]-[A-Z] includes the space and capital letter, hence removes by separating. I only want ...
0
votes
1answer
24 views

Regex for replacing commas only within square brackets

I have a text file and it contains comma separated strings. But some of the strings separated by commas are of the form [*,*,*,...]. So for example: "Hello", "Goodbye", ["Yes", "No", "Maybe], "...
0
votes
0answers
9 views

Shiny renderUI with widgets that are dependent on each other

I am trying to use renderUI to render multiple widgets. Also, I want some of the widgets that I render to be dependent on another widget that I render. Here is a small, reproducible example of my ...
0
votes
1answer
10 views

Create a list of data frames from list of data frame names (for merge_all)

I have a list of data frame names and I want to create a data frame list (or I want to be able to use the data frame name list to call the data frame itself). The idea is to be able to merge all data ...
0
votes
0answers
8 views

Remove CDATA from XML with regex in Windows CMD (powershell)

I am working with some XML data and I am stacked trying to remove CDATA in XML. I tried many ways, and it seems the simplier is by replacing all patterns hey <![CDATA[mate - number 1]]> what's ...
0
votes
0answers
11 views

Can't install package ‘ggpmisc’ is not available (for R version 3.5.0)

I'm trying to install ‘ggpmisc’ package in my Dockerfile, and I got the message : Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) Warning: unable to access index ...
0
votes
0answers
9 views

Making SQL and R cells always run together in R Notebook

R notebooks allow us to write SQL code directly with a dedicated chunk defined by {sql}. However, that call isn't very useful until we get its output and process it in the next R chunk: ```{sql ...
0
votes
0answers
8 views

How to select all nodes which have no attributes using rvest?

Using rvest, how to select nodes which have no attributes? For example: <nodes> <node attribute1="aaaa"></node> <node attribute1="bbbb"></node> <node&...
1
vote
1answer
15 views

How to label axes on a plot when making a custom function?

I need to make a custom function that would be draw several separate boxplot graphs. My function has two arguments: one for the x-axis, another for the y-axis. I want to label them with the names of ...
0
votes
0answers
16 views

R “unnesting” dataframe results in an error

I have a dataset that looks like this - dataset = data.frame(Site=c(rep('A',6),rep('B',6)), Date=c(rep(c('2019-05-31','2019-04-30','2019-03-31'),4)), ...
0
votes
0answers
8 views

Linear programming for Data Envelopment Analysis in R

I asked this on CrossValidated but since most of what I'm asking is about code, I also wanted to ask here. I apologize if it is not a suitable question. Suppose I have this dataframe. library(dplyr) ...
0
votes
1answer
15 views

Why can I not rename columns of a tbl?

I came across a weird function in dplyr's tbl: df <- as.tibble(iris) i <- colnames(df)[5] df$new <- df[,i] For some reason the newly created column new is named new.Species (at least when ...
1
vote
1answer
15 views

Is my R Regular Expression matching correctly?

I've struggled with regular expressions in general and recently wrote one that I think is working correctly, but I'm not sure. My question to anyone who takes the time to review my code below - is it ...
0
votes
2answers
19 views

How to remove parenthesis and inside text in r?

I have a dataframe with some species names + parenthesis and a number inside + some text, like : "species name(2) V1", which are present in dataframe$species_name. I need to remove it with gsub so it ...
0
votes
0answers
9 views

lapply with read_csv_chunked

I am trying to import multiple .csv files that are at least 1GB using lapply and read_csv_chunked. To create sample data lets look at: A <- data.frame(id = sample(c("A","B","C"), 100, replace = T),...
0
votes
0answers
10 views

Rotate the dial of a plotly gauge chart using R

I've seen this question asked several times and none of the solutions seem to be working for me. I'm brand new to R and thus don't necessarily understand all the ins and outs of these charts yet. I'...
0
votes
1answer
12 views

Condensing groups of multiple rows into single row maintaining the values with the highest x in R?

I have a data frame that includes multiple rows of data for each time and would like to group by time to create a condensed data frame. Columns a and b are cumulative sums from other columns and ...
0
votes
1answer
16 views

reshape column to row in a particular sequence

I want to reshape a data from wide to long; I want each record in the second column, after reshape, to be under each of record in the first column. For example, consider this: df <- data.frame(a=...
1
vote
0answers
29 views

Applying functions in list column to column in R

I am looking for the most elegant approach for this operation. I currently have a tibble containing a few list-columns of models and a column containing my test dataset for prediction. I can manually ...
0
votes
2answers
10 views

How to create a for loop to tune lambda and alpha for glmm elastic net?

I am using the MMS package in R to conduct an elastic net regression on a GLMM. What I want to do is tune the lambda (or mu which is what it is called in the package) and alpha values. I want to ...
0
votes
0answers
8 views

drop-down menu and check-boxes in r

I have a dataframe that has different columns. The first one is the year, the rest are different brands. I would like to plot a graph showing how those different brands performed throughout the years ...
1
vote
1answer
23 views

Understanding the output of all_equal

I have been using dplyr::all_equal to try and find differences between datasets. I don't always understand the output when the datasets are not equal. I've generated some small tibbles to try and ...
0
votes
0answers
28 views

How to pass bash variable into R script

I have a couple of R scripts that processes data in a particular input folder. I have a few folders I need to run this script on, so I started writing a bash script to loop through these folders and ...
0
votes
1answer
13 views

Create a list of dataframes and use it to call details about that dataframe

I am trying to create a list of dataframes and then using that list of dataframes to create another dataframe about the attributes of that dataframe. I wanted to do this by creating a loop. I tried ...
0
votes
0answers
12 views

Exchanging the axes of stat_ecdf plot in ggplot and thus plot the quantile function

My objective is to plot the quantile function of a distribution in ggplot. This plot is equivalent to the inverse of the empirical cummulative distribution function (ECDF). For example the inverse of ...
0
votes
0answers
8 views

factor analysis for mixed data - plot first supplementary column

I fit the model like this using the packages: FactoMineR and factoextra see also. model <- FAMD(temp, graph = FALSE, sup.var = c(1)) Here column 1 is the supplementary variable containing the ...
1
vote
1answer
13 views

How to conditionally color table elements using formattable and color_tile?

I am trying to set up a table with colored tiles that are colored conditionally based on the average of each column. Basically, the tile would be red if the value is below the average, and green if ...
0
votes
0answers
5 views

Rselenium check Server version every time

When trying to run the RSelenium code remDr <- rsDriver(remoteServerAddr = "localhost", browserName = c("chrome"), chromever = "75.0.3770.90", port = 4444L) it start to check Selenium Server ...
0
votes
1answer
23 views

How to calculate time difference, and add it up to the starting time?

I am trying to produce a linear regression model between 2 time points (those displayed as time of the day) - say "dispatched" and "received" - to observe whether there is a specific time of the day (...
0
votes
1answer
22 views

remove paired rows where lag == 0 and calculate % change using dplyr and chaining

I'm working with a very large tibble and want to calculate the % of growth of those tables over time (first entry to last entry, not max to min). I would also ultimately want to store any tables with ...
0
votes
0answers
29 views

What is the difference between '=' , '<<=' and ':=' operators in R? [duplicate]

what are the differences between these operators? I know = is assignment and <<= is used to assign from a parent environment with the same variable name.
-1
votes
0answers
14 views

Error in res.sum$coefficients[2, 1] : subscript out of bounds

Hi i am new to R and i am trying to do Time-series Analysis where there are 2 attributes Dates and Calls handled its a pretty small dataset of 78 entries for the first time. However the issue ...
0
votes
0answers
15 views

Generating only one density graph for each group of user - R

I have a binary data frame, which each row represents data related to a user (size of data frame :90 rows * 65 cols). The last column of this data frame contains the label for the users (4 labels :...
0
votes
0answers
25 views

How to add value to df1 if the observation exists in df2

My df1 has case number (1000 rows), and education industry(binary variable, with Y indicates the case is about education industry). My df 2 only have 100 cases and all these cases are in the education ...
0
votes
0answers
17 views

R Shiny shake when input is wrong [on hold]

I need some JavaScript code to add to this HTML bellow to shake the div when the input is not in acording with the form (e.g the code bellow blocks numerical inputs, so, when user type any number the ...
0
votes
0answers
8 views

Convert network/igraph object to plotly

I have build a network and created both igraph and network object. I can plot the object with ggplot and export to plot_ly using ggplotly. The problem is that i don´t have real control over the graph ...
1
vote
3answers
22 views

How do I add observations to an existing data frame column?

I have a data frame. Let's say it looks like this: Input data set I have simulated some values and put them into a vector c(4,5,8,8). I want to add these simulated values to columns a, b and c. I ...
0
votes
2answers
22 views

R: Create a table where cells have 1 or 0 decimal places after rbind

I am creating a table in R. The values in some rows should have 0 decimal places (such as number of people) while values in other rows should have 1 decimal place (e.g. percent of population). I have ...
1
vote
1answer
17 views

How do I subset a data frame by row for ALL columns [duplicate]

This seems like a very simple problem but I am unable to find a solution anywhere online. I want to subset a data frame to rows for which any column contains the string "string". This is how I want to ...
0
votes
1answer
16 views

How to create a map where the color is based on one variable (discrete), but the gradient is based on another variable (continuous)

I would like to recreate the pop vs soda map. I am using the state from maps library. Here is the code I am using. states = map_data("state") states%>% full_join(soft_drinks_plot, by = c("...
0
votes
1answer
17 views

How to assign in try-catch in R

I have written code below : I am sure it enters error part but it didn't assign to vector_a. anyone can help me? thanks a lot vector_a <- c() for (satr in 1:10) { my_gene <- input[satr,]$gene ...
0
votes
0answers
14 views

Is there a way to avoid overlapping bar when using a continuous scale with ggplot function geom_bar?

so i am working on some data and what i'd like to do is something like this : Model Whith bars following a continuous scale ( The time period) , a great bar_width (easy to read) , no overlapping ...
1
vote
1answer
10 views

How to display standardized y-scores in interaction plot

I am trying to plot a two-way interaction of standardized data in R using the package "interplot". However, the displayed y-scores are not standardized anymore. Why is that and how can I fix that? I ...
1
vote
2answers
18 views

How to subset a list of a list based on the name

I am given a list of lists. I would like now to subset the list based on the names of the sublist. L1<-list("A"=matrix(c(1:4),2),"B"=matrix(c("a","b","c","d"),2)) L2<-list("A"=matrix(c(5:8),2)...
0
votes
1answer
15 views

Get the event which is fired in Shiny and with grep (generated input)

I have input generated, _1,_2, etc...but I want to know which event is fired. It works : Get the event which is fired in Shiny? It works : Addressing multiple inputs in shiny But both don't work, ....
1
vote
3answers
27 views

Coalesce columns based on pattern in R [duplicate]

I have combined data sets in R, and each data set may use a different column name for the same data. I need to use a regular expression to identify the names of the columns I need to combine, and then ...
1
vote
1answer
16 views

How to change the x-axis scale

enter image description hereI have generate 1000 set of random data for Poisson Distribution and plot all the data into a probability distribution graph. I would like to change the x-axis scale as 2 ...
0
votes
1answer
31 views

R spread across multiple value columns

My dataset looks like this - dataset = data.frame(Site=c(rep('A',6),rep('B',6)),Date=c(rep(c('2019-05-31','2019-04-30','2019-03-31'),4)),Question=c(rep('Q1',3),rep('Q2',3)),Score=runif(12,0.5,1),...