Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [r]

R is a free, open-source programming language and software environment for statistical computing, bioinformatics, visualization and general computing. Provide minimal, reproducible, representative example(s) with your questions. Use dput() for data and specify all non-base packages with library ...

2
votes
0answers
5 views

Clarification on igraph::count_multiple()

I expect igraph::count_multiple() to count edge multiplicity, which the documentation seems to reflect. However, it doesn't always result in whole numbers. An example: library(igraph) library(dplyr) ...
0
votes
0answers
17 views

Negative number comparison error

I have a problem for below comparison in R dataframe if ((RSI<=40) & ((BUY_FACTOR>=-.5) || (BUY_FACTOR<=.5))){ BUY_CONDITION<-"TRUE" } It works fine for BUY_FACTOR positive ...
1
vote
2answers
10 views

How to assign the elements to different subsets according to the number of letter “A” within the element in R?

I want to assign my data into different groups depends on the number of letters "A". For example, library("stringr") data1 <- c("apple","appreciate","available","account","adapt") data2 <- c("...
0
votes
0answers
2 views

Error when tuning xgboost model in caret's train function in parallel

I am trying to run some cross validation tuning in caret for an xgboost model. I have a large tuning grid so I'd like to run it in parallel. I set up the data as a sparse matrix, set up the tuning ...
0
votes
2answers
14 views

Look up and extract values exceeding a threshold in r

I have two data frames: #df1 df1 = data.frame("id" = c("A","B","C","D","E"), "dev" = c(213.5, 225.1, 198.9, 201.0, 266.8) df1 id dev 1 A 213.5 2 B 225.1 3 C 198.9 4 D 201.0 5 E 266.8 #...
0
votes
0answers
9 views

How to suppress #> output created by patchwork's plot_layout()

I am running code to use the plot_layout function from the patchwork library and find that for some plots, plot_layout creates the combined plot view, but also displays some messages prefixed by #>....
-2
votes
0answers
15 views

R Shiny VIM Package aggr

How to display only the missing histogram and not the plot for combinations with VIM package?The below code displays both the plots- for missing as well as combination:- output$miss <- renderPlot({...
0
votes
1answer
42 views

ifelse() gave me wrong output

I got a data.frame named DF1 Digit Country 1 A 1 B 2 C 16 China P Rep 15 Indonesia i'm using DF1$Digit <- ifelse(DF1$Digit<=5,"",DF1$Digit) it become Digit ...
0
votes
1answer
8 views

r MatchIt output: cannot see first output showing mean match data

because the output of matchit in the console shows so much data, I am unable to see what it at the top of the output--this is where the match improvement data is. I increased my maxprint but it still ...
3
votes
3answers
35 views

R dplyr: change the row value of columns having an specific name

I have a data frame. One of the columns has string values that I want to use as a condition for the name of the other columns. For example, df <- data.frame( cond=c("a","b"), aVal=c(1 , 2), ...
0
votes
1answer
16 views

Using Keras model as a part of Shiny app

So, my goal here is to create an Shiny application which takes user's input, changes it into a matrix, then uses a pre-saved Keras model (basically saved weights) to predict a certain variable of his (...
0
votes
0answers
20 views

R: how does a foreach loop executed in a function export the output of the function?

I would like the function FUN3 defined below to use parallel computation and to return an object (data file), but cannot achieve my aim… Here is the code: FUN <- function(x,y,z) { x + y + z } # ...
1
vote
1answer
17 views

Select columns by regex matching

I know there a lot of posts on this, but I couldn't find any that helped. What I'm trying to do is simple. I want to select (or drop) columns based on whether a letter is present in a column name. ...
0
votes
1answer
20 views

Reorganize a List with Lists in a new list in R

This is my list: mylist=list(list(a = c(2, 3, 4, 5), b = c(3, 4, 5, 5), c = c(3, 7, 5, 5), d = c(3, 4, 9, 5), e = c(3, 4, 5, 9), f = c(3, 4, 1, 9), g = c(3, 1, 5, 9), h = c(3, 3, 5, 9), i = c(3,...
0
votes
0answers
12 views

Shiny widgets do not work unless another widget is activated

I have a functional shiny app whose logic is described below: Logic of the app: The user chooses one of the Tests by using the selectInput() "Label". This is the main operation and then he is able ...
1
vote
1answer
22 views

Mutate (dplyr) based on multiple conditions (time intervals)

I'm struggling with conditional merging of the 2 datasets I have. The first one has the following structure ID Trip number Time start Time Stop 1 1 2018-...
0
votes
0answers
19 views

R Environment does not recognize getCensus function despite loading CensusAPI Package [duplicate]

I am using R to draw census data from the United State Census API. However when I run the code I get an error that I cannot remedy despite looking everywhere for a similar issue. It seems like a ...
0
votes
1answer
21 views

Coding weighted mean (R)

I am having trouble with a piece of my code. I want to perform a weighted mean but the value I get is not the value I obtain if I calculate the weighed mean myself. Here's how I'm coding the ...
1
vote
1answer
23 views

Convert data of overlapping time ranges to data of distinct time ranges

I have data that consists of observations of the range of time a particular status applied for an individual. An individual can have multiple statuses at a given time, or have no stats at all (in ...
2
votes
0answers
12 views

Google basemap and geom_sf aligned WITH custom geom_image symbols and annotation labels in R

I would like to use custom symbols and annotation on a geom_sf polygon layer that is placed on a google basemap. Initially, I had difficulty with the basemap and polygon lining up correctly (...
-1
votes
0answers
13 views

Error in Officer package (R) with annotate_base for PPT

I'm having multiple issues trying to run the annotate_base function for a custom powerpoint template. I don't have a straightforward example to share, but basically when I run annotate_base for a ...
0
votes
0answers
7 views

How to use the nlrob() function from the robustbase package in R to do LAD regression?

I would like to use the nlrob() function in the robustbase package in R to do LAD regression. The LAD estimator is an M-estimator with the following Psi function: psi = sign(x) For that reason I ...
0
votes
2answers
35 views

R loop change variable names

Looked over several posts on this topic, but still couldn't figure out. Thought I'd just ask: I wrote a for-loop: for (i in 0:5) { est16_y2016$pov50_[i] <- est16_y2016$pop[i]*est16_y2016$...
0
votes
1answer
20 views

create a new column according to condition in another column R

I would like to create a new column "test" according to dates calendar. If duration = n I put the same value for temp test=temp corresponding to n-1 days before dates Ozone Solar.R Wind Temp Month ...
1
vote
1answer
13 views

Complex XML Parsing in R

I am trying to parsing a xml file that is nested. <GENERIC_ROUGHDRAFT> <HEADER compName="California" dateCreated="2018-08-07"> <COMP_INFO> </HEADER> <...
1
vote
1answer
14 views

r update.packages() not updating packages that are imported by other packages

I recently updated to R 3.5.1 from 3.4.3. I updated my packages as follows: (a) copied packages from my old library into my new library (taking care not to overwrite the base packages) (b) ran ...
-1
votes
0answers
15 views

Calculating area in Gain charts using R

I have plotted the gain chart by calculating cumulative gain of the result produced by my ANN model. Now my question is how do I calculate area from the graph. I have to find out the area between ...
0
votes
0answers
15 views

3D plot in R error

I have been trying to plot a 3d plot of my data but I cannot figure out how to overcome some errors. Any help is highly appreciated. >head(d1) #produced through the melt function as seen below ...
0
votes
1answer
14 views

Bar plot separated by a variable and colored by another variable

I've spent an astonishing 4 hours googling and finding not-quite the same answers to do something that should take me 30 seconds. Here's my data: DFj <- read.table(text="Intervention Timepoint ...
0
votes
0answers
11 views

Failed to library(ggplot2) because WinError 32 when use R Magic in Jupyter notebook

I have already use "conda install rpy2" to install rpy2 package in my python3 environment.I open my jupyter notebook with py3 kernel and run following code: %load_ext rpy2.ipython #Load in the r ...
0
votes
2answers
21 views

R: ggplot for hover text

My data (final.df) looks like the following: A B C Y 1 0 0 0 0 0.05 0 0 1 1 0.03 .... Based on the comment below, here is a ASCII text representation of the dataframe. structure(list(A = c(...
0
votes
0answers
12 views

Submit POST form when rvest doesn't recognize submit button

I would like to submit the following form (the form appears after you click on link "Kliknite na ..."): http://www1.biznet.hr/HgkWeb/do/extlogon I have to enter one parameter, named "OIB" and submit ...
4
votes
1answer
60 views

The different among r regular expression symbol “+”, “*”, “?” [duplicate]

I am a beginner of Regular expression in R. I am very confused about the usage of the following symbols, +, * and ?. I found the definition from the R's documentation: + : one or more * : zero or ...
1
vote
0answers
16 views

h2o.importFile() does not import full data frame in R

I have a dataframe of 50 rows (subjects) and 572288 columns (variables) When parsing the data.frame into an h2o object I lose variables and end up with 51 rows and 419431 variables. It does not ...
0
votes
1answer
11 views

RStudio: Executing RMarkdown code in the console (and plotting)

I'm using RStudio v1.0.143 on an old Mac, and something changed one day in how RStudio handles execution of R code in the R chunks of .Rmd files. It used to be the case where I could have the text ...
1
vote
0answers
30 views

Issue when creating zip file from directory

I have trouble with creating zip file from R. The same code worked perfectly at work with R version 3.4.2, 32 bit computer. Now I am trying to run the same thing on R version 3.5.1, 64 bit computer, ...
1
vote
1answer
21 views

Group/Aggregate data.table columns by a ref from another data.table file.

I am trying to aggregate columns of a following data: Label A B C D E 1: a 0.00 0 0.00 0 1 2: b 0.00 0 0.00 0 2 3: c 0.00 0 0.00 0 3 4: d 0.00 0 0.11 ...
-1
votes
0answers
15 views

Passing object to lines function in R for plot data

my issue is the following. I use package ROCR for plot data. the function "performance" return an object that i pass to plot the data like this: example <- performance(prediction1,"tpr","fpr") ...
0
votes
1answer
16 views

Is it possible to locate a star glyph on a scatterplot using ggplot2?

This R code outputs 5 star glyphs but I can't control their location: stars(mtcars[1:5, 1:4], key.loc = c(6, 0.5), main = "Example of 4 glyph stars", labels= NULL, flip.labels = FALSE) I want ...
0
votes
2answers
23 views

Add specific rows to create new row using R dplyr

I am trying to add a new row Total which would be a sum of apples+bananas+oranges Metric_name May Jun 1 apples 11 34 2 bananas 632 ...
0
votes
1answer
26 views

Trying to create new column that has the dataframes name through for loop?

I have a list of dataframes and I want to create a new column in each of those dataframes that is the name of the dataframe, which I also have in another list. I'm not sure why but it ends up creating ...
0
votes
1answer
25 views

How to get a list of IP addresses from an IP range using R?

I have log data in which one of the columns have IP ranges and the next column is corresponding ports. Eg: IPRange Port 10.78.64.0-10.78.66.255 D, A, C I need to expand the ...
0
votes
0answers
16 views

Future/Promises and Capturing Output

I have a shiny app that uses a fairly long function that periodically prints updates to the console. I would like to renderPrint() these to a shiny window so the user knows that work is still being ...
1
vote
4answers
25 views

How to use map() function on multiple columns

I have got a data frame which looks like this: x1 x2 x3 x4 ... 56 45 34 76 ... 56+3 56 42 43 ... 38 53 56-1 55+3 ... ... ... ... ... ... In each row in more ...
1
vote
0answers
26 views

Converting a data frame to a parameter list for rmarkdown

I’m trying to covert a data frame to a data frame with a list of parameters to send to a parameterized markdown report. I'm following R Markdown: The Definitive Guide as my guide. library(tidyr) ...
-1
votes
0answers
12 views

Plotting over multiple lengths and columns

I am wanting to plot on the X axis 17K sets of intervals, where I plot the start and stop intervals for each Chr column. However, these intervals are not plotting correctly to each chr? This I figured ...
0
votes
0answers
33 views

Sum Working With Subset in R

What is incorrect about the following code? TotalCnt<- sum(subset(Dataset,Group=="Test")$Fall_2016_Fall,na.rm=TRUE) It shows up as 0L. I think the following code is working though: TotalMN <-...
1
vote
0answers
16 views

daterangeinput without fluidpage in shiny dashboard

I have an issue while creating a shiny web app using semantic.dashboard library. Below is the code for my app. library(semantic.dashboard) # Define UI header <- dashboardHeader( ) sidebar <- ...
1
vote
1answer
29 views

subsets of different vectors R

I have three vectors as shown below. q = c("a == 1", "a == 2", "a == 3") w = c("b >= 50", "b >= 100") t = c("c >= 40 & c <= 80", "c > 80") I want to be able to combine all the ...
1
vote
1answer
21 views

Is there an equivalent to RStudio's “.rs.askForPassword” in Python?

I want to connect to my database in Python, but i don't want to show my password to other users, like .rs.askForPassword does exactly what i need in RStudio. Here's an example: library(RODBC) conn = ...