for loop - Turning a Data.Frame with 28441 Rows in it to a Dataframe with 28 Rows and 1000 Columns in R -


i have data frame 28441 zip codes , column in data frame. want turn 28 rows 1000 zip codes each in , 1 441 zip codes:

i have tried following in r language:

zip.codes<-read.csv('e:/my docments/zip_codes.csv', header= true, fill=true            quote="\"", na.strings='ns', stringsasfactors=false)  (i in 1:length(zip.codes)) {  for(j in 1:1000) {         new.zip.codes[j,i]<-zip.codes[i,j]  } }  following error: error in new.zip.codes[j, i] <- zip,codes[i, j] :  incorrect number of subscripts on matrix 

each zip code unique , not repeated.

what missing? appreciated.

robert

i assuming want once. if have number of lists of zip codes of different lengths need modify somewhat.

zip<-seq(1:28441)        #fake zip codes example zip[28842:29000]<-na     #pads zip codes fit nicely in matrix zipmat<-matrix(data=zip,nrow=29, ncol=100) #now in 29 row 100 column matrix 

the on matrix() command has couple of options (dimnames, byrow) might find useful.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -