installing data.table results in “there is no package”

I am new to R and have to install a data.table into my workfile. Right now, I have implemented: However, when I run this part (Ctrl + Enter) I get the following error in the console-window: Loading required package: data.table Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there … Read more

Categories R

incorrect number of subscripts on matrix in R

I think that when you read in your “D1.txt”, “D2.txt”…………….”D45.txt” files they get converted to matrices and that is why your particular for loop fails. I’ll use your example: If we use class(L[[1]]) to pick out the first element of the list it will output [1] “data.frame” if you use your for loop on this … Read more

Categories R

Error in file(filename, “r”, encoding = encoding) : cannot open the connection

In your case try to add setwd(“path/to/project/”) in main.R where path/to/project/ contains main.R. Then you can source functions.R either directly by source(“functions.R”) if both files lie in the same directory or source(“sub-folder/functions.R”) if the latter file is contained in a sub-folder. If you’re not working on a RStudio project, chances are the working directory of … Read more

Categories R

Error in match.fun(FUN)

There are several problems with the code. First, apply operators on a matrix or data.frame. You probably meant to use sapply instead. Second, nchar() calls nchar without any argument. You want nchar — i.e. the function name, without calling it (the calling will happen inside sapply):

Categories R

Aggregate multiple columns at once

We can use the formula method of aggregate. The variables on the ‘rhs’ of ~ are the grouping variables while the . represents all other variables in the ‘df1’ (from the example, we assume that we need the mean for all the columns except the grouping), specify the dataset and the function (mean). Or we … Read more

Categories R

lmer error: grouping factor must be < number of observations

You have two problems here: It looks like you have one observation for every value of code. That means that you can’t estimate both a residual variance (which is built in to lmer, and linear mixed models more generally) and an among-code variance — both of these parameters will be trying to estimate the same … Read more

Categories R

Too few periods for decompose()

the error looks like this i want to know whats the problem? I am basically writing a code forecasting using ARIMA and i want to knoe if there is any seasonality or trend in my data. Hoping for a quick resonse!!!!!

Categories R