Error in xj[i] : invalid subscript type ‘list’

The issue is in subset=train. According to the ?glm. the subset should be a vector as oppose to a subset of original dataset: subset an optional vector specifying a subset of observations to be used in the fitting process. Hence, you may need to change the code to: glm.fit=glm(Status~Length+Right+Bottom+Top+Diagonal,data=train,family=binomial) or glm.fit=glm(Status~Length+Right+Bottom+Top+Diagonal,data=bank,family=binomial,subset=1:100)

Categories R Tags

Geometric Mean: is there a built-in?

Here is a vectorized, zero- and NA-tolerant function for calculating geometric mean in R. The verbose mean calculation involving length(x) is necessary for the cases where x contains non-positive values. Thanks to @ben-bolker for noting the na.rm pass-through and @Gregor for making sure it works correctly. I think some of the comments are related to … Read more

Categories R

Changing fonts in ggplot2

You just missed an initialization step I think. You can see what fonts you have available with the command windowsFonts(). For example mine looks like this when I started looking at this: After intalling the package extraFont and running font_import like this (it took like 5 minutes): I had many more available – arguable too … Read more

Categories R

R apply function with multiple parameters

Just pass var2 as an extra argument to one of the apply functions. This passes the same var2 to every call of myfxn. If instead you want each call of myfxn to get the 1st/2nd/3rd/etc. element of both mylist and var2, then you’re in mapply‘s domain.

Categories R

Error:attempt to apply non-function

You’re missing *s in the last two terms of your expression, so R is interpreting (e.g.) 0.207 (log(DIAM93))^2 as an attempt to call a function named 0.207 … For example: Error: attempt to apply non-function Your (unreproducible) expression should read: Mathematica is the only computer system I know of that allows juxtaposition to be used for multiplication …

Creating a Plot Window of a Particular Size

Use dev.new(). (See this related question.) To be more specific which units are used: edit additional argument for Rstudio (May 2020), (thanks user Soren Havelund Welling) For Rstudio, add dev.new(width=5,height=4,noRStudioGD = TRUE)

Categories R

Argument “No” is missing, with no default

I need to assign values in the variable “TRTCD1” in two different classes as 1 and 2, based on the condition as stated in the R programming code below. On running these code, I am getting the error: Argument “No” is missing, with no default Here, Treatment1.class is a new variable in table z which … Read more

Categories R