Trouble with working directory and {reticulate} - r

I'm trying to use {reticulate} to load in a .pkl file. So far I've just loaded the package and tried to import pandas, i.e.:
library(reticulate)
pd<-import("pandas")
For some reason I'm getting this error, but can't make any sense of it:
Error: invalid version specification ''/home'', '..EXE was started with the above path as the current directory.', '. paths are not supported. Defaulting to Windows directory.'
In addition: Warning message:
In if (grepl("\\.$", v)) v <- paste0(v, "9000") :
the condition has length > 1 and only the first element will be used
Any tips?

Related

Attempting to use source() in r, but gives grep error

I am attempting to use Muxviz, and I believe that I installed all of the required dependencies (octave, R, g++, gfortan, and GDAL), but I'm getting an error when I try to use "source('muxVizGUI.R')". I says
Error in if (grep("3.2", version$version.string) != 1) { :
argument is of length zero
Any suggestions? I just made sure that R is > 3.2.x.

Error using DEXSeqDataSetFromHTSeq

Currently I am trying to understand DEXSeq package. I have a design tsv file and 7 files which contains Counts. Now would like to run the following command
library("DEXSeq");
design=read.table("dexseq_design.tsv", header=TRUE, row.names=1);
ecs = DEXSeqDataSetFromHTSeq(countfiles=c("M0.txt", "M1.txt", "M2.txt", "M3.txt", "M4.txt", "M5.txt", "M6.txt", "M7.txt"), design=design, flattenedfile="genome.chr.gff");
The last command gives and error
Error in class(sampleData) %in% c("data.frame") :
error in evaluating the argument 'x' in selecting a method for function '%in%':
Error: argument "sampleData" is missing, with no default
What does this error means and how to fix it? While loading the package DEXSeq there was a warning
Warning message:
replacing previous import by ‘ggplot2::Position’ when loading ‘DESeq2’

In R, after installed a package,' pixmap', Error in file(file, open = "rb") : cannot open the connection

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.

Using R package BerkeleyEarth

I'm working for the first time with the R package BerkeleyEarth, and attempting to use its convenience functions to access the BEST data. I think maybe it's just a problem with their servers (a matter I've separately addressed to the package's maintainer) but I wanted to know if it's instead something silly I'm doing.
To reproduce my fault
library(BerkeleyEarth)
downloadBerkeley()
which provides the following error message
trying URL 'http://download.berkeleyearth.org/downloads/TAVG/LATEST%20-%20Non-seasonal%20_%20Quality%20Controlled.zip'
Error in download.file(urls$Url[thisUrl], destfile = file.path(destDir, :
cannot open URL 'http://download.berkeleyearth.org/downloads/TAVG/LATEST%20-%20Non-seasonal%20_%20Quality%20Controlled.zip'
In addition: Warning message:
In download.file(urls$Url[thisUrl], destfile = file.path(destDir, :
InternetOpenUrl failed: 'A connection with the server could not be established'
Has anyone had a better experience using this package?
The error message is pointing to a different URL than one should get judging what URLs are listed at http://berkeleyearth.org/data/ that point to the zip formatted files. There are another set of .nc files that appear to be more recent. I would replace the entries in the BerkeleyUrls dataframe with the ones that match your analysis strategy:
This is the current URL that should be in position 1,1:
http://berkeleyearth.lbl.gov/downloads/TAVG/LATEST%20-%20Non-seasonal%20_%20Quality%20Controlled.zip
And this is the one that is in the package dataframe:
> BerkeleyUrls[1,1]
[1] "http://download.berkeleyearth.org/downloads/TAVG/LATEST%20-%20Non-seasonal%20_%20Quality%20Controlled.zip"
I suppose you could try:
BerkeleyUrls[, 1] <- sub( "download\\.berkeleyearth\\.org", "berkeleyearth.lbl.gov", BerkeleyUrls[, 1])

Creating a help file for a vector object

I'm working in R Version 2.15.0 on Mac OS X (Intel, 64-bit). When I apply prompt to a vector object, it throws an error unless I specify the file argument. Additionally, when I do provide a file name, there are oddities in the help file skeleton (e.g. many \name, \alias, and \usage commands, one for each element of the vector). Are these the expected results of prompt when specifying a vector? Sample commands that replicate the problem:
> COL <- rgb(1:4 / 4, 4:1 / 4, c(1, 0, 1, 0))
> prompt(COL)
Error in file(file, ifelse(append, "a", "w")) :
invalid 'description' argument
In addition: Warning messages:
1: In if (is.na(filename)) return(Rdtxt) :
the condition has length > 1 and only the first element will be used
2: In if (file == "") file <- stdout() else if (substring(file, 1L, :
the condition has length > 1 and only the first element will be used
3: In if (substring(file, 1L, 1L) == "|") { :
the condition has length > 1 and only the first element will be used
> prompt(COL, file="COL.Rd")
Created file named ‘COL.Rd’.
Edit the file and move it to the appropriate directory.
One other odd component: when running 32-bit R on my machine and loading in the package, R will not properly load and allow access to the vector object when it is from the package (i.e. it throws an error: Error: internal error -3 in R_decompress1). However, when I load in the .rda object directly, things are fine in R 32-bit. Are such problems/inconsistencies expected when running R 32-bit on a 64-bit machine?
Edit: One more question. Any idea on how to get .R and .rda files to open in R 64-bit by default? The "Get Info" trick doesn't work... when clicking "Change All", it reverts back to the default R 32-bit. This seems to be a problem for certain file types.
Thanks!
As Paul said, split your questions next time.
Regarding the prompt function:
If you don't specify anthing, the filename is set to NULL, and the default behaviour is that the object itself is used to create a filename. When you pass a vector, the function sees that as a vector of objects and hence creates a vector of names. That gives the error message.
If you want to document a vector object, use the argument name instead, eg: prompt(name="COL"). That will give you the wanted behaviour
If you want to see a list, ?prompt tells you that you should specify filename=NA. The output will come to the console instead.
Opening .R and .rda files by 64 bit by default is OS dependent. In Windows you can do this eg via the control Panel > Default Programs > set Associations and then set the association to the 64bit binary file of R (to be found in ...\R\R-2.15.0\bin\x64 ).
The second question is impossible to answer without further details. I suggest you figure out how to reproduce that (see this question) and ask it in a new question

Resources