Is there an R function for finding the index of outliers in a vector?
I am trying to write a program with the function findOutliers to return a vector with either the outliers or the index of the outliers. The function should accept an optional named, boolean argument...
View ArticleHow to customize plotly title in R?
Code for pie chart in plotly is like this:USPersonalExpenditure <- data.frame("Categorie"=rownames(USPersonalExpenditure), USPersonalExpenditure) data <- USPersonalExpenditure[,c('Categorie',...
View ArticleFunction to create dataframe based on user input in R
Forgive me if this question is basic, but I can't seem to find a similar example. I am relatively new to R and creating function. I have my code working without a function, but would like to convert it...
View ArticleHow can I summarize reactive data from outside a render function in a Shiny app?
For this particular shiny example I am trying to apply a circular model and display and summarize it within the ggplot and a summary table. This is straightforward up until trying to add in reactive...
View ArticleWorkaround to Quantmod getDividends which apparently stopped working Jan 16,...
My R program started failing Jan 16 quantmod::getDividends('BBY') gives: Error in vapply(parse(text = fr[, 2]), eval, numeric(1)) : values must be length 1, but FUN(X[[1]]) result is length 2
View ArticleHow do I use R to count multiple variables?
I have a large dataset of Bird observations. I would like to count by groups i.e. the species observed by various categories: year, season, and grid.For example how many American Crows (AMCR) were...
View ArticleRstudio Keras network structure causing trouble
I am new to Keras and was trying to use bidirectional-lstm to classify each string in a text. Could someone please help out in getting the network structure right. On a higher level, I am trying to use...
View ArticleBest method to download HTTPs files in R for an R Package
I'm writing an R package where I have to download a fairly large file (7gb, 4gb compressed) from AWS to be able to run it properly. I've seen some posts on here for people using RCurl and downloader,...
View ArticleIs there a way to optimize this code, as this is taking hours to execute...
for (i in 1:99653) { for(j in 1:3226) { if (grepl(cdata$LegDigitsDialed[i],sdata$SavedPhone[j]) == TRUE) { cdata$category[i] = "Supplier" cdata$su_name[i] = sdata$sushortname[j] } else {...
View ArticleR: Sliding one-ahead forecasts from equation estimated on a fixed period
The toy model below stands in for one with a bunch more variables, transforms, lags, etc. Assume I got that stuff right. My data is ordered in time, but is now formatted as an R time series, because I...
View Article'R', 'mice', missing variable imputation - how to only do one column in...
I have a matrix that is half-sparse. Half of all cells are blank (na) so when I try to run the 'mice' it tries to work on all of them. I'm only interested in a subset.Question: In the following code,...
View ArticleIn R, ggplot for a population pyramid: how to align labels near to the axis...
I am making a sort of population pyramid using ggplot (plotrix doesn't allow me to do fancy labels etc), then I start with a geom_bar with labels and later I flip the coordinates. Sadly, labels almost...
View ArticleCalculate distance between vector of coordinates in 1 df and single...
Suppose I have the following two dataframes (with uneven rows)set.seed(1999) dfA <- data.frame(x = rpois(10,2), y = rpois(10,2), z = rpois(10,2), q = rpois(10,2), t = rpois(10,2)) set.seed(24) dfB...
View Articleknitting a figure to word using papaja fails
I am able to knit the following code to PDF. However, it always fails when trying to knit the output to Word (win 10, Rstudio 1.2.5033, R 3.6.2, papaja 0.1.0.9942). I had to delete the papaja header...
View ArticleDifferent estimates for fixed effect model in STATA and R
I have an unbalanced panel of T=28 years and N=91. I am estimating what I believe to be the same fixed effects(Country/Year FE) model with STATA and R, but my estimates are different. Can someone help...
View ArticleHow to visualise an interaction effect using ggplot with method =...
I am running an analysis in R on the effect of canopy cover (OverheadCover) and the number of carcasses placed on the same location (CarcassNumber) on the proportion of carrion eaten by birds...
View ArticleIs there an R package for modified 2-sample Hotelling's T2 test (unequal...
I need to compare many multivariate means. Usually, I would do this using Hotelling's T-square test statistics. The original Hotelling's equation is: T^2 = (nxny/nx+ny) (X-Y)' S^-1 (X-Y)where X and Y...
View ArticleR (64-bit on Windows): How to get around "cannot allocate vector of size...
This is a follow-up to my earlier question about how to locate a compare a particular attribute between two text files.Thanks to the accepted answer I got together below code which works (on my system)...
View ArticleRow-wise entry population based on previous row
I have a R data frame that looks like this:Category Date Column Cat1 2018-03-23 19 Cat1 2018-03-24 19 Cat1 2018-03-25 19 Cat1 2018-03-26 NULL Cat1 2018-03-27 NULL ... .... ... Cat2 2018-03-23 25 Cat2...
View ArticleHow do I create a function that renames column names based on specified...
I am in the midst of creating a data analysis package that scrapes data from a variety of sources. In lots of cases, the name of columns have inconsistent naming for the same type of data at each data...
View Article