How to get total count of repeated values and make an adjacency table
I have similar datadf <- data.frame(city1=sample(c("Tokyo","New York","Los Angeles", "Mumbai", "Los Angeles", "Tokyo", "Shanghai", "Kolkata", "Los Angeles", "Tokyo")),...
View ArticleMove the position of colorbar/ colorkeys in levelplot
I have plotted a stack of raster using the function 'levelplot' script as below:library(raster) library(rasterVis) ras <- list.files("/filepath/", pattern = "\\.tif$", full=TRUE) s <- stack(ras)...
View ArticleLMM model with nested design and random slopes (nlme package) cannot run with...
Despite many efforts, I cannot run a linear mixed model because of the autocorrelation term. In fact, I can't manage to code for both a nested design and random slopes within it.For example, let's...
View ArticleWhy doesn't "dnorm" sum up to one as a probability?
This may be some basic/fundamental question on 'dnorm' function in R. Let's say I create some z scores through z transformation and try to get the sum out of 'dnorm'....
View ArticleError with confusion matrix: Error: `data` and `reference` should be factors...
Edited Question:I have a data set of 699 rows and in the exercise I'm working on it is requested to generate a training set of 300 observations. The rest will be the test set. I write all the possible...
View ArticleR auto compute features log and poly data matrix
BackgroundI'm writing my own function. The function takes a dataframe input with unfixed number of features. Also, the features' type maybe different,i.e. numeric,factor and chr. I want to maximise my...
View ArticleHow do I know if my data fit a Poisson Distribution using R?
I have a dataset of around 30 values and I would like to know if these data fit a Poisson distribution. I would like to perform a test, like GLM for my data and I found out that they don't follow a...
View ArticleReshape 2d matrix(data.frame) by combining row and column names
QuestionI got a funny task to do during coding my thesis. I have a 2D-matrix(or data.frame) like this: CACE cheng cheng2 ding ding_ass sun2 mean 0 -0.000467158 0.01219119 0.004284223 0.003803375...
View ArticleGetting estimated means after multiple imputation using the mitml, nlme &...
I'm running multilevel multiple imputation through the package mitml (using the panimpute() function) and am fitting linear mixed models and marginal models through the packages nlme and geepack and...
View ArticleMultiple values in square bracket csv in R
I have a csv file like this:1556891503.326399;16384;340;48188.23529411765;[1618.377685546875, 1620.2911376953125, 1620.1904296874998, 1619.9386596679685, 1620.391845703125, 1620.2911376953125,...
View ArticleHow to transform a unique identifier's position over a time from multiple row...
I need help with a unique query, I couldn't find any solutions as yet. But that could be because I didn't know how to word what I am looking. Below is a sample datasetname, position, start_date,...
View ArticleRandomly sampling rows from particular months in a data set
I was given this task in R:"Randomly select 10 trading days from each of the following months: January 2019 to June 2019 (6 months total)".I have a CSV file of a company's stock trading history from...
View ArticleWhy there is so much difference in accuracy from fit model evaluation and...
This is how i try to interpret result from model which is only printing Model_RF_RF using random forest and below is using confusion matrix but why accuracy is so different....
View ArticleScript for creating a new project in Rstudio
I want to write a template that creates new projects in RStudio. What I want to do is:Create a new Rstudio project in a folder called "MyNewProject"Create a new project using ProjectTemplate package in...
View ArticleHow to use pivot_wider to tidy data set with duplicates and multiple classes...
I am trying to tidy a data set by using pivot_wider but I run into some problems which I don't know how to tackle. In my values column "OrigValueStr", the one I assign to "values_from", I have both...
View ArticleHow do I get the non-selected rownumbers?
I created a training and testing subset from my original data:df <- data.frame(var = seq(1, 200, by = 2)) train.rows <- sample(1:100, 75, replace = FALSE) df.train <- df[train.rows,] df.test...
View Articleas.factor with levels 0, 1 instead of 1, 2
My variable (poor) is a factor with 2 levels: Poor and Non-Poor. I need it to be 1 if it's Poor and 0 if it's Non-Poor, so i converted it to numeric (with as.numeric, and then changed it to factor...
View ArticleRename Columns of one DataFrame to Another (R or Python)
I want to rename the columns from one dataframe into the columns of another, meanwhile creating a completely new dataframe. I am not really sure how to approach this and which is why the consultation....
View ArticleCalculating sum of certain rows within one data.frame
I have a data.frame called "test" like this: Age START_DATE END_DATE ACCT_NO PRINCIPAL_AMOUNT_BASE 1 60 01/05/2014 30/06/2014 ACC1 400 2 121 01/03/2014 30/06/2014 ACC2 200 3 121 01/03/2014 30/06/2014...
View ArticleHighcharts Dependency wheel in R
I'd like to create a dependency wheel diagram using the highcharter library in R. Usually I'm just able to look at the javascript code for the plot and translate it for R, but for dependency wheel...
View Article