When trying to run this (or any other) command
xtabs(ugdata$response, ugdata$Equity, data=ugdata)
I keep receiving this error
Error in formula.default(object, env = baseenv()) : invalid formula
I have been looking around all day, including similar posts on this website, but I cannot find a solution to help me fix this.
Any help would be greatly appreciated
I believe the error is in the syntax. Please try:
xtabs(ugdata$response ~ ugdata$Equity, data = ugdata)
Related
I just try to use :
scRNA <- FindNeighbors(scRNA, dims = pc.num)
and
scRNA.counts <- Read10X(data.dir = "filtered_feature_bc_matrix")
and both of them gives error like :
Error in validityMethod(as(object, superClass)) : object 'Matrix_validate' not found
I guess these code totally run well in other's computer
so I wonder what's wrong with my code and how to fix it ?
Indeed, to solve the problem for you, it should be sufficient to do what #Mikael Jagan says:
update.packages("Matrix")
2nd thought: The above may not solve the problem entirely:
As there are other packages involved, some of these may have to be re-installed (after the updating of Matrix).
Can you post the output (or good summary of that if it's too long) of
traceback()
immediately after producing the error you are seeing?
I am trying to use some very simple data in rdplot but I keep getting the error: Error in seq.default(x_min, c, jump_l) : invalid '(to - from)/by' I found this response from a diffrent post on Stack Overflow but can seem to apply the fix to the rdplot function. does anyone know how can this be fixed?
The actual code I am using is:
library(rdrobust)
rdplot(y = dt$treated, x = dt$score)
Reproducibility:
Here is a sample of my data, as I've said it is fairly common data. So far I have found a couple of things:
There are multiple subsets of the observations that seem to cause problems
Changing the nbins or binselect arguments from their default will fix the problem
The first time you get an error is on the set 1:1463, however using only observations 2:1464 is OK.
The recent rdrobust version 1.0.1 should take care of this error.
I have the correct package alr4 which contains cars so it shouldn't be a problem with the function itself
box <- lm(Distance~Speed, data = stop)
boxCox(box)
This is the error
Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ‘"function"’ to a data.frame
The lm function runs just fine on its own, and I have used it in other analysis just fine, so it isn't an issue there. I am mostly just confused about the error and how to fix it. If you have suggestions or know why it happens that would be appreciated! Thanks
I'm getting a strange error when I run an lmer function in r.
I've tried changing the variable types (all of them are numeric or factor) and removing the NA before analysis, but nothing seems to work.
model_1 <- lmer(Q14 ~ gender * time + (1|OMID), data=data)
summary(model_1)
Specifically, my error message reads:
Error in as(value, fieldClass, strict = FALSE) :
internal problem in as(): “labelled” is(object, "numeric") is TRUE, but the metadata asserts that the 'is' relation is FALSE
Not sure why this is happening, but I can't seem to find any answers for it. Any help would be appreciated.
Thanks!
I think lmer has a problem with 'labelled' data. If you un-label the predictors it should work fine.
I had the same error: the code for the lme-formula worked perfectly fine and one day I encountered that error. The solution in my case was simply to restart the R session, reload the data - in my case from SPSS via library("haven")::read.sps and after that load library("lme4") and execute the lme-formula.
So, if the formula worked before without any error, maybe just clean the project environment and re-run the most crucial code without any additional packages loaded. Maybe it's just some "cross-contamination" between packages or an unwanted effect of any package on the dataframe.
Hope you can give me a quick help:
I have a function that works perfect as run in the global envir. When I eval the function from my own package it gives me an error. I can't figure out what the problem is. Seem so random to me.
catTableFun(aaa,grouped_by = "varNameAsString",preview=T) #from global envir works as expected
elricoFuns::catTableFun(aaa,grouped_by = "varNameAsString",preview=T) # identical function run from package gives the following error
Error:
#Error in get(grouped_by) : object 'varNameAsString' not found
Its such a construct causing the error. But why?
setDT(x)
gnLevels <- x[,get(grouped_by),drop=F]
I'm sorry I cant give you some rep example and this is a broad question, but I hope someone has encountered a similar phenomenon or has an educated guess about it.