I am a beginner in R.
I would like to use R clustal function in package ape to process my DNA sequence, so I can us {pegas} to perform further analysis.
However, when I first try the example provided in the manual:
clustal(woodmouse, pw.gapopen = 1, pw.gapext = 1, exec = "clustalw2")
But I got an error message:
/bin/sh: clustalw2: command not found
Error in file(file, "r") : cannot open the connection. In addition: Warning massage: In file(file, "r") : cannot open file '/var/folders/vm/fzyykk3x21g55fdvpctj7s900000gn/T//Rtmp0RjsMr/input_clustal.aln' :No such file or directory
I would like to know how to fix this problem? By the way, the OS I use is Mac OS 10.9. Thank you.
Make sure that you have clustalw2 installed. Download *.msi from here:
http://www.clustal.org/download/current/
Then run
require(ape)
fix(clustal)
Make sure that the following part of the clustal function:
shortPathName("C:/Program Files/ClustalW2/clustalw2.exe")
...matches the placement of clustalw2.exe in your system perfectly. Also exhange all the "/" with "\".
Hope that works - worked for me...
Related
I'm trying to conduct CFA but suddenly this error appear and now I cannot use r anymore since no metter what data I use it always give me the "Error in file(file, "r") : cannot open the connection".
This is the code that I'm using right now:
data
data <- read.delim("C:/Users/Nyname/Desktop/data.txt")
View(data)
model
overall_data <- '
f1 =~ item_3 + item_4 + item_12 + item_16
f2 =~ item_1 + item_5 + item_9 + item_14 + item_18
fit
overall_datafit <- cfa(overall_data, data=data, meanstructure = TRUE)
Error in file(file, "r") : cannot open the connection
I'v tried to change the directory, using setwd() and to unistall and install but nothing seems to work. I really hope somebody can help me because I've no idea what to do next and I really need to finish my work.
Thank you
I also came across similar kind of error when I worked on windows, and was not able to resolve what was the problem with my code.
If you are windows below will help, as I finally found out what the problem actually was:
When you name your file "blabla.txt" then windows name it "blabla.txt.txt"... That's the same with .CSV files so windows create a file named "bla.csv.csv" if you called it "bla.csv"
So, when you create your .txt file, just rename it "data" and open it in R using data <- read.delim("C:/Users/Nyname/Desktop/data.txt")
It worked for me.
It is a bit late for answering this question, but others may also face it.
It is possible that you have loaded another package that masks the function cfa() from lavaan (e.g., package "sem" or other packages that require it such as "faoutlier"). If so, you will face this error.
If this is the case, using lavaan::cfa() instead of cfa() should resolve the problem.
I am attempting to use the plot() function in the biomod2 package, following a vignette here (http://finzi.psych.upenn.edu/usr/share/doc/library/biomod2/doc/Simple_species_modelling.pdf). Below is the error I am getting:
getwd()
# [1] "/home/gjanzen/Documents/Hufford/Drought/Data/Layers"
plot(myBiomodData)
Error in getExportedValue(pkg, name) : cannot open file
'~/R/x86_64-pc-linux-gnu-library/3.3/viridisLite/data/Rdata.rdb': No
such file or directory In addition: Warning message: In
getExportedValue(pkg, name) : restarting interrupted promise
evaluation
I have confirmed that the Rdata.rdb exists, in the following directory:
f <- file.choose()
f
# [1] "/home/gjanzen/R/x86_64-pc-linux-gnu-library/3.3/viridisLite/data/Rdata.rdb"
So, to me, it looks like the plot() function is looking in the wrong place. How can I change where this function looks for Rdata.rdb? Can I alter the path somehow? Or would changing my working directory fix this?
PS - This is my first post on Stack Overflow, so please forgive any mistakes in etiquette, and/or feel free to point them out to me so that I do not repeat them.
I think that the first thing to try is to reinstall the package viridisLite that seems to be the one that is causing troubles.
install.packages('viridisLite', dep = TRUE)
If this not solves the issue you should try to open a new plotting device threw x11() to check if the issue is not coming from the R (resp. RStudio) plotting device itself.
I'm learning R programming, using the book, "The Art of R Programming".
In chapter 3.2.3 Extended Example: Image Manipulation. The author Matloff tries to use a Mount Rushmore gray-scale image to illustrate that the image is stored in matrix. He used a library called pixmap. And I downloaded the package, installed it.
> library(pixmap)
> mtrush1 <- read.pnm("mtrush1.pgm")
> mtrush1
Pixmap image
Type : pixmapGrey
Size : 194x259
Resolution : 1x1
Bounding box : 0 0 259 194
> plot(mtrush1)
This is what the book has written, and I tried to run this, but got the error message,
> library(pixmap)
> mtrush1 <- read.pnm("mtrush1.pgm")
Error in file(file, open = "rb") : cannot open the connection
In addition: Warning message:
In file(file, open = "rb") :
cannot open file 'mtrush1.pgm': No such file or directory
starting httpd help server ... done
What does this mean? cannot open the connection? And also the mtrush1.pgm does not exist? How should I fix it here? Any help? Much appreciated.
Summary:
Add the argument cellres=1 to your function call and you should be fine.
Answer:
The second error you saw--Warning message: In rep(cellres, length = 2) : 'x' is NULL so the result will be NULL--is because you haven't set the cellres argument and, as a result, "cellres" assumes its default value (i.e. 'NULL'--hence the warning). For what you're working on, setting the cellres argument to 1 will do the trick (though you can pass in a two-element vector with unequal values and see just how it affects your figure by plotting the resulting object).
Note: Though it's a little late to be answering, I figure that since I had the same problem earlier today (and since Google was no help) a response was probably warranted.
This means that the file mtrush1.pgm is not in current directory. You should either setwd to the directory that contains this file, or specify the complete path in read.pnm.
For the file mtrush1.pgm, you can download it from http://heather.cs.ucdavis.edu/~matloff/
The file mtrush1.pgm and the R scripts from the book "The Art Of R Programming" can be found at this GitHub site.
I have a package which contains a csv file which I put in inst/extdata per R-exts. This file is needed for the vignette. If I Sweave the vignette directly, all works well. When I run R --vanilla CMD check however, the check process can't find the file. I know it has been moved into an .Rcheck directory during checking and this is probably part of the problem. But I don't know how to set it up so both direct Sweave and vignette building/checking works.
The vignette contains a line like this:
EC1 <- dot2HPD(file = "../inst/extdata/E_coli/ecoli.dot",
node.inst = "../inst/extdata/E_coli/NodeInst.csv",
and the function dot2HPD accesses the file via:
ni <- read.csv(node.inst)
Here's the error message:
> tab <- read.csv("../inst/extdata/E_coli/NodeInst.csv")
Warning in file(file, "rt") :
cannot open file '../inst/extdata/E_coli/NodeInst.csv': No such file or directory
When sourcing ‘HiveR.R’:
Error: cannot open the connection
Execution halted
By the way, this is related to this question but that info seems outdated and doesn't quite cover this territory.
I'm on a Mac.
Have you tried using system.file instead of hardcoded relative paths?
EC1 <- dot2HPD(file = system.file("inst", "extdata", "E_coli", "ecoli.dot", package = "your_package+name"))
node.inst <- system.file("inst", "extdata", "E_coli", "NodeInst.csv", package = "your_package_name")
I want to make colored dendrograms and have yet to find a sufficient library: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=79
This graphic/library looks promising but cannot install the A2E library?
Trying to install on windows, downloaded the tar.gz file and cannot install package from the R console.
In addition:
Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In gzfile(file, "r") :
cannot open compressed file 'A2R_0.0-4.tar.gz/DESCRIPTION', probable reason 'No such file or directory'
Can anyone see if they can get this A2R library working, confirm error, or suggest a good colored dendrogram library?
(It might help if you spelled it correctly.) A2R is a source package. So you might need to have the system toolchain for compilation. Those are typically in your system if you are on Linux, but not if you are on a Mac (as I am) or on Windows. The package does compile from source on a Mac. And the compilation process may not have needed the toolchain. So try this:
install.packages("<fullpath> A2R_0.0-4.tar.gz", type ="source")
There are a few other dependencies: 'trimcluster', 'prabclus' , 'MASS' , 'cluster', 'mclust', 'flexmix', 'modeltools', 'stats4', 'multcomp', 'mvtnorm'. I am able to get most of that graphic but the left side curve does not appear as shown and I did get an error:
Error in hubertgamma[i] <- cluster.stats(d.usa, cutree(h.usa, k = i + :
replacement has length zero:
If you do not want the heights of the dendrogram scaled to their depth you can add this modification to the hclust object:
h.usa$height <- log(h.usa$height)
You could use the dendrapply() function in R's built-in dendrogram code to apply custom leaf and node coloring. See the following mailing list thread for hints.