output-formatting

Is it possible to truncate output when viewing the contents of dataframes?

社会主义新天地 提交于 2019-12-07 07:57:14
问题 I have a data frame with some very long "comments" columns. When I have them displayed they are broken into different blocks, making it hard to read across rows. Is it possible to change a setting in R or modify the call to data.frame to truncate strings at a certain length? Example: a 3-column dataframe data.frame(cbind(rep(1,5),rep(c("very very long obnoxious character string here" ,"dog","cat","dog",5)),rep(c("very very long obnoxious character string here" ,"dog","cat","dog",5))))

Output results in conll format (POS-tagging, stanford pos tagger)

拟墨画扇 提交于 2019-12-06 07:20:24
问题 I am trying to use Stanford POS-tagger, I want to ask if it is possible to parse (actually only pos tag would be enough) an english text and output the results in conll format. Is there such an option? I am using the full 3.2.0 version of the Stanford pos tagger Thanks a lot 回答1: When it comes to the CONLL format, i presume you mean the CONLL2000 chunking task format as such: He PRP B-NP reckons VBZ B-VP the DT B-NP current JJ I-NP account NN I-NP deficit NN I-NP will MD B-VP narrow VB I-VP

Is it possible to truncate output when viewing the contents of dataframes?

时光总嘲笑我的痴心妄想 提交于 2019-12-05 10:14:36
I have a data frame with some very long "comments" columns. When I have them displayed they are broken into different blocks, making it hard to read across rows. Is it possible to change a setting in R or modify the call to data.frame to truncate strings at a certain length? Example: a 3-column dataframe data.frame(cbind(rep(1,5),rep(c("very very long obnoxious character string here" ,"dog","cat","dog",5)),rep(c("very very long obnoxious character string here" ,"dog","cat","dog",5)))) Resulting dataframe as seen on my screen: X1 X2 1 1 very very long obnoxious character string here 2 1 dog 3 1

Round positive value half-up to 2 decimal places in C

自作多情 提交于 2019-12-05 07:40:49
Typically, Rounding to 2 decimal places is very easy with printf("%.2lf",<variable>); However, the rounding system will usually rounds to the nearest even . For example, 2.554 -> 2.55 2.555 -> 2.56 2.565 -> 2.56 2.566 -> 2.57 And what I want to achieve is that 2.555 -> 2.56 2.565 -> 2.57 In fact, rounding half-up is doable in C, but for Integer only; int a = (int)(b+0.5) So, I'm asking for how to do the same thing as above with 2 decimal places on positive values instead of Integer to achieve what I said earlier for printing . It is not clear whether you actually want to " round half-up ", or

Update command line output

北城以北 提交于 2019-12-03 06:16:14
My program (which happens to be in Perl, though I don't think this question is Perl-specific) outputs status messages at one point in the program of the form Progress: x/yy where x and yy are a number, like: Progress: 4/38 . I'd like to "overwrite" the previous output when a new status message is printed so I don't fill the screen with status messages. So far, I've tried this: my $progressString = "Progress\t$counter / " . $total . "\n"; print $progressString; #do lots of processing, update $counter my $i = 0; while ($i < length($progressString)) { print "\b"; ++$i; } The backspace character

How do I enable msysgit colored output when using console2

放肆的年华 提交于 2019-12-03 04:07:46
问题 I'm having a hard time enabling git colored output on windows when using console2. To trick git I've already SET TERM = 'cygwin'. This enabled the colors from a standard cmd.exe prompt but not in console2. I've verified that console2 can see the env var as well. Anyone know how to get this working? 回答1: Ok, wow. The solution is to disable custom font color in console2. If enabled, it overrides the expected colors. I use a custom color to give me opaque text when using c2's alpha transparency.

Possible to print more than 100 rows of a data.table?

跟風遠走 提交于 2019-12-02 17:51:40
The data.table has a nice feature that suppresses output to the head and tail of the table. Is it possible to view / print more than 100 rows at once? library(data.table) ## Convert the ubiquitous "iris" data to a data.table dtIris = as.data.table(iris) ## Printing 100 rows is possible dtIris[1:100, ] ## Printing 101 rows is truncated dtIris[1:101, ] I often have data.table results that are somewhat large (e.g. 200 rows) that I just want to view. The print method of data.table has an argument nrows : args(data.table:::print.data.table) function (x, nrows = 100L, digits = NULL, ...) You can use

How do I enable msysgit colored output when using console2

怎甘沉沦 提交于 2019-12-02 17:27:16
I'm having a hard time enabling git colored output on windows when using console2. To trick git I've already SET TERM = 'cygwin'. This enabled the colors from a standard cmd.exe prompt but not in console2. I've verified that console2 can see the env var as well. Anyone know how to get this working? Ok, wow. The solution is to disable custom font color in console2. If enabled, it overrides the expected colors. I use a custom color to give me opaque text when using c2's alpha transparency. I completely forgot about it. VonC That is strange because, with a default installation of console2 (2.00

Is there any setfill() alternative for C?

混江龙づ霸主 提交于 2019-12-01 19:36:45
In C++: int main() { cout << setfill('#') << setw(10) << 5 << endl; return 0; } Outputs: #########5 Is there any setfill() alternative for C? Or how to do this in C without manually creating the string? No, there is no direct alternative. But if you have a well-behaved snprintf (one that behaves as described by the C99 Standard), this works without creating a new string; creating only 2 temporary int s #include <stdio.h> int main(void) { int filler = '#'; /* setfill('#') */ int width = 10; /* setw(10) */ int target = 5; /* 5 */ /* ******** */ int s = snprintf(NULL, 0, "%d", target); for (int i

Long NumPy array can't be printed completely?

↘锁芯ラ 提交于 2019-12-01 06:52:10
问题 I'm trying to print the complete contents of two 1001x1 arrays, but Python only gives me truncated output something like this: array([[5,45], [1,23], ......, [1,24], [2,31]]) instead of the complete array. Can anyone give me solution of how to get the complete 1001x1 array? 回答1: I'm going to guess that you tried a simple statement like: print myarray ... rather than something more explicit like: for each_item in myarray: print each_item ... or even: print ', '.join([str(x) for x in myarray])