Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does format(..., justify = "left") on a dataframe also left-justify the column names?

I'm relatively new to R, so hopefully this is an easy fix.

Here's my problem:

x <- data.frame(c("Thing1", "Thing2", "Thing3", "Thing4", "Thing5"), c("Sizeable line of text", "more text", "I hope this aligns", "something", "help me"))
colnames(x) <- c("T", "Text")
format(x, justify = "left")

       T                  Text
1 Thing1 Sizeable line of text
2 Thing2 more text            
3 Thing3 I hope this aligns   
4 Thing4 not much             
5 Thing5 help me 

How can I get the column names to align left with the rest of the dataframe?

Thanks in advance.

like image 890
neuropsych Avatar asked Mar 08 '15 06:03

neuropsych


People also ask

How do you left align a column in Python?

In order to align columns to left in pandas dataframe, we use the dataframe. style. set_properties() function.

How to align DataFrames in pandas?

Align two objects on their axes with the specified join method. Join method is specified for each axis Index. Align on index (0), columns (1), or both (None). Broadcast across a level, matching Index values on the passed MultiIndex level.


1 Answers

# print object explicitly
print(x,right=F)
like image 60
Petr Matousu Avatar answered Oct 23 '22 12:10

Petr Matousu