I'm trying to perform a bladj in R language using the phylocom interface but, when I run (as in the package's example) the following commands
path <- "~/Mac/Courses_Rice/EcolJClub563/Fall10/phylometa_stuff/R_tutorial/bladjing/"
(tree2 <- rbladj(tree, path = path, fixroot = TRUE))
I only get the following message:
Error: phylocom not found - make sure your path is correct
I also downloaded the software into my computer and substitute the path with the path to the location of the executable, but I only get the same error.
I am running on Windows 10 (64 bits)
Can anybody tell me PLEASE how to fix it?
Best!
Paolo
Related
I installed R version 3.5.1 (on Windows 7 x64 desktop PC) following by Rtools 3.5 and rstan (via install.packages())
Rstan is failing with multi-core support like so:
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = 3) # or any number above 2
fit <- stan(file = '8schools.stan', data = schools_dat,
iter = 3, chains = 4)
with error:
Error in checkForRemoteErrors(val) :
4 nodes produced errors; first error: unable to load shared object 'C:/Users/ubashir/AppData/Local/Temp/RtmpIHGdm6/file194833bbb82.dll':
LoadLibrary failure: Access is denied.
However if i change the options line to:
options(mc.cores = 1) # or any other number up to 8
The code works. Anyone know a solution besides using only 1 core?
Thanks
There exist two relevant issues on the rstan GitHub project site: Issue #491 and Issue #492.
This issue seems to be related to an empty /etc/hosts file. I don't own a Windows machine, but this file seems to reside in c:\Windows\System32\Drivers\etc\hosts.
You need to make sure that the file contains a line:
127.0.0.1 localhost
If necessary edit and save the file, and try again. (You potentially might have to do the whole restart Windows shenanigans...)
Trying to use the awesome gganimate package in R, but was having trouble getting my animation to run. Reverted to trying to run the base example but couldn't get it to link up with ImageMagick.
Input:
library(gapminder)
b = ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year))+ geom_point() +scale_x_log10()
gg_animate(b)
And the output:
I cannot find ImageMagick with convert = "convert"
Error in file(file, "rb") : cannot open the connection
In addition: Warning messages:
1: running command 'C:\windows\system32\cmd.exe /c convert --version' had status 4
2: In find_magic() : ImageMagick not installed yet!
3: In im.convert(img.files, output = movie.name, convert = convert, :
Please install ImageMagick first or put its bin path into the system PATH variable
4: In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="filed42411bd2b88.gif": The system cannot find the file specified
From the research I have done it seems that the issue has something to do with declaring convert.exe and the windows path, I'm just not sure what to fix to get this code to work.
I have installed ImageMagick-7.0.2-Q16 for Windows (I am running Windows 7).
What am I missing?
You don't need to declare convert.exe; Windows has a native cli tool with the same name to convert a FAT partition into an NTFS partition, not what you want.
(NB: I forget to which directory IM installs itself in windows, so please verify the path I provide before blindly using this code.)
If this is a one-time thing, you can make it available with something like:
Sys.setenv(PATH = paste("c:/Program Files/ImageMagick/bin",
Sys.getenv("PATH"), sep = ";"))
If you want a more permanent solution, you have two options:
Save the above code in a .Rprofile file, either in your home directory (affects all of your future R sessions) or in the directory of your R project needing this tool. (You either need to also run this code on the console or restart the R session for the change to be noticed in your code.)
Add it to the windows path. There are lots of places to find help with this, including https://stackoverflow.com/a/28545224/3358272.
Edit: it came to my attention that the windows install no longer provides the convenience applications (e.g., convert.exe, mogrify.exe) that the unixy install does. (I'm using IM on windows installed via msys2, so I guess it's preferring the unixy-method ... I should have known.) So that suggests a third option:
Since gapminder is using gganimate which is calling animation::im.convert, its source says you can specify the command executable via something like ani.options(convert = shQuote('c:/program files/imagemagick/magick.exe')).
I want to deploy a basic trained R model as a webservice to AzureML. Similar to what is done here:
http://www.r-bloggers.com/deploying-a-car-price-model-using-r-and-azureml/
Since that post the publishWebService function in the R AzureML package was has changed it now requires me to have a workspace object as first parameter thus my R code looks as follows:
library(MASS)
library(AzureML)
PredictionModel = lm( medv ~ lstat , data = Boston )
PricePredFunktion = function(percent)
{return(predict(PredictionModel, data.frame(lstat =percent)))}
myWsID = "<my Workspace ID>"
myAuth = "<my Authorization code"
ws = workspace(myWsID, myAuth, api_endpoint = "https://studio.azureml.net/", .validate = TRUE)
# publish the R function to AzureML
PricePredService = publishWebService(
ws,
"PricePredFunktion",
"PricePredOnline",
list("lstat" = "float"),
list("mdev" = "float"),
myWsID,
myAuth
)
But every time I execute the code I get the following error:
Error in publishWebService(ws, "PricePredFunktion", "PricePredOnline", :
Requires external zip utility. Please install zip, ensure it's on your path and try again.
I tried installing programs that handle zip files (like 7zip) on my machine as well as calling the utils library in R which allows R to directly interact with zip files. But I couldn't get rid of the error.
I also found the R package code that is throwing the error, it is on line 154 on this page:
https://github.com/RevolutionAnalytics/AzureML/blob/master/R/internal.R
but it didn't help me in figuring out what to do.
Thanks in advance for any Help!
The Azure Machine Learning API requires the payload to be zipped, which is why the package insists on the zip utility being installed. (This is an unfortunate situation, and hopefully we can find a way in future to include a zip with the package.)
It is unlikely that you will ever encounter this situation on Linux, since most (all?) Linux distributions includes a zip utility.
Thus, on Windows, you have to do the following procedure once:
Install a zip utility (RTools has one and this works)
Ensure the zip is on your path
Restart R – this is important, otherwise R will not recognize the changed path
Upon completion, the litmus test is if R can see your zip. To do this, try:
Sys.which("zip")
You should get a result similar to this:
zip
"C:\\Rtools\\R-3.1\\bin\\zip.exe"
In other words, R should recognize the installation path.
On previous occasions when people told me this didn’t work, it was always because they thought they had a zip in the path, but it turned out they didn’t.
One last comment: installing 7zip may not work. The reason is that 7zip contains a utility called 7zip, but R will only look for a utility called zip.
I saw this link earlier but the additional clarification which made my code not work was
1. Address and Path of Rtools was not as straigt forward
2. You need to Reboot R
With regards to the address - always look where it was installed . I also used this code to set the path and ALWAYS ADD ZIP at the end
##Rtools.bin="C:\\Users\\User_2\\R-Portable\\Rtools\\bin"
Rtools.bin="C:\\Rtools\\bin\\zip"
sys.path = Sys.getenv("PATH")
if (Sys.which("zip") == "" ) {
system(paste("setx PATH \"", Rtools.bin, ";", sys.path, "\"", sep = ""))
}
Sys.which("zip")
you should get a return of
" C:\\RTools|\bin\zip"
From looking at Andrie's comment here: https://github.com/RevolutionAnalytics/AzureML/commit/9cf2c5c59f1f82b874dc7fdb1f9439b11ab60f40
Implies we can just download RTools and be done with it.
Download RTools from:
https://cran.r-project.org/bin/windows/Rtools/
During installation select the check box to modify the PATH
At first it didn't work. I then tried R32bit, and that seemed to work. Then R64 bit started working again. Honestly, not sure if I did something in the middle to make it work. Only takes a few minutes so worth a punt.
Try the following
-Download the Rtools file which usually contains the zip utility.
-Copy all the files in the "bin" folder of "Rtools"
-Paste them in "~/RStudio/bin/x64" folder
I am trying to use XLConnect library in R. If I execute
library(XLConnect)
I get the following error message:
JAVA_HOME cannot be determined from the Registry
To resolve this problem I set first the JAVA_HOME variable:
Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_65')
library(XLConnect)
It looks like it helps me to come further but then I get another problem:
unable to load shared object 'C:/Program Files/R/R-3.2.2/library/rJava/libs/x64/rJava.dll'
It wonder why R cannot load rJava.dll. At least this file is located in the folder where R searches for it:
C:\Program Files\R\R-3.2.2\library\rJava\libs\x64
ADDED
Please note that the rJava.dll file exists and it is located there, where R is searching for it. I guess that the problem is in incompatibility between 32bit and 64bit versions. I assume that because R complains:
% 1 is not a valid Win32 application
Well, why do R expect it to be a Win32 application`? First, my OS is 64bit, second my Java is also for the 64bit and finally, the `rJava.dll` object is located in the folder withx64` in the name (so, I assume it is also a 64bit version).
I faced the same issue . Please locate jvm.dll
should be in (your JRE version could be different )
C:\Program Files (x86)\Java\jre1.8.0_65\bin\client
or
C:\Program Files (x86)\Java\jre1.8.0_65\bin\server
add this path to your windows system path and you are good to go .but keep in mind the version of jre and R should be consistent,if your java is in Program Files its 64 bit so launch from 64 bit R if its in Program Files (x86)its 32 bit so use 32 bit R
like in my case it showed error in 64 bit
but worked perfectly in 32 bit
You did use / instead of \.
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre1.8.0_65')
library(XLConnect)
I am using UNIX. Therefore I cannot test it by myself but your path might be wrong as well.
According to this post you can search it by using this:
find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}
credit goes to #nograpes for the function and this article for helping me giving you the answer.
I am downloading data from data.gov website and I get following two types of errors in the process:
fileUrl <- "http://catalog.data.gov/dataset/expenditures-on-children-by-families"
download.file(fileUrl,destfile=".data/studentdata.csv",method="curl")
Warning message:
In download.file(fileUrl, destfile = ".data/studentdata.csv", method = "curl") :
download had nonzero exit status
I tried to remove the method="curl" as suggested in other forum, but again I get this new error
download.file(fileUrl,destfile=".data/studentdata.csv")
Error in download.file(fileUrl, destfile = ".data/studentdata.csv") :
cannot open destfile '.data/studentdata.csv', reason 'No such file or directory'
I think there are two major factors why your curl doesn't work well.
First, the problem is on your URL. fileUrl <- "http://catalog.data.gov/dataset/expenditures-on-children-by-families". In your URL, it is not referred to a csv file. So, they won't work even if you set the destination into a csv file such as destfile = ".data/studentdata.csv"
I have an example of getting a csv dataset using the same code (different dataset):
DataURL<- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD" (This link refers to a rows.csv file)
download.file(DataURL, destfile="./data/rows.csv", method="curl") (The method is quite same, using curl)
Second, previously I had the same problem that the curl does not work, even I used a proper URL that refers to a csv file. However, when I diagnosed a bit deeper, I found something interesting fact about why my curl method cannot work properly. It was my R session program. I used a 32-bit R, in which the error occurs. Later then, I tried to change the session into a 64-bit R. Amazingly, and the download status was running at that time. To see your R session architecture (whether you are using 32-bit or 64-bit), type in your R:
sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-ming32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
You have to switch your R, from 32-bit to 64-bit to avoid 'curl' call had nonzero exit status. You go to your R directory folder, and then you run a 64-bit R.
If you are using a Windows OS and installing the R in a default path folder, you can run this C:\Program Files\R\R-3.5.3\bin\x64\R.exe. (I used a version of 3.5.3, so it may be different with your version)
If you are using R-studio, you can switch the R session on the menubar Tools -> Global Options -> R version -> Change -> Use your machine's default version of R64 (64-bit) -> OK. Then restart your R-studio.
However, it depends on your OS architecture. If you are using a 32-bit OS, hence you have to find another way to solve this.
So looking at the code for download.file(...), if you specify method="curl" the function tries to use the curl shell command. If this command does not exist on your system, you will get the error above.
If you do not specify a method, the default is to use an internal R method to download, which evidently works on your system. In that case, the function is trying to put the file in .data/studentdata.csv but evidently there is not .data directory. Try taking out the ..
When this download works, you will get a text/html file, not a csv file. Your url points to a web page, not a download link. That page does have a download link, but unfortunately it is a pdf, not a csv.
Finally, if your goal is to have the data in R (is it?), and if the link actually produces a csv file, you could more easily use
df <- read.csv(fileUrl)
If I'm not very much mistaken you just have a simple typo here. I suspect you have a "data" directory, not a ".data" directory - in which case your only problem is that your destfile string needs to begin "./data", not ".data".
I was having the same problem.
Then I realized that I forget to create the "data" directory!
So try adding this above your fileURL line to create the directory first.
if(!file.exists("data")){
dir.create("data")
}
Also, if you are running a Mac, then you want to keep method="curl" when downloading a https file. I don't believe Windows has that problem hence the suggestions to remove it.
Try this:
file<-'http://catalog.data.gov/dataset/expenditures-on-children-by-families'
file<- read.csv(file)