Q&A for professional and enthusiast programmers

I have a slight problem with predicting values of a randomForest model. I always receive a following message: Error in predict.randomForest(rFmodel, newdata = testFin, type = "response") : REAL() can ...

I am trying to use the summarize function within dplyr to calculate summary statistics using a two argument function that passes a table and field name from a connected database. Unfortunately as ...

I would like to make a Shiny app which makes as much HTML div object as the lenght of selected the database, but there could be a communication problem between Shiny and JavaScript.
I tried to use ...

I have a vector consisting of mixed double precision values and very short strings of characters. I want to sprintf them, while showing results up to n digits. The problem is, I can't sprintf strings ...

I want to include a link to a local html file, which lives inside the www directory of my shiny app, inside a column in data.table. On click a new tab should open showing the html file.
I've found ...

Is there a package in R that has a procedure for logistic regression tree. And if so do you have examples of script and output from the procedures.

I am using igraph in R to calculate some network centrality measures. Once the measures are ready, I want to write the graph into a file (say Pajek format)
V(net)$deg_net <- degree(net, loops = F)...

I exclusively use python to scrape data off the NCAA stats website for a few sports.
However, for the majority of my model development and data analysis I use R. I was trying to figure out how to ...

I am trying to download a file based on the values in the rows of a data_frame. Here is what the data_frame looks like:
df_foo = data_frame( input_id = 1:10, file_name_id = 20:30
)
Here is an ...

I have a query which I've wrapped. I now want to put this in a GUI using gwidgets. I'm not sure how to, especially when it comes to svalues. I can build the window with buttons, but I'm finding it ...

I am BRAND new to R. I need help creating a simple stem-leaf plot in R. This is my data to create the stem-leaf plot. It is saved in an text file.
THIS IS HOW I WANT MY STEM TO LOOK-LEAF LIKE.
...

I am experimenting with trained text classification in R and have adapted this example to my own data. I have tested the example against two folders of text files, one consisting of documents ...

I have this code that produces at least 50000 files.
I have found out that the code slows at about 15000 files produced.
By accident, I deleted the folder and "put it back" after renaming it and the ...

I would like to to a logistic regression with the caret train function on the following data.frame:
lr_scaled <- structure(list(p1 = c(0.485563579637833, -0.616626170629997,
-0.0250480996345426, -...

I have started writing a shiny app.
What I want to achieve is loading a text file with a string in one line - like this:
$ cat testdata.txt
hello world
If the text gets loaded, the vowels are ...

I just noticed that for 2 x 2 tables where cells have low frequencies, even with the Yates correction, R seems to be computing chi^2 statistics incorrectly.
mat <- matrix(c(3, 2, 14, 10), ncol = 2)...

I'm trying to include an HTML widget created by timevis in an R presentation (.Rpres).
I'm using:
library(timevis)
data <- data.frame(id = 1:4, content = c("Item one", "Item two","Ranged item",...

Consider the following R-code:
i <- 10
j <- 0
m <- matrix(c(1,2,3,4,5,6), nrow = 3, ncol = 2, byrow = TRUE)
apply(m, 1, function(x) { if(i > 0) j<-1 else j<-2 return <...

Here are two snippets:
a = 1:1000000; res = as.integer(0);
class(res)
system.time(for (e in a) res = res + e ^ 2)
class(res)
###########################
fn1 <- function (N)
{ for(i in 1:N) { ...

I am very new to R and recently I have been playing around with the pheatmap library to generate, well, heatmaps. My problem is that I want to color my heatmap in a specific way. I'll describe below:
...

I'm trying to generate a sequence with the first 10 days for each month from 2010 to 2016 in RStudio.
I have tried this:
seq(as.Date("2010/01/01"), as.Date("2016/12/11"), by = "day")
and this ...

I try to manually alter the order of species in the legend. By default, they come out alphabetically. I want them in a specific order with a given color. I've managed to make the color list by using ...

These are the two url
http://onwatchseries.to/cale.html?r=aHR0cDovL2dvcmlsbGF2aWQuaW4veGVod3hra3Ywcnp0
http://onwatchseries.to/cale.html?r=aHR0cDovL2dvcmlsbGF2aWQuaW4vZjJtZHdnc204dThq
I have tried ...

I'm trying to draw n random numbers from a non uniform arbitrary probability distribution. My initial problem was that I didn't know how to do this statistically. Now I have found a beautiful function ...

Suppose I have these two DFs.
df1 <- c("A","B","C","D") #The problem is D (both DFs have a different number of rows)
df2 <- c("A","B","Z")
My goal is to create a new variable in df3 based on ...

I need to extract the maximum likelihood or REML estimates of the means, variances and covariances of continuous variables from a gls model produced by the "nlme" R package. The glsEstimate() function ...

I would like to select the range ID with the greatest quantity taken from a separate column using foverlaps, in a setting where a value falls between overlapping ranges. Although I'm quite familiar ...

I have the following matrix:
mat <- matrix(1:16, 4, 4)
> mat [,1] [,2] [,3] [,4]
[1,] 1 5 9 13
[2,] 2 6 10 14
[3,] 3 7 11 15
[4,] 4 8 12 16
I ...

I am making a Java GUI to go with my colleague's custom made R package, IntramiRExploreR, which includes a function made to create an interactive graphic via igraph and IntramiRExploreR's ...

I have a 18x3 data.frame. I would like a similar plot as in
ggplot: arranging boxplots of multiple y-variables for each group of a continuous x
but I want the x-axis divided into two variables (y0 &...

I have a dataset, simplified version is as following:
input <- data_frame(key=c(1,2),Color=c("Red,Green","Blue,Red"))
input key Color 1 Red,Green 2 Blue,Red
I want to use ...

I want to plot a density map of events in San Francisco. I need to display hexagons. I need hexagons's alpha to be close to 1 when the density is maximum and close to 0 when the density is minimum. My ...

I am trying to reproduce the example given in Goodfellow, I. et al.: Generative Adversarial Nets
The pseudocode is given on page 4 as "Algorithm 1". I am trying to rebuild it with the neuralnet ...

I am trying to make a two facet line plot as this example. My problem is to arrange data to show desired variable on x-axis. Here is small data set I wanna use.
Study,Cat,Dim1,Dim2,Dim3,Dim4
Study1,...

I am trying to create a graph of comparison between three categories and how they have varied their values over time.
However, I realize that I am systematically doing something wrong since instead of ...

Suppose I have an m x n matrix M1 and an k x l matrix M2 with l <= n. I want to find all those rows in M1 that contain some row of M2 in it.
For example consider the following situation:
> M1 &...

Is there a package to compute the Durbin h-statistic in R? I've got a version of an autoregressive linear model so I can't use the usual Durbin Watson statistic.

I have faced a huge problem while working with Mallet R package. I trained a cool model and want to share it with my colleague, but how can I do it? Well, I found out the way to save it with mallet....

I'd like to create a specific pairwise comparison matrices using a data frames. For this I have:
Data frame with 5 products (deltametrina,fipronil,imidaclopride,sulfluramida,tiametoxam) and 2 ...

i am learning how to use R program language. Now i am learning the pca technique, the question was to train a model with the knn technique and to find out which is the accuracy value for the training ...

I have a data.frame called df with a 8 million observations on 4 columns:
name <- c("Pablo", "Christina", "Steve", "Diego", "Ali", "Brit", "Ruth", "Mia", "David", "Dylan")
year <- seq(2000, ...

I have a data set (that I came up with) consists of the following observations and features to record user log activity over time. I would like to build a model that predicts (score) which user_id's ...

How do I (if possible) add lollipop sticks to point plots?
For instance,
plot(1:10, sin(1:10))
How do I add a vertical line (lollipop stick) from each of the ten points to the x-axis? Do I need to ...

I have several wide tables that should fit onto an html report, but I don't know how to do it.
Consider the following example. It's rather silly I know, because I could chop the digits off, but many ...

I want to add one arbitrary class-value column to the existing data set.As test(data set has 94 column) does not have a classification column, I want to add one with arbitrary class-values. This will ...

I put some code but the answer should be simple. My function (cut it shorter) 'results' should return 4 matrices. Shortly, it has a loop with a parameter 'i' inserted in the function 'matr' that ...

I have a data frame contr_factors, with 1932 rows and the following columns:
state, unarmed, not_flee, white_victim, attacked. I want to change the factors in the data set and I wrote this code:
...

I am having huge data that contains millions of records. I am just sharing subset of it. data<-structure(list(email_address_hash = structure(c(1L, 1L, 2L, 2L, 2L, 3L, 3L), .Label = c("...

I am trying to implement two-class classification for the two extracted feature set(Running and Hugging) calculated with wavelet correlation.
The thing I am trying to reach is,what is the accuracy ...

I am trying to implement a knn density estimation for variable 'speed' from data set cars. I use K=4. I am not totally sure about how the knn density estimate function works and I am trying to learn.
...

Translating... 0%