Re: [ESS] Print spark histograms from skimr package in Emacs ESS on Windows

2018-01-24 Thread Richard M. Heiberger
This looks like an example of UTF-8 not working on Windows.

Windows in Emacs ESS
> UTF8.beta <- "\u03b2"
> UTF8.beta
[1] "ß"## wrong character
> UTF8.sharps <- "\u00DF"
> UTF8.sharps
[1] "ß"


Macintosh
> UTF8.beta <- "\u03b2"
> UTF8.beta
[1] "β"
> UTF8.sharps <- "\u00DF"
> UTF8.sharps
[1] "ß"
>

On Wed, Jan 24, 2018 at 10:52 AM, Vinh Nguyen  wrote:
> On Wed, Jan 24, 2018 at 7:17 AM, Vitalie Spinu  wrote:
>>
>>
>>  (set-buffer-process-coding-system 'windows-1252 'windows-1252)
>>
>> Try 'utf-8 or variants displayed by M-x list-coding-systems. If this works, 
>> you
>> can either set in ess-R-post-run-hook or in process-coding-system-alist.
>>
>
> Hmm, I evaluated in the ESS R buffer
>  (set-buffer-process-coding-system 'utf-8 'utf-8)
>
> which returned t, but I still get: the following output:
>
>> library(skimr); skim(cars)
> Skim summary statistics
>  n obs: 50
>  n variables: 2
>
> Variable type: numeric
>   variable missing complete  n  meansd min p25 median p75 max
> 1 dist   0   50 50 42.98 25.77   2  26 36  56 120
> 2speed   0   50 50 15.4   5.29   4  12 15  19  25
>   hist
> 1 
> 2 
>
>
> If I set to Chinese locale, I get:
>> Sys.setlocale("LC_CTYPE", "Chinese") # properly print skim on Windows
> [1] "Chinese (Simplified)_People's Republic of China.936"
>> library(skimr); skim(cars)
> Skim summary statistics
>  n obs: 50
>  n variables: 2
>
> Variable type: numeric
>   variable missing complete  n  meansd min p25 median p75 max hist
> 1 dist   0   50 50 42.98 25.77   2  26 36  56 120  z ~
> ~ | y y x x
> 2speed   0   50 50 15.4   5.29   4  12 15  19  25  x y
> z ~ | | z z
>
> (emacs displays \250 instead of a space under that "hist" column).
>
> Note that I also have LC_CTYPE=en_US.utf-8 in my environment, which
> gives the following warning in R (both in Emacs ESS and in regular R
> GUI console):
>
> Using the Intel MKL for parallel mathematical computing (using 4 cores).
> Default CRAN mirror snapshot taken on 2017-10-15.
> See: https://mran.microsoft.com/.
> During startup - Warning message:
> Setting LC_CTYPE=en_US.utf-8 failed
>
> Happy to test further if anyone
>
> __
> ESS-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help

Re: [ESS] Print spark histograms from skimr package in Emacs ESS on Windows

2018-01-24 Thread Vitalie Spinu

Ok, I see. This is linux but I recall (from many years ago when I worked on
Windows) being able to fix such issues by explicitly specifying the codding
system of the process.

I still have this line commented out in my init file:

 (set-buffer-process-coding-system 'windows-1252 'windows-1252)

Try 'utf-8 or variants displayed by M-x list-coding-systems. If this works, you
can either set in ess-R-post-run-hook or in process-coding-system-alist.

I cannot investigate this further on Windows at the moment, sorry.

 Vitalie



>> On Wed, Jan 24 2018 09:50, Ista Zahn wrote:

> On Wed, Jan 24, 2018 at 8:54 AM, Vitalie Spinu  wrote:
>>
>>
>> Hi Vinh,
>>
>> It works for me out of the box, no need for Chinese locale or R specific 
>> tricks:

> Just to clarify -- it works for you _on Windows_? For me it works on
> Linux but _not_ on Windows. And "out of the box" means starting with

> runemacs.exe -q

> followed by

> (package-initialize)
> (require 'ess-site)

> ?

> For me R only displays a subset of characters correctly. For example,
> "\U00B5" displays correctly but "\U4E02" does not. Both characters
> display correctly when inserted with "insert-char", so this is not a
> font problem.

> The attached screen shot shows the behavior I observe in Emacs 25.3 on
> Windows starting from "runemacs.exe -q" (left) and when running
> "runemacs.exe" and using my usual configuration. The behavior is
> different, but in neither case is the 丂 character displayed correctly.

> Best,
> Ista
>>
>>
>>Variable type: numeric
>> variable missing complete   n mean   sd  p0 p25 median p75 p100 
>> hist
>> Petal.Length   0  150 150 3.76 1.77 1   1.6   4.35 5.1  6.9 
>> ▇▁▁▂▅▅▃▁
>>  Petal.Width   0  150 150 1.2  0.76 0.1 0.3   1.3  1.8  2.5 
>> ▇▁▁▅▃▃▂▂
>> Sepal.Length   0  150 150 5.84 0.83 4.3 5.1   5.8  6.4  7.9 
>> ▂▇▅▇▆▅▂▂
>>  Sepal.Width   0  150 150 3.06 0.44 2   2.8   33.3  4.4 
>> ▁▂▅▇▃▂▁▁
>>
>> My bet is that it's your emacs font which doesn't recognize those Unicode
>> characters.

>>
>> In my experience DejaVu is among the most complete fonts so I do this in my 
>> .emacs:
>>
>>   (set-face-font 'default  "DejaVu Sans Mono-9.5")
>>
>> You can see all fonts on your machine with by calling (font-family-list).
>>
>> HTH,
>>
>>   Vitalie
>>
>>
 On Tue, Jan 23 2018 17:35, Vinh Nguyen wrote:
>>
>>> Hi everyone,
>>
>>> Was curious if anyone was able to print spark histograms from the
>>> skimr in the text console of Emacs ESS?  Tried setting to Chinese
>>> locale, playing around with environment variables, but can't get
>>> things to print as described here:
>>> https://github.com/ropenscilabs/skimr/issues/246>
>>> I'm able to print on the regular R console by setting to the Chinese
>>> locale and using the NSimSun font as described here
>>> (https://stackoverflow.com/questions/44253848/skimr-cant-seem-to-produce-the-histograms),but
>>>  no luck on the Emacs ESS side.
>>
>>> Curious if others have gotten this to work.  Thanks!
>>> -- Vinh
>>
>>> __
>>> ESS-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/ess-help>
>> __
>> ESS-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help