ASCII Build Functions for R

To access my server, I have to work with an old text terminal that does not have X windows. The best I'm going to do is emacs / ESS.

Often I want to make rudimentary plots, such as histograms and scatterplots, and I don’t have to worry about transferring the file to a computer with a graphic display.

Is there a graphics library based on a text terminal?

+8
text r data-visualization graphics
source share
1 answer

There are a few things that a bit can accomplish. There, the default stem is R, this scat ter plot function, but the best thing is there is a txtplot package on CRAN that has scatter plots, boxes, hatching, density traces, acfs curves and graphs (for example, the curve ... kinda function).

I only need this from time to time, but if I try to convey an approximate idea of ​​the graphics in clear text, as I sometimes need, this is a life saver.

In the past, I wrote a short piece of R code that very quickly drew ascii graphics in ascii style (for example, in side velvet or on the storyline with numbers replaced by characters, which solved problem I), but I did not save it, since the trunk is in mainly covers this territory.

Of course, the "table" tool produces ascii output and can be used to create interesting / useful semi-graphic objects.

There is also an ascii package, which can be used to visualize various R objects in ascii form, similar to Sweave - convenient for formatting tables, etc. Just formatting the table in ascii is actually not for that, but you can still get a little work out of it and the correct output format.

sample output from txtplot:

scatter plot:

  > with(cars,txtplot(speed,dist)) +----+-----------+------------+-----------+-----------+--+ 120 + * + | | 100 + + | * * | 80 + * * + | * * * | 60 + * * + | * * * * * | 40 + * * * * * + | * * * * * * * | 20 + * * * * * * * + | * * * * | | * * * | 0 +----+-----------+------------+-----------+-----------+--+ 5 10 15 20 25 

acf plot:

  > txtacf(ldeaths) +-+--------------+--------------+--------------+--------+ 1 + * + | * | | * * * * * | 0.5 + * * * * * + | * * * * * * * * | | * * * * * * * * | | * * * * * * * * | 0 + * * * * * * * * * * * * * * * * * * * * * + | * * * * * * * * * * | | * * * * * * * * * * | | * * * * * * * * * | -0.5 + * * * * * * + | * * * * | +-+--------------+--------------+--------------+--------+ 0 0.5 1 1.5 

density trace:

  > txtdensity(rnorm(100,m=5,s=.1)) +------+----------+----------+----------+----------+-------+ | ***** | 4 + ** *** + | * *** | | ** *** | 3 + ** *** + | *** ** | | ***** ** | 2 + *** ** + | *** ** | | ** ** | 1 + ** *** + | *** ****** | | ******** *** | +------+----------+----------+----------+----------+-------+ 4.8 4.9 5 5.1 5.2 

field:

  > vc <- ToothGrowth[,2]=="VC" > oj <- ToothGrowth[,2]=="OJ" > txtboxplot(ToothGrowth[vc,1],ToothGrowth[oj,1]) 5 10 15 20 25 30 35 |----+-------+--------+--------+--------+--------+-------+--| +--------+-----------+ 1 -------------| | |------------------ +--------+-----------+ +------------+----+ 2 -------------| | |--------- +------------+----+ Legend: 1=ToothGrowth[vc, 1], 2=ToothGrowth[oj, 1] 

curve graph:

  > txtcurve(sin(pi*x),from=0,to=2) +--+-----------+------------+------------+-----------+--+ 1 + ********* + | *** ** | | ** ** | 0.5 + ** ** + | ** ** | | * ** | 0 + * ** * + | * * | | ** ** | -0.5 + *** ** + | ** ** | | ** *** | -1 + ********* + +--+-----------+------------+------------+-----------+--+ 0 0.5 1 1.5 2 
Schedule

:

  > txtbarchart(as.factor(res),pch="|") +--+------------+------------+------------+------------+--+ 50 + | + | | | 40 + | + | | | 30 + | | + | | | | | | | | 20 + | | | + | | | | | 10 + | | | + | | | | | 0 + | | | + +--+------------+------------+------------+------------+--+ 1 1.5 2 2.5 3 Legend: 1=A, 2=B, 3=C 

Add the default R graphics to the stem function:

 > stem(log(islands,10)) The decimal point is at the | 1 | 1111112222233444 1 | 5555556666667899999 2 | 3344 2 | 59 3 | 3 | 5678 4 | 012 

and you have quite a few opportunities for coverage.

+16
source share

All Articles