How can I read a matrix with missing end elements in R? -


i pass r txt file matrix, tailing zeros omitted rows (except first tailing zero, if any). missing values considered zeros.

for example:

8 7 0 5 4 3 2 1 4 8 9 

should read as:

8 7 0 0 0 5 4 3 2 1 4 8 9 0 0 

the max row size (i.e. number of matrix columns) unknown prior reading matrix.

d <- as.matrix(read.table(filename, fill=t)) d[is.na(d)] <- 0 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -