jr134
jr134

Reputation: 83

How to convert array to data frame?

I am new to R, I have had a go at converting a array to a data frame, but the output is separated and does not show "Class: Negative" etc in the output.

How do I combine the results from the array into one data frame that takes into account the "Class: Negative"?

What is contained in the array:

[[1]]
                Sensitivity Specificity
Class: Negative   0.8498542   0.8207283
Class: Neutral    0.4482759   0.7075856
Class: Positive   0.4018519   0.9587209

[[2]]
                Sensitivity Specificity
Class: Negative   0.6173469   0.9495798
Class: Neutral    0.7959770   0.6659869
Class: Positive   0.6472222   0.9500000


dd <- data.frame(t(result2))
colnames(dd) <- c("Class", "Sensitivity", "Specificity")

sample of dd output:

  Class Sensitivity Specificity
1 NULL     NULL        NULL 

1 0.84985423, 0.44827586

1 0.61734694, 0.79597701

Upvotes: 0

Views: 583

Answers (1)

Alejandro Andrade
Alejandro Andrade

Reputation: 2216

Based on the example data you show you don't have an array but a list to convert it into a data.frame you can use the following code:

do.call(rbind.data.frame,result2)

if it doesn't work i would need an example data.

Upvotes: 3

Related Questions