Re: [R] sapply/lapply instead of loop

2010-08-10 Thread GL
That works great, and is ever so much simpler. Thanks much! -- View this message in context: http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320317.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-projec

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread Henrique Dallazuanna
So try: format(as.matrix(temp)) On Tue, Aug 10, 2010 at 4:13 PM, GL wrote: > > Both of those approaches seem to return (" v75") instead of ("v75 "). > -- > View this message in context: > http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320305.html > Sent from the R help

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread GL
Both of those approaches seem to return (" v75") instead of ("v75 "). -- View this message in context: http://r.789695.n4.nabble.com/sapply-lapply-instead-of-loop-tp2320265p2320305.html Sent from the R help mailing list archive at Nabble.com. __ R-

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread Henrique Dallazuanna
Try this: formatC(as.matrix(temp)) On Tue, Aug 10, 2010 at 3:55 PM, GL wrote: > > Using the input below, can I do something more elegant (and more efficient) > than the loop also listed below to pad strings to a width of 5? The true > matrix is about 300K rows and 31 columns. > > #

Re: [R] sapply/lapply instead of loop

2010-08-10 Thread jim holtman
will this do what you want: > newTemp[] <- lapply(newTemp, function(.col){ + # convert to character and pad to 5 space + sprintf("%5s", as.character(.col)) + }) > > str(newTemp) 'data.frame': 5 obs. of 3 variables: $ DX1: chr "13761" "63371" "51745" "64081" ... $ DX2: chr " 8125" "

[R] sapply/lapply instead of loop

2010-08-10 Thread GL
Using the input below, can I do something more elegant (and more efficient) than the loop also listed below to pad strings to a width of 5? The true matrix is about 300K rows and 31 columns. ### #INPUT ### > temp DX1 DX2 DX3 1 13761 8125 49178 2 6