I have read several questions listed below:
Set path to miktex for pdflatex in R
How can I set the latex path for sweave in R?
https://tex.stackexchange.com/questions/267299/how-to-fix-the-sorry-but-c-miktex-pdftex-exe-did-not-succeed-error
https://tex.stackexchange.com/questions/429706/rstudio-not-detecting-miktex
https://tex.stackexchange.com/questions/231595/rstudio-cant-find-pdflatex-on-windows-7
The above list does not exhaust everything I have tried which also includes reinstalling RStudio, R and MikTex.
I then thought that I could edit the path to delete MikTeX 1.9 that R keeps calling but don't know how to do that.
I found this function which shows that I have infact set the correct path to MikTex but R keeps calling MikTeX 1.9:
Sys.which2 <- function(cmd) {
stopifnot(length(cmd) == 1)
if (.Platform$OS.type == "windows") {
suppressWarnings({
pathname <- shell(sprintf("where %s 2> NUL", cmd), intern=TRUE)[1]
})
if (!is.na(pathname)) return(setNames(pathname, cmd))
}
Sys.which(cmd)
}
Different output between Sys.which and Sys.which2:
Sys.which2("pdflatex")
pdflatex
"C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\pdflatex.exe"
Sys.which("pdflatex")
pdflatex
"C:\\PROGRA~1\\MIKTEX~1.9\\miktex\\bin\\x64\\pdflatex.exe"
How can I best solve this issue?
My idea was to somehow locate where R is finding this MikTeX 1.9 and replace it but I can't find it on my system and don't quite know what Sys.which is doing behind the scenes.
EDIT
An attempt at locating where 1.9 is:
stringr::str_detect(unlist(strsplit(Sys.getenv("PATH"),";")),"latex")
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
Output of sys.getenv("PATH":
"C:/Program Files/MiKTeX 2.9/miktex/bin/x64:C:\Program Files\R\R-3.6.2\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\copasi.org\COPASI 4.22.170\bin;C:\Program Files (x86)\Intel\TXE Components\iCLS\;C:\Program Files\Intel\TXE Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Recovery\OEM\Backup\;C:\Program Files\Intel\TXE Components\DAL\;C:\Program Files (x86)\Intel\TXE Components\DAL\;C:\Program Files\Intel\TXE Components\IPT\;C:\Program Files (x86)\Intel\TXE Components\IPT\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;E:\MATLAB\runtime\win64;E:\MATLAB\bin;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Users\my name\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\my name\AppData\Local\Programs\Python\Python38\;C:\Users\my name\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\my name\AppData\Local\Programs\Python\Python36\;C:\Users\my name\Desktop\wget-1.20.3-win64;C:\Users\my name\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\my name\AppData\Local\Programs\Python\Python37\;C:\Users\my name\AppData\Local\Microsoft\WindowsApps;C:\Users\my name\AppData\Local\Programs\Python\Python37-32;E:\jdk-12_windows-x64_bin;C:\Users\my name\AppData\Local\Microsoft\WindowsApps;C:\Users\my name\Desktop\adb+-+platform+tools+v28.0.1"
C:\\PROGRA~1\\MIKTEX~1.9 doesn't mean literally MiKTeX v1.9. It is an 8.3 filename. Because the string MiKTeX 2 contains a "special character" (i.e. a space), it is converted to MIKTEX~1 (the .9 part still remains as the "extension", so MiKTeX 2.9 became MIKTEX~1.9, which is indeed confusing in this case).
I feel the problem you are actually trying to solve might be a different one. If that's the case, you may ask the actual question. There isn't anything wrong with your environment variables, as far as I can see.
If you really need the long name, you can call normalizePath() to convert the short 8.3 name to a long name.
Related
I'm new to Robot Framework scripting. I am facing an hurdle with this line.
So as per the Image horizon library, the keyword 'does exist' returns TRUE or FALSE
But how do I check if this keyword returns true or false
Run Keyword and Return Status this keyword returns the status of True or False.
Here is the official documentation for the same.
https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Run%20Keyword%20And%20Return%20Status
If you are looking for an example line, then here it is:
${IS_PRESENT} Run Keyword and Return Status Element Should Contain something that I am asserting for
Log to Console ${IS_PRESENT} # returns the status True/False on to the console
# Log ${IS_PRESENT} # prints the status True/False in the log.html file
I am trying to figure out a way to find all the keywords that come from the same root word (in some sense the opposite action of stemming). Currently, I am using R for coding, but I am open to switching to a different language if it helps.
For instance, I have the root word "rent" and I would like to be able to find "renting", "renter", "rental", "rents" and so on.
Try this code in python:
from pattern.en import lexeme
print(lexeme("rent")
the output generated is:
Installation:
pip install pattern
pip install nltk
Now, open a terminal, type python and run the below code.
import nltk
nltk.download(["wordnet","wordnet_ic","sentiwordnet"])
After the installation is done, run the pattern code again.
You want to find the opposite of Stemming, but stemming can be your way in.
Look at this example in Python:
from nltk.stem.porter import PorterStemmer
stemmer = PorterStemmer()
words = ["renting", "renter", "rental", "rents", "apple"]
all_rents = {}
for word in words:
stem = stemmer.stem(word)
if stem not in all_rents:
all_rents[stem] = []
all_rents[stem].append(word)
else:
all_rents[stem].append(word)
print(all_rents)
Result:
{'rent': ['renting', 'rents'], 'renter': ['renter'], 'rental': ['rental'], 'appl': ['apple']}
There are several other algorithm to use. However, keep in mind that stemmers are rule-based and are not "smart" to the point where they will select all related words (as seen above). You can even implement your own rules (extend the Stem API from NLTK).
Read more about all available stemmers in NLTK (the module that was used in the above example) here: https://www.nltk.org/api/nltk.stem.html
You can implement your own algorithm as well. For example, you can implement Levenshtein Distance (as proposed in #noski comment) to compute the smaller common prefix. However, you have to do your own research on this one, since it is a complex process.
For an R answer, you can try these functions as a starting point. d.b gives grepl as an example, here are a few more:
words = c("renting", "renter", "rental", "rents", "apple", "brent")
grepl("rent", words) # TRUE TRUE TRUE TRUE FALSE TRUE
startsWith(words, "rent") # TRUE TRUE TRUE TRUE FALSE FALSE
endsWith(words, "rent") # FALSE FALSE FALSE FALSE FALSE TRUE
I'm running Kibana 6.7.1 in Elastic Cloud. I'm open to upgrading it if will help.
I would like to hide all of the links (plugins? applications?) in Kibana's left navigation bar, except for "Discover", "Visualize", "Dashboard", and maybe "Canvas". Ideally configured by space or by role.
I've read in a few places that Timelion can be disabled by setting Timelion.enabled: false in the Kibana.yaml. However, that setting is not documented for 6.7. And there are ten other links to hide.
Is this what Application Roles are for? I did not get anywhere with trying to set them and I don't think they do this as I assume the documentation would list the roles for each default application if that was the case.
I've tried Dashboard Only mode, but it's more restrictive than I would prefer.
Are there settings in Kibana to disable these links, or do I have to add CSS or use a proxy which edits the HTML to remove them?
I am using the latest ELK stack [ELK - 7.5.2] to develop a custom plugin and have found following settings to be helpful in removing the clutter from Kibana.
You can add these to your kibana.yml file and set their values according to your needs:
xpack.canvas.enabled: false
xpack.reporting.enabled: false
xpack.actions.enabled: false
xpack.alerting.enabled: false
xpack.maps.enabled: false
xpack.security.enabled: false
xpack.uptime.enabled: false
xpack.watcher.enabled: false
xpack.spaces.enabled: false
xpack.license_management.enabled: false
xpack.upgrade_assistant.enabled: false
xpack.index_management.enabled: false
xpack.apm.enabled: false
xpack.beats.enabled: false
xpack.ccr.enabled: false
xpack.cloud.enabled: false
xpack.code.enabled: false
xpack.graph.enabled: false
xpack.grokdebugger.enabled: false
xpack.ilm.enabled: false
xpack.infra.enabled: false
xpack.logstash.enabled: false
xpack.ml.enabled: false
xpack.monitoring.enabled: false
xpack.remote_clusters.enabled: false
xpack.rollup.enabled: false
xpack.searchprofiler.enabled: false
xpack.siem.enabled: false
xpack.snapshot_restore.enabled: false
xpack.tilemap.enabled: false
xpack.transform.enabled: false
Hope it helps.
I have an R script that takes a file as input, and I want a general way to know whether the input is a file that exists, and is not a directory.
In Python you would do it this way: How do I check whether a file exists using Python?, but I was struggling to find anything similar in R.
What I'd like is something like below, assuming that the file.txt actually exists:
input.good = "~/directory/file.txt"
input.bad = "~/directory/"
is.file(input.good) # should return TRUE
is.file(input.bad) #should return FALSE
R has something called file.exists(), but this doesn't distinguish files from directories.
There is a dir.exists function in all recent versions of R.
file.exists(f) && !dir.exists(f)
The solution is to use file_test()
This gives shell-style file tests, and can distinguish files from folders.
E.g.
input.good = "~/directory/file.txt"
input.bad = "~/directory/"
file_test("-f", input.good) # returns TRUE
file_test("-f", input.bad) #returns FALSE
From the manual:
Usage
file_test(op, x, y) Arguments
op a character string specifying the test to be performed. Unary
tests (only x is used) are "-f" (existence and not being a directory),
"-d" (existence and directory) and "-x" (executable as a file or
searchable as a directory). Binary tests are "-nt" (strictly newer
than, using the modification dates) and "-ot" (strictly older than):
in both cases the test is false unless both files exist.
x, y character vectors giving file paths.
You can also use is_file(path) from the fs package.
How can I check if a https url is valid?
Using:
RCurl::url.exists("https://github.com/")
gives [1] FALSE.
I prefer base R for my needs but am not married to it. Plus additional answers make this question more generalizable.
I would use httr instead. I'm not sure which one is preferable between url_ok and url_success but they both work at this level.
library(httr)
url_ok("http://github.com/")
#[1] TRUE
url_ok("https://github.com/")
#[1] TRUE
url_ok("https://github.com/nonworking")
#[1] FALSE
url_success("http://github.com/")
#[1] TRUE
url_success("https://github.com/")
#[1] TRUE
url_success("https://github.com/nonworking")
#[1] FALSE
For some reason, RCurl doesn't like github even in http mode. I suspect it's because of a redirect.
library(RCurl)
url.exists("http://github.com/")
#[1] FALSE
url.exists("https://github.com/")
#[1] FALSE
Edit: Some commenters have mentionned they get TRUE as an answer, but I also get FALSE using RCurl. I'm on Windows.