Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I suppress (not print) line numbers?

Tags:

r

How can I suppress (not print) line numbers?
Code reads:

dd<-data.frame(a=gl(2,3),b=gl(3,1,6) ) 
model.matrix( ~a + b + a*b, dd )

Tries:

> dd<-data.frame(a=gl(2,3),b=gl(3,1,6) ) 
> model.matrix( ~a + b + a*b, dd )
  (Intercept) a2 b2 b3 a2:b2 a2:b3
1           1  0  0  0     0     0
2           1  0  1  0     0     0
3           1  0  0  1     0     0
4           1  1  0  0     0     0
5           1  1  1  0     1     0
6           1  1  0  1     0     1
attr(,"assign")
[1] 0 1 2 2 3 3
attr(,"contrasts")
attr(,"contrasts")$a
[1] "contr.treatment"
attr(,"contrasts")$b
[1] "contr.treatment"

> cat(model.matrix( ~a + b + a*b, dd ))
1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1
> model.matrix( ~ a + b + a*b, dd )
  (Intercept) a2 b2 b3 a2:b2 a2:b3
1           1  0  0  0     0     0
2           1  0  1  0     0     0
3           1  0  0  1     0     0
4           1  1  0  0     0     0
5           1  1  1  0     1     0
6           1  1  0  1     0     1
attr(,"assign")
[1] 0 1 2 2 3 3
attr(,"contrasts")
attr(,"contrasts")$a
[1] "contr.treatment"
attr(,"contrasts")$b
[1] "contr.treatment"

> dd<-data.frame(a=gl(2,3),b=gl(3,1,6) )
> print(model.matrix( ~a + b + a*b, dd , rowNames=False))
  (Intercept) a2 b2 b3 a2:b2 a2:b3
1           1  0  0  0     0     0
2           1  0  1  0     0     0
3           1  0  0  1     0     0
4           1  1  0  0     0     0
5           1  1  1  0     1     0
6           1  1  0  1     0     1
attr(,"assign")
[1] 0 1 2 2 3 3
attr(,"contrasts")
attr(,"contrasts")$a
[1] "contr.treatment"
attr(,"contrasts")$b
[1] "contr.treatment"

> print(model.matrix( ~a + b + a*b, dd , colNames=False))
  (Intercept) a2 b2 b3 a2:b2 a2:b3
1           1  0  0  0     0     0
2           1  0  1  0     0     0
3           1  0  0  1     0     0
4           1  1  0  0     0     0
5           1  1  1  0     1     0
6           1  1  0  1     0     1
attr(,"assign")
[1] 0 1 2 2 3 3
attr(,"contrasts")
attr(,"contrasts")$a
[1] "contr.treatment"
attr(,"contrasts")$b
[1] "contr.treatment"
like image 470
Mary A. Marion Avatar asked Jun 20 '15 15:06

Mary A. Marion


People also ask

How do you suppress line numbering in Word?

On the Layout tab, in the Page Setup group, click Line Numbers. Do one of the following: To remove line numbers from the entire document or section, click None. To remove line numbers from a single paragraph, click Suppress for Current Paragraph.

What does suppress line numbers mean in Word?

Remove Line Numbers in Word Then do one of the following: Select None to remove the line numbers from the entire document. Select Suppress for Current Paragraph to remove the numbering for a particular paragraph (where your cursor is located).

How do I turn off line numbers in Notepad ++?

Editing Preferences Page To show line numbers in Notepad++, put a checkmark in the checkbox labeled Display line number, as indicated by the blue arrow. If you wish to hide line numbers in Notepad++, remove the checkmark from this box instead. When ready, click on the Close button to save the changes.

How do I turn off line numbers in Visual Studio?

On the menu bar, choose Tools > Options. Expand the Text Editor node, and then select either the language you're using or All Languages to turn on line numbers in all supported programming languages. You can also type line number in the Search box, and then choose Turn line numbers on or off from the results.


1 Answers

It is unfortunate that there doesn't seem to be any way to suppress row names when printing matrices, isn't it? One option is to coerce to data.frame and use the row.names argument of print.data.frame():

dd <- data.frame(a=gl(2,3),b=gl(3,1,6));
print(as.data.frame(model.matrix( ~a + b + a*b, dd )),row.names=F);
##  (Intercept) a2 b2 b3 a2:b2 a2:b3
##            1  0  0  0     0     0
##            1  0  1  0     0     0
##            1  0  0  1     0     0
##            1  1  0  0     0     0
##            1  1  1  0     1     0
##            1  1  0  1     0     1
like image 119
bgoldst Avatar answered Sep 30 '22 05:09

bgoldst