Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I extract numbers without attributes?

Tags:

r

I have the following object which I want to extract the numbers without attributes to a data frame as a column. I tried this, but didn't work:

data.frame(do.call(rbind, alpha.bar))

Named num [1:66] 0.122 0.125 0.131 0.137 0.138 ...
 - attr(*, "names")= chr [1:66] "alpha[1]" "alpha[2]" "alpha[3]" "alpha[4]" ...
like image 966
user45367 Avatar asked Feb 24 '26 13:02

user45367


1 Answers

From ?c:

c is sometimes used for its side effect of removing attributes except names, for example to turn an array into a vector. as.vector is a more intuitive way to do this, but also drops names. Note too that methods other than the default are not required to do this (and they will almost certainly preserve a class attribute).

It looks like you want to use,

data.frame(as.vector(alpha.bar))
like image 54
James Avatar answered Feb 26 '26 02:02

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!