Hamna Ehsan
Hamna Ehsan

Reputation: 1

Extraction of specific result in R outputs

I want to extract the values of "b1p" and "b2p" from the mardia's command and want to save it in bskew. For this i have used the "psych" package R version is 4.0.3. I have tried several commands for extraction but failed.

bskew <- mardia$b1p
bskew <- mardia[b1p
bskew <- mardia[[b1p

for this i got the error "object of type 'closure' is not subsettable" By using names() i got only names and by using class() i got "psych", "mardia". By using summary() i got the message "Warning message: In summary.psych(mardia(x)) : I am sorry, I do not have a summary function for this object" and then i used mna$coefficients[[]] command and i got the message "NULL". I saved my mardia command in mna. Minimum Working Example is:

n0 <- 5
 p0 <- 2
 m0 <- matrix(rep(0,p0),ncol=p0)
 s0 <- diag(1,p0) 
 x <- rmvnorm(5,mean=m0, sigma=s0)
 mardia$"b1p"
 bskew <- mardia["b1p"]
 bskew <- mardia[["b1p"]]
 bkurt <- mardia[["b2p"]]
 bskew <- mardia$b1p$
 mna<-mardia(x)
 class(mna)
 names(mna)
 summary(mardia(x))
 summary(mna)
 sk1 <- mna$coefficients[[3]]
  mna$coefficients

Upvotes: 0

Views: 95

Answers (1)

Abdessabour Mtk
Abdessabour Mtk

Reputation: 3888

the error is because you're trying to subset a function mardia which always throws the error you have, also you should subset the mna object instead of subsetting the actual function.

> mna$b1p
[1] 1.95888
> mna["b1p"]
$b1p
[1] 1.95888

> mna[["b1p"]]
[1] 1.95888
> mardia(x)$b1p
[1] 1.95888
> mardia$b1p
Error in mardia$b1p : object of type 'closure' is not subsettable
> mardia<-mardia(x)
> mardia$b1p
[1] 1.95888

Upvotes: 1

Related Questions