I am working in RStudio (on a Mac) to write reports which are rendered as PDF.
I am working in an English locale.
The report, however, is in German and I would like to use German decimal and group (thousands) marks in the report without changing the locale of the OS (or R).
I would like to do this by setting one global option at the beginning of the Rmd file.
Is there a way to accomplish this?
Up until now I tried
command line in Terminal
defaults write org.R-project.R force.LANG de_AT.UTF-8
This only changed the UI language used by R itself, no by RStudio.
Sys.setlocale("LC_NUMERIC","de_DE")
in an Rmd document produces
Error: package or namespace load failed for ’sf': .onLoad failed in loadNamespace() for ’units’, details: call:
udunits_initCfile.path(.get_ud_xml_dir(), "udunits2.xml")) error: Error in function udunits.init: Can't open
installed, default, unit database Execution halted
Putting
NUMERIC="de_DE"
LC_NUMERIC="de_DE"
in .Renviron does not help either
Quoting ?locales
Setting "LC_NUMERIC" to any value other than "C" may cause R to function anomalously, so gives a warning. Input conversions in R itself are unaffected, but the reading and writing of ASCII save files will be, as may packages which do their own input/output.
Setting it temporarily on a Unix-alike to produce graphical or text output may work well enough, but options(OutDec) is often preferable.
So let's try that:
---
output: pdf_document
lang: de-DE
---
```{r echo=FALSE}
options(OutDec = ",")
library(sf)
knitr::kable(head(mtcars))
```
Dies ist ein nichtssagender Blindtext inklusive R output `r pi` der genau so
lang ist, dass es zu Zeilenumbrüchen mit Trennung kommt.
Result:
Notes:
There is no group-separator, since R does not use that in its output.
I have added lang: de-DE to enable German hyphenation patterns.
Loading the sf package works without problems.
Related
I am trying to print out some information within a CUDA kernel using printfs to write code into the console that I can paste into another program to draw the geometric setup that I am working with.
I have, however, trouble getting the locale to work. I am working under Linux Mint 18.1 with CUDA 9.0. When I printf from the C++ part of my program the numbers get printed as follows:
printf("my value: %.3f\n", my_value); // prints 1.234 for example
but using it from a CUDA kernel I get
printf("my value: %.3f\n", my_value); // prints 1,234
This is the format used in Germany, but obviously computers don't understand the latter format. I need it to print with the . instead of the comma.
I have tried manually setting my locale by putting the line
export LC_NUMERIC="en_US.UTF-8"
into my .bashrc. My locale command prints:
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=de_BE.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=de_BE.UTF-8
LC_NAME=de_BE.UTF-8
LC_ADDRESS=de_BE.UTF-8
LC_TELEPHONE=de_BE.UTF-8
LC_MEASUREMENT=de_BE.UTF-8
LC_IDENTIFICATION=de_BE.UTF-8
LC_ALL=
But that does not change the output from the CUDA kernel.
I am not sure which other values to overwrite, without messing up default currency and so on. I also cannot find any information on setting locales within CUDA, so I assume it fetches that information from somewhere else. Does anyone know where that is and how to make it do what I want?
It seems like Linux is very adamant on keeping the current language configuration as it is. I managed to get the printout to be like I want it by uninstalling all other language packages that were installed, putting
export LANG=en_US.utf8
in my .bashrc and then rebooting the machine. Not sure if all of those steps were necessary, but it fixed my problem.
I has this code that searches through text by XPath. The problem is that the searched text may contain Latin characters like ñor í.
I encoded it and when I print it, it shows perfectly, but when I use the XPath the encoding changes, and obviously it can't be found.
The decoded var prints well:
nombre_act = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
nombre_act = nombre_act.decode("utf8")
nombre_contrato = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato.decode("utf8")
print nombre_contrato
xpath = "//select[#name='"+nombre_act+"']/option[text()='"+nombre_contrato+"']"
print xpath
hotel_sel = driver.find_element_by_xpath(xpath).click()
Your code trials were near perfect. However I feel you don't need to change through encoding/decoding unless you want to print the characters to the console as follows:
nombre_act_actual = "HOTEL DIEGO DE ALMAGRO SAN PEDRO DE ATACAMA"
#nombre_act = nombre_act_actual.encode("utf-8")
nombre_contrato_actual = "Campaña Cyber Day, Desayuno Incluído"
nombre_contrato = nombre_contrato_actual.encode("utf-8") #required as you need to print to the console
print nombre_contrato
xpath = "//select[#name='"+nombre_act_actual+"']/option[text()='"+nombre_contrato_actual+"']"
hotel_sel = driver.find_element_by_xpath(xpath).click()
However, your another issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.41
Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v67-69
You are using chrome=70.0
Release Notes of ChromeDriver v2.44 clearly mentions the following :
Supports Chrome v69-71
So there is a clear mismatch between ChromeDriver v2.41 and the Chrome Browser v70.0
Solution
Upgrade ChromeDriver to current ChromeDriver v2.44 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.44 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test.
I've got Dragon Naturally Speaking 14, dragonfly, the latest natlink (4.1 or something), pywin32, python 2.7, and wxpython installed
I've got a python file with this in it in my "user configuration directory" set up by natlink
I get the natlink popup message when Dragon Naturally Speaking starts, telling me that it's working. I reset DNS 14 to ensure my "macro" (dosomething.py) is loaded.
this is the code in my dosomething.py
from dragonfly import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Voice command spoken."
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load() # Load the grammar.
while True:
pythoncom.PumpWaitingMessages()
sleep(.1)
however, when I start up & activate DNS and say "do something computer" with dictation & command mode, or just command mode, the transcription box pops up, how can I tell if it's working or not? I don't think it is. What is supposed to happen? I'm new to python, I fired up the interpreter in the cmd window and no prompt like "Voice command spoken." is ever generated when I say the voice command. Is that what's supposed to happen?
There are two ways to load up Dragonfly grammars: through Natlink, and through Windows Speech Recognition. WSR requires you to put in that while loop with pythoncom.PumpWaitingMessages(), but that won't work with Natlink. You should comment it out.
If you set this up correctly, you won't see "Voice command spoken." in any cmd prompt -- you will see it in the Natlink window.
I am running libsvm through weka. Its output accuracy looks good to me, so I am planning to write a svm model by myself. However, weka didn't generate any training parameter, such as number of support vector. Therefore i cannot do anything. Searching the web, i found somebody said it would generate some parameters like the following:
optimization finished, #iter = 27
nu = 0.058475864943863545
obj = -1.871013102744184, rho = -0.19357337828800944
nSV = 9, nBSV = 0 `enter code here`
Total nSV = 9
but how come i didn't see any of them? any step that i missed? please help me. Thanks a lot.
Weka writes the output you mentioned to stderr.
So if you have started weka.sh or weka.bat from a terminal (or "command window" if you are on Windows), you should see that output appear in your terminal window after clicking "classify"
If you want to have access to this information via scripts, you can
redirect the output to a file and read in that file.
Here is how to edit the startup file weka.sh / weka.bat.
Edit this line (it is probably the last line) in order to write log info to a file instead of the terminal window:
java -cp $CP -Xmx8092m weka.gui.GUIChooser 2>>/opt/weka-stable/weka.log &
You can also add a properties file to your home directory to add more fine-grained behaviour.
https://weka.wikispaces.com/Properties+file
(You probably can also access information via the Weka Java API somehow, but you did not ask for that)
The thing is that on non-english versions of XP code pages for console and gui apps differ, for example if I on my Polish version write in console:
echo zażółć gęślą jaźń > somefile.txt
The content of that file is:
zaľ˘† g©lĄ ja«ä
This isn't happening if I put that into cmd file. That is this text with polish letters. But if I create a file or directory that is named using non English only chars, then no matter if it's run from cmd or from finger the effect is always gibberish.
So my question is how to get this second code page that rest of windows is running with. In my case this CP is 1250 - but how to get this number from c++ ?
GetConsoleCP() and GetConsoleOutputCP() both return 852 (which is correct) and GetThreadLocale() gives 1045.
If I try to chcp 1045 it gives "wrong code page".
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\ACP - this registry key stores the ANSI code page number (it should be 1250 in your case) and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage\OEMCP stores OEM code page.
Oh, and there are GetACP and GetOEMCP functions.