I work on Windows, R version 2.4.1 I need to leave out many rows and columns when reading a matrix. The 'skip' commands in read.table, seem to be just for skipping rows, if I understand well, but I need to skip many columns as well. I tried something very simple and left one row and one column out, but I don't know how to do it for many rows and columns at a time. Example: zzz # euclidean distances matrix X1 X2 X3 X4 X5 X1 0 11 12 1 15 X2 11 0 5 12 3 X3 12 5 0 8 4 X4 1 12 8 0 16 X5 15 3 4 16 0 skip.data = zzz [-3, -3] # gives me the same matrix without row 3 and column 3... how can I tell R to skip more than one row and column? Columns and rows to be left out are not contiguous The matrix I'm using is fairly large (335x335), so excel won't read the whole thing, and it's not a fixed-width txt file, so I cannot use read.fwf. I also don't have access to Unix, as was suggested to other users to solve this problem. -- View this message in context: http://www.nabble.com/Skipping-rows-and-columns-in-large-matrix-tf3712332.html#a10384400 Sent from the R help mailing list archive at Nabble.com.
zzz <- zzz[-c(1,45,23,321), -c(23,34,45,67)] On 5/8/07, Silvia Lomascolo <slomascolo at zoo.ufl.edu> wrote:> > I work on Windows, R version 2.4.1 > I need to leave out many rows and columns when reading a matrix. The 'skip' > commands in read.table, seem to be just for skipping rows, if I understand > well, but I need to skip many columns as well. I tried something very simple > and left one row and one column out, but I don't know how to do it for many > rows and columns at a time. > > Example: > > zzz # euclidean distances matrix > > X1 X2 X3 X4 X5 > X1 0 11 12 1 15 > X2 11 0 5 12 3 > X3 12 5 0 8 4 > X4 1 12 8 0 16 > X5 15 3 4 16 0 > > skip.data = zzz [-3, -3] # gives me the same matrix without row 3 and > column 3... how can I tell R to skip more than one row and column? Columns > and rows to be left out are not contiguous The matrix I'm using is fairly > large (335x335), so excel won't read the whole thing, and it's not a > fixed-width txt file, so I cannot use read.fwf. I also don't have access to > Unix, as was suggested to other users to solve this problem. > > > -- > View this message in context: http://www.nabble.com/Skipping-rows-and-columns-in-large-matrix-tf3712332.html#a10384400 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
Columns that correspond to NULLs in the colClasses arg of read.table are ignored. ?read.table On 5/8/07, Silvia Lomascolo <slomascolo at zoo.ufl.edu> wrote:> > I work on Windows, R version 2.4.1 > I need to leave out many rows and columns when reading a matrix. The 'skip' > commands in read.table, seem to be just for skipping rows, if I understand > well, but I need to skip many columns as well. I tried something very simple > and left one row and one column out, but I don't know how to do it for many > rows and columns at a time. > > Example: > > zzz # euclidean distances matrix > > X1 X2 X3 X4 X5 > X1 0 11 12 1 15 > X2 11 0 5 12 3 > X3 12 5 0 8 4 > X4 1 12 8 0 16 > X5 15 3 4 16 0 > > skip.data = zzz [-3, -3] # gives me the same matrix without row 3 and > column 3... how can I tell R to skip more than one row and column? Columns > and rows to be left out are not contiguous The matrix I'm using is fairly > large (335x335), so excel won't read the whole thing, and it's not a > fixed-width txt file, so I cannot use read.fwf. I also don't have access to > Unix, as was suggested to other users to solve this problem. > > > -- > View this message in context: http://www.nabble.com/Skipping-rows-and-columns-in-large-matrix-tf3712332.html#a10384400 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >