Q&A for professional and enthusiast programmers

I want to convert a data table containing numeric values for 305 variables and 361 observations into a data table of same size containing dates. The data table does contain "NA"s.
The numeric value ...

I have a .txt file that contains values and is tab seperated. It looks like this:
G-clef E1,E1,B0,G0 E1 E1 E1 E1 F1,C#1,A0 G1 A1 G1,C#1 G1,D1,C#1 C#2 B1,F1 C#2 C#2,G1,E1 C#1 C#1 C#...

I am new to R as a whole, I know that some of the packages in can help me render maps at county level, What I need is apply color /shades to some counties, for example in Texas, not all of them, So I ...

with df like below
df <- data.frame( name = rep(c("A", "B", "C"),2), type = c("10", "10", "10","20", "20", "20"), val = c(1,2,3,4,5,6)
)
> df name type val
1 A 10 1
2 B 10 ...

I have created a model-average and would now like to plot the linear relationship between the response variable and the sole significant predictor (component model) using the model-averaged ...

I would like to overlay 2 bar charts in Plotly (R), but cannot figure it out. Can easily be done in ggplot2, but qqplotly renders it incorrectly so I would like to make the chart in plot_ly. Thanks ...

I have data like this:
club <- c("a", "b", "c", "d","d", "a")
all.scores.math <- c(1,2,5,3,4,4)
all.scores.english <- c(2,2,4,3,4,1)
data <- cbind(club, all.scores.math, all.scores....

I have built a SVM model using the R package e1071 and the iris data set. I have split up the iris data into a training and test data and built the SVM from the training data. Now I would like to plot ...

I'm trying to scrape the locations off some rental property listings website using R (rvest). The website has locations in the form as a embedded google map with a pin on the general location of the ...

I have a model like this
EG= α0 + ∑βi*X + ∑ϕi DPEG *X + ∑ϒi DPayout *X + ε
where DPEG and DPay are dummy variables, X is the vector of independent variables (Payout,etc)
β1, φ1, ϒ1 are the ...

I am interested in making an interactive plot in R+Shiny (or R and some other package) that is similar in spirit to this one: http://benschmidt.org/migration2/. I don't need to have two plots side-by-...

For a day, I have been trying to send an email to my gmail account but unfortunately nothing is working. I have tried with different ports on the smtp.gmail.com and also enable google setting for less ...

A represents how much each industry of country is related to other industry of other country. It could takes values from around 1.00. So diagonal element of matrix A is close to 1 but the off diagonal ...

For the life of me I cannot work out why I cant get this code to work:
rda(taste ~ . -quality, data = train)
I keep getting the error "Error in [.data.frame(m, xvars) : undefined columns selected" ...

I'm unsure why facet_grid is generating different charts than I get without using facet_grid. If you have any ideas on why I'm getting two different results please let me know.
Thank you :)
my code:
...

The dataset contains information about superheroes. This code removes the annoying bracket part from the string 'name':
# package loading
library(fivethirtyeight)
# data opening
data(package ="...

I have a issue with a for loop which should apply an ANOVA in a dataframe
for(i in nom_soilbis){
anova_s[1,i]=aov(mt_s[,i]~mt_s$temps)$p.value
}
Error message is
"number of items to replace is not a ...

I have a data frame containing 20 year monthly house prices (columns) for 100 cities (100 x 20 matrix). I need to calculate the quarterly averages
city_homes_subs$Q12016 <- ((city_homes_subs$`...

I have the following plot of a stock's price in response to time on different days. Currently, using geom_text I'm able to label the points of interest where the Y value deviates from 0 by a ...

I have started using R. I keep getting this error
Error in tw_from_response(out, ...) : unused argument (until = "2016-11-28") when trying to run code PBunting<- userTimeline('@PeterBuntingMP',n=...

I am creating a django project in Windows in which I need to call few existing R codes (saved as .R files) via django views functions. To achieve this, I am using rpy2 python library.
After including ...

This is very basic question. 1^NA gives 1, but 1*NA gives NA.
Any other numeric such as 1.1 or 2 to the power of NA gives NA
Is there a way to set an option which would give 1^NA as NA?

I have a data-set/data-frame with columns Description, Department Name, Priority, Doctor name & Location.Description data comes as free text from from the UI.
Based on historical description's ...

I try to make a plot using ggplot2 using this code:
points <- data.frame(x = fit$points[, 1], y = fit$points[, 2])
ggplot(points, aes(x = x, y = y)) + geom_point(data = points, aes(x = x, y = y,...

It seems that reactive encapsulated variables, so the variable inside tweets can not be accessed... so how to fix it ? or do not use reactive ?
the csv file tweets_davin and just use both for 2 ...

I have a csv file with quoted numeric column such as "'0001',a\n'0002',b\n'0003',c", for fread(), the first column will be character but for read.csv() the 1st column will be numeric type.
How can I ...

I wrote following function
costFunc=function(par,dat){ state=sapply(mySamp,stateofMC,windDat=windDat) sum=0 for(i in 1:3){ state_loc=which(state==i) state_dat=dat[...

This code is slow for n.col=31; n.row=1600000, and I can't think of how to optimize it in R. I need to know the balance of several items at each step, but only one balance changes per step. I have a ...

I'm trying to run a code in python that creates all possible combinations of different variables value.
in R the code will look like that:
a=unique(df$a)
b=unique(df$b)
c=unique(df$c)
d=unique(df$d)...

can someone tell me how to evaluate the quality of a data file ..?? What procedure is widely used to check the data Accuracy, Completeness, Consistency, Timeliness, Uniqueness, Validity and others ...

My data includes data on different people (ID) over each Day of the week and the time they spend in different areas of the hospital or Ward. I am given this time, in minutes:seconds or Duration. An ...

I've been using type III SS in R for years now seemingly without issue. But now I'm having an issue with type III sums of squares in R producing highly inconsistent results with the car package.
Yes,...

I have been given a file with time, in minutes.seconds, in the following format:
TimeInput <- c(13.66, 14.08, 12.86)
How do I convert a numeric value, for example 13.66, to minutes:seconds format ...

I'm trying to replicate the Visualization of a Randomly Generated Branching Process and the book does not have the plot command. I tried the following code but it's not plotting but also not giving ...

I have created two corpuses: one containing tweet texts and another containing company names. What I'm trying to do is find which companies are mentioned in tweets.
Example document of a tweet:
> ...

I am performing a knn analysis of some data. I have both categorical (with more than 2 factors) and continuous data. I found a package that accounts for this situation (knncat) but there's very little ...

I have data frame with 617k variables and I would like to calculate the time differences (in minutes) between any two rows for the same category (the category is IP).
So far, I didn't find a relevant ...

I know that I can add edge constraints as prior knowledge when I use PC algorithm in pcalg (fixedGaps and fixedEdges). In tetrad one can also add tier constraints as prior knowledge before using the ...

I have the following type of data (it's a subset just for the example):
mydf <- data.frame(Score = c(55.17241, 79.31034, 96.55172, 31.03448), Subgroup = c("A", "B", "C", "A"), ...

To run a program in R .Do some modifications on the graph with Photoshop and upload it on net through python.
Is this possible?

I need to flatten a list but keep the null elements. unlist() will remove the NULL or character(0) elements, which results in a vector with fewer elements than a list.
How can I flatten a list ...

I am using a main R function to call a series of R functions from different scripts. In order to reproduce results, I set.seed in the beginning of my main script. In the code, sample() function to ...

I want to lemmatize english words such that all of them get converted to the same tense. For example, c("ran","run","running") should become c("run","run","run").
I have already explored R packages ...

I have a list: a = c("aaaa", "bbbbbbb") b = c("a1", "b2", "c33") c = "d" d = list(a, b, c)
How can I get the longest items from each element of the list without a loop?
In other words the goal ...

I have two daily time series ranging from 1st of Jan 2016 to 1st of Aug 2016, however one my my series only includes data from business days (i.e weekends and bank holidays omitted), the other has ...

I was wondering how I can draw parallel concentric ellipses (oval shape lines) just like the grey, oval dashed lines in the picture below in my R plot?
Here is my small R code:
plot(1, ty='n', ann = ...

I'm asking this question solely so that I can publicly document for others an answer that I found by experimenting after I was unable to find a similar question. (It's a simple answer, though not ...

I would simply like to add the data values on top of every bar of the charts. How can I best do this?
library("RColorBrewer")
HOLD <- matrix(c(0.80, 0.70, 0.70, 0.65, 0.56, 0.56, 0.78, 0.54, 0.40,...

I have daily AUMs for 2 companies over 5 years. Each day I add a new row with yesterday's AUMs. Data looks something like this:
Date FirmA FirmB
01/01/2001 100 ...

I am using DocumentTermMatrix as follows:
dtm = DocumentTermMatrix(corpus, control = list( #weighting = weightTfIdf, ...

Translating... 0%