Quantcast
Channel: Active questions tagged r - Stack Overflow
Browsing all 206180 articles
Browse latest View live
↧

Random Forest Appears to be Overfitting

I am constructing what is known as an 'Expected Goals' model for football. This metric measures shot quality and a probability is assigned to a shot to achieve this, i.e. the chance a shot will be...

View Article


Find index of all max/min values in vector in Rcpp

Let's say I have a vectorv = c(1,2,3) I can easily find which element is the max usingcppFunction('int which_maxCpp(NumericVector v) { int z = which_max(v); return z; }') which_maxCpp(v) 2 However, if...

View Article


R: Join two tables (tibbles) by *list* columns

Seems like there should be a simple answer for this but I haven't been able to find one:tib1 <- tibble(x = list(1, 2, 3), y = list(4, 5, 6)) tib1 # A tibble: 3 × 2 x y <list> <list> 1...

View Article

Problem installing factoextra package in R

Hi I am using R (and RStudio in Ubuntu) I am having the following issue.I use the line of code:install.packages("factoextra") During the installation I get the message:install.packages("factoextra")...

View Article

Cannot devtools::install_github() with R 3.6.1

I recently updated from R 3.5.3 to R 3.6.1 and rerun all my script. Unfortunately, I appear not to be able to install packages from GitHub repos. I have a slightly modified package that sits in my GH...

View Article


ggplot2 Force y-axis to start at origin and float y-axis upper limit

After a bit of searching I am still not happy!Is there a simple way to make a graph with a y-axis that starts at the origin and clearly shows all your data? Here's my problem:set.seed(123) my.data<-...

View Article

Looping creating new variable based on case when conditional

I'm new to R and trying to build a loop where create a new variable based on a case when conditional. for(i in 2:10){ variable_1 <- paste0("a_", i) variable_2 <- paste0("b_", i) variable_3 <-...

View Article

How to cluster the similar texts in R

I know similar question might have asked in this/different forum but I feel my requirement is different. I have 2 columns dataframe as shown in below:VerbatimLowestlevelTermAcute Bronchitis Acute...

View Article


In R, How do I filter a data frame to only include rows with >=2 non-NA values?

Suppose I have a dataframe Grp1 Grp2 Grp3 Trt1 NA 1 NA Trt2 2 3 NA Trt3 4 NA 5 I'd like to filter this down to only include rows where the number of non-NA values is greater than some total (in this...

View Article


Trying to find volatility in R but my code won't work

I'm using this following code to find the volatility of Tesla:library(quantmod) library(ggplot2) Tesla <- getSymbols("TSLA", src = "yahoo", from = "2014-10-01", to = "2019-11-25", auto.assign =...

View Article

How to use glmulti from python using rpy2?

consider the following dataframeimport pickle...

View Article

plot_usmap Error in match.arg(regions) : 'arg' must be NULL or a character...

I am trying to create a basic heat map of the below. I keep getting this error:********Error in match.arg(regions) : 'arg' must be NULL or a character vector******** This some of the work I've done to...

View Article

Apply arbitrary function that returns a list to vector in R

I recently asked a similar question (link), but the example that I gave there was a little too simple, and the answers did not work for my actual use case. Again, I am using R and want to apply a...

View Article


How do I assign numerical values to characters in a column in R?

I have imported a table (.cvs) in R, which has a column for income, where the income is given as either <=50K or >50K. >str(hausuebung_daten$income) chr [1:500]...

View Article

Make a existing function generic

I want to make an existing function generic. Thereby the default case should be the same as before, but I want to add a case for my own data structure.Thereby I came around setGeneric. For classes like...

View Article


Combine column values with partially matching names into one...

I've looked through SO and have not found any advice that accurately explains what I am looking for.I have a giant table. The first few columns have information about different expressed transcripts...

View Article

Add multiple columns with dplyr and fill cells based on condition

I am trying to:1) add multiple columns that correspond to existing columns (e.g., a1 exists and add a1_yes). 2) Next, if a given cell contains 1:3, put 1 in a#_yes column, otherwise, put 0. I can...

View Article


Looping and concatenating based on a condition in R

I'm new to R and still struggling with loops.I'm trying to create a loop where, based on a condition (variable_4 == 1), it will concatenate the content of variable_5, separated by comma....

View Article

trouble with optimx() ("Cannot evaluate function at initial parameters")

I would like to maximize a function of x1, x2, and x3 as followsf <- function(x) x[1]*14.1638 + x[2]*4.2062 + x[3]*0.6700 - x[1]*x[2]*2.2175 + x[1]*x[3]*2.8800 + x[2]*x[3]*2.0450 + x[1]*x[1]*9.9863...

View Article

R knitr - Object from cached chunk not being loaded

I am practicing with R Markdown and knitr. I am trying to cache a chunk that takes a little while to compute. When I run the script without caching that chunk, it does not produce any errors. However,...

View Article
Browsing all 206180 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>