Hello, I am simply trying to remove the [,1] row from a matrix. I tried to search Google to see if I could find how that is removed, but could not find a way to do it. So I have the following: [,1] date 2019-7-01 Peeps 5 days 7 worn 9 this is what I want: date 2019-7-01 Peeps 5 days 7 worn 9 Any ideas? Nic
ruipb@rr@d@s m@iii@g oii s@po@pt
2019-Jul-02 21:09 UTC
[R] Matrix - remove [,1] from top row
Hello, That is not a row, what you seem to have is an object of class "matrix" and when it's printed it prints the column names or [,1] [,2] etc if there aren't any colnames. So your matrix has just one column and 4 rows with rownames 'date', 'Peeps', 'days', 'worn'. Hope this helps, Rui Barradas Citando Nicola Cecchino <ncecchino at gmail.com>:> Hello, > > I am simply trying to remove the [,1] row from a matrix. I tried to > search Google to see if I could find how that is removed, but could > not find a way to do it. > > So I have the following: > > [,1] > date 2019-7-01 > Peeps 5 > days 7 > worn 9 > > this is what I want: > > date 2019-7-01 > Peeps 5 > days 7 > worn 9 > > Any ideas? > > Nic > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
give your a matrix an empty column name.> tmp <- matrix(1:4, 4, 1, dimnames=list(letters[1:4], NULL)) > tmp[,1] a 1 b 2 c 3 d 4> dimnames(tmp)[[1]][1] "a" "b" "c" "d"> dimnames(tmp)[[2]]NULL> dimnames(tmp)[[2]] <- "" > tmpa 1 b 2 c 3 d 4 On Tue, Jul 2, 2019 at 5:09 PM <ruipbarradas at sapo.pt> wrote:> > Hello, > > That is not a row, what you seem to have is an object of class > "matrix" and when it's printed it prints the column names or [,1] > [,2] etc if there aren't any colnames. So your matrix has just one > column and 4 rows with rownames 'date', 'Peeps', 'days', 'worn'. > > > Hope this helps, > > Rui Barradas > > > > > Citando Nicola Cecchino <ncecchino at gmail.com>: > > > Hello, > > > > I am simply trying to remove the [,1] row from a matrix. I tried to > > search Google to see if I could find how that is removed, but could > > not find a way to do it. > > > > So I have the following: > > > > [,1] > > date 2019-7-01 > > Peeps 5 > > days 7 > > worn 9 > > > > this is what I want: > > > > date 2019-7-01 > > Peeps 5 > > days 7 > > worn 9 > > > > Any ideas? > > > > Nic > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
(1) m[,1] is the first column of matrix (or dataframe) m. (2) The first row of matrix or dataframe m is m[1,] (3) To remove the first row of matrix or dataframe m, do m <- m[-1,] On Wed, 3 Jul 2019 at 08:59, Nicola Cecchino <ncecchino at gmail.com> wrote:> Hello, > > I am simply trying to remove the [,1] row from a matrix. I tried to > search Google to see if I could find how that is removed, but could > not find a way to do it. > > So I have the following: > > [,1] > date 2019-7-01 > Peeps 5 > days 7 > worn 9 > > this is what I want: > > date 2019-7-01 > Peeps 5 > days 7 > worn 9 > > Any ideas? > > Nic > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]