Getting names while applying sapply or l …


Getting names while applying sapply or lapply in R.
sapply or lapply extract the element without the row name.
So this code does not work.

par(mfrow = c(4,4))
sapply(names(score.avg)
       , function(x) {
           plot(x
                , type = 'l'
              );
           title(main=names(x))      
           })

In order to use the row names while applying sapply or apply,
pass the names of the list to a function and call the values using the names.

par(mfrow = c(4,4))
sapply( rencontre gay à choisy le roi names(score.avg)
       , function(x) {
           xlength <- length(score.avg[[x]]);         
           plot(-499:(xlength-499-1),  http://screenpolska.pl/?fipociya=portal-randkowy-romeo&e24=a3 score.avg[[x]]
                , type = 'l'
                , xlab='Distance from TSS', ylab='score'
             #   , xlim=c(-100,100)
              );
           title(main=x, cex.main=0.85);
           })

Leave a Reply

Your email address will not be published. Required fields are marked *