unlist2            package:AnnotationDbi            R Documentation

_A _r_e_p_l_a_c_e_m_e_n_t _f_o_r _u_n_l_i_s_t() _t_h_a_t _d_o_e_s _n_o_t _m_a_n_g_l_e _t_h_e _n_a_m_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     'unlist2' is a replacement for 'base::unlist()' that does not
     mangle the names.

_U_s_a_g_e:

       unlist2(x, recursive=TRUE, use.names=TRUE, what.names="inherited")

_A_r_g_u_m_e_n_t_s:

x, recursive, use.names: See '?unlist'.

what.names: '"inherited"' or '"full"'.

_D_e_t_a_i_l_s:

     Use this function if you don't like the mangled names returned by
     the standard 'unlist' function from the base package. Using
     'unlist' with annotation data is dangerous and it is highly
     recommended to use 'unlist2' instead.

_A_u_t_h_o_r(_s):

     Herve Pages

_S_e_e _A_l_s_o:

     'unlist'

_E_x_a_m_p_l_e_s:

       x <- list(A=c(b=-4, 2, b=7), B=3:-1, c(a=1, a=-2), C=list(c(2:-1, d=55), e=99))
       unlist(x)
       unlist2(x)

       library(hgu95av2.db)
       egids <- c("10", "100", "1000")
       egids2pbids <- mget(egids, revmap(hgu95av2ENTREZID))
       egids2pbids

       unlist(egids2pbids)   # 1001, 1002, 10001 and 10002 are not real
                             # Entrez ids but are the result of unlist()
                             # mangling the names!

       unlist2(egids2pbids)  # much cleaner! yes the names are not unique
                             # but at least they are correct...

