How can I suppress (not print) line numbers?

Mary A. Marion

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"
bgoldst

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

Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.

En caso de infracción, por favor [email protected] Eliminar

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

How can I print numbers between two numbers that I enter?

Gratient Module how can i print text in the same line

How can I add line numbers to a textarea using an ordered list?

How do I print numbers from 1 to n in python in a single line without spaces?

How can I suppress assembly files output by compilation proper?

How can I suppress Javac warning about preview features?

How can I print cPacket?

How can I print more than one line of words/phrases in a Multiline PySimpleGUI element?

How do I print the line number of each line in a string?

How can I print multidimensional arrays in C?

How can I print the outliers of a Boxplot in Python?

How can I print a vector in a recursive function?

How can I print subelements in Python?

How can I print objects to the console?

How can I parse this numbers to timestamp?

How can I truncate numbers in Pine Script?

How can I suppress "The tag <some-tag> is unrecognized in this browser" warning in React?

How can i suppress output from a command in bash without making its variable empty

How do I print STDOUT and get STDIN on the same line in Rust?

How do I put this code into one print function (or line)?

How do I put a print statement on the same line as a return statement?

How can I make the line turn?

How can I fit a nonlinear line in R?

How do I make my Print Statement print on only one line?

How do I make my Print Statement print on only one line?

How can i print json object with some other text

How i can print a number triangle in c++

How can I print the filename which is being processes by xmltask?

How can I keep input track log in shiny, then print it and save it?

TOP Lista

CalienteEtiquetas

Archivo