How to aggregate over multiple variables
I have some data which has the columns company, amount of donation and party.I want to have a new list where for each company the sum of donated money, for each party, is listed.So far I know how to...
View Articleleaflet needs projection for displaying raster
I am trying to create a shiny app that displays raster over a world map. The user will interact with the inputs and the app will generate a raster as well as histogram. The code below generates the...
View ArticleclogitL1 or cv.clogitL1 -- force variables into model?
Is there a way to force clogitL1 or cv.clogitL1 to keep certain covariates in all the models? I'm thinking of something analogous to the penalty.factor argument in glmnet.(Or, if there isn't a way to...
View ArticlesqlSave() - slow writing to MS Access Table
I have a bit of R code that looks something like this:Mycon <- odbcConnectAccess2007("Output DB.accdb") sqlSave(Mycon, df_Output_Table, rownames = FALSE) It's very slow (compared to the processing...
View Articletest for named character(0) vector in R
I have a function which returns the following vector in Rvec #named character(0) Since it is a named vector, I am not able to test the following on itis.na()is.na(vec) # named logical(0) is.null...
View ArticlePlot a legend through ggplot using three different dependent-predictor series
I had previously posted where I was unable to plot a legend using one dependent variable and three different predictor variables using ggplot's geom_smooth function. I was fortunate enough to gain...
View Articlesolve simple quadratic optimization in R with sum constraint
I want to solve a very simple quadratic optimization problem in R where one of the constraints is an equality constraint related to the sum of a vector. I tried to use the quadprog package but I cannot...
View Articlescaling multiple columns in lists using map, map2, mutate_at, summarise_at
I am having problems with the scaled_assessment data I am trying to create.I have some time series data I split up into analysis and assessment. I want to scale the analysis data and use these scaled...
View ArticleHow to combine the columns of two data.tables?
I have two tables of the type data.table. I want to combine the tables into one table. They look like:DT1:1 A B C 2 A B C 3 A B C DT2:D E F D E F D E F I want to combine them like:1 A B C D E F 2 A B C...
View ArticleInconsistent behavior during cell selection in DT datatable
I have the shiny app below in which the user clicks on a cell in the upper table and the relative cell should be displayed in the lower table. The issue is that when I unselect the cells in the upper...
View ArticleRolling mean partinioned by different collumns in R
I'm working in R and I need to do a rolling mean of the last 3 values of a data set, partinioned by 3 different collumns. Each time one of the values of the collumn changes, the rolling mean should...
View ArticleUsing the map function along with the image function for geospatial data in R
I am trying to plot geospatial sea surface temperature correlation data on the world map (only Northern hemisphere). I am using the image function (plot correlation data) along with the map function...
View ArticleHow to combine line and bar chart for specific variable using R
I have a quite straightforward question. I would line to have a bar chart for var1, var2, var3 and var4 and a line chart for var5. Line and bars should be in the same chart. How can I get it keeping...
View ArticleColor key not shown with heatmap.2
I am not able to display the color key while using heatmap.2. I've read it should appear automatically, is it true? Otherwise I've tried several times but only the heatmap appears.Here is my...
View ArticleNaming a vector assigning some values
I want to assign a vector named 5_randoms with 10 random number from 10-50. If i use x/y/z inspite of 5_randoms it is working. even if i use num_random, the vector is working. if I use 5_randoms, all...
View ArticleHow to compare k-means result with true labels
Hey I would like to compare the results of my k-means with the true labels which are in column one (is_non_maligant) which can have the value 0 and 1Sorry for the basic question but I am only a...
View ArticleConditional Subset, Manipulate and Replace
Following on from a previous question here I extracted the following data.frameDF <- data.frame(A =c("One","Two","Three","Four","Five"), B=c(1,1,2,2,3), D=c(10,2,3,-5,5)) subset(DF, B %in% c(1,3)) A...
View Articleremoving columns in csv format in R language
I have the following table in csv format:I have the following gene information in a csv format table: 1 3 1 2 2 3 1415670_at 1 365.1 293.4 288.9 394.5 312 381.6 1415671_at 2 556.1 584.2 567.8 592.8...
View ArticleHow do I find the top 3 highly correlated variables with another specific...
I have a dataframe containing the number of points scored by various individuals in various events. A total column is then added to this dataframe. Now, how do I calculate the top 3 highly correlated...
View ArticleMy ggplot of predictions vs actual doesn't plot the correct output
I have some issues plotting several curves. I have made some predictive models using caret which predicts probablilities, like logistic and XGBoost and evaluated using ROC, but when I try to plot these...
View Article