[R] Problem opening connections to removable hard drive
Hi, I have my files and R session on a portable hard drive to be able to work across computers since I have some extremely large files. I have just started doing this and generally it works as I expect. But after a while of using my R session, certain types of calls to open connections on the hard drive don't work. But I experience no problems opening/saving files on the portable hard drive using other programs. In particular, if I explicitly call the entire folder path to the hard drive, I can save an object to file, for example. But if I just want to save it in the current working directory, without explicitly naming the entire path, then I have problems (I show an example below). I am using a package that assumes a certain file structure from the current working directory in order to find/write output, which is why I want to be able to rely on not explicitly calling the whole path. Furthermore, I was experimenting just now, and when I changed the current directory to another one, and then back to the removable hard drive, everything gets 'reset' somehow and opening connections works again, just like when I first started up my session. I am on Windows XP, R 2.4.0. Thanks, Elizabeth Purdom example: getwd() [1] I:/ICBP/Exon Array/Data #explicit call to hard drive works... save(x,file=I:/ICBP/Exon Array/Data/tmp.rdata) #unexplicit call relying on knowing working directory doesn't... save(x,file=tmp.rdata) Error in gzfile(file, wb) : unable to open connection In addition: Warning message: cannot open compressed file 'tmp.rdata' __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] passing arguments to multiple functions
Hi, I am writing a function and I want to pass arguments to a function I will call internally without having to specify all the possible arguments to pass. Usually I would use '...' but I want to do this for two functions that I will call, and the two functions do not take the same arguments. So I would like a call to my function to look like this: myfunc(x, fun1Args, fun2Args) where fun1Args would be a list of arguments to pass to the first function and fun2Args would be list of arguments to pass to the second function. The problem is that I don't know how to write 'myfunc' so that I can input these elements into the calls I will make to the two functions. I certainly don't want to have to specify all the possible values and input them manually (for example if one of the functions is a plotting function!) I know I've run across functions that require you to pass arguments in a list like this, but the only one I can remember is 'mapply' which calls a C function so it doesn't help me figure out how to parse/send the arguments to the functions. Is this possible to do within R? Or is there a way to parse the '...' so that only the right arguments go to the right function? Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Internet Problem in R
Hi, I have a student who's R seems to be unable to connect to the internet. I have verified that her computer has internet access that's working fine, but that R is not able to establish connections. For example, she cannot download packages for R from the URL site, cannot source webpages, or read.table from a webpage (all of these give errors of not being able to establish a connection). Right now I have shown her how to manually download the zip file for the package and install it from the local file, but she wants Bioconductor -- the instructions for which seem to require the usual internet access. Does anyone have any troubleshooting suggestions? (I've never had problems with the internet interface with R, so I don't even know where to start to try to fix it or even diagnose the problem). Could a firewall have this effect? Wireless? Her computer is running version R.2.3.1, on a Windows XP. Thanks, Elizabeth Purdom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] NA in eigen()
Sorry, I forgot to give my system details. I am using R 2.2.1 on a Windows XP. I just did the standard download from the CRAN page for Windows. I did not use any special options. I don't know what compilation the download is, the details of BLAS or LAPACK for my computer, etc. -- how can I find this information for my computer? Thanks, Elizabeth At 03:46 AM 3/4/2006, Prof Brian Ripley wrote: The default is to use LAPACK rather than EISPACK. In general, LAPACK is a lot faster and a lot stabler than EISPACK, so you will get `odd behavior' much more often with EISPACK=TRUE (sic). You have not told us your machine or R details. Most of the problem reports we see in this area are not due to R itself but to a problem in the BLAS or LAPACK in use on the system running R. So exactly what system is this, how was R compiled and with what options? On Fri, 3 Mar 2006, Elizabeth Purdom wrote: Hi, I am using eigen to get an eigen decomposition of a square, symmetric matrix. For some reason, I am getting a column in my eigen vectors (the 52nd column out of 601) that is a column of all NAs. I am using the option, NAs and not NaNs? I don't think the internal code of eigen knows how to generate NAs, and is.na is not a test for NAs. symmetric=T for eigen. I just discovered that I do not get this behavior when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is (up to rounding error) a vector of all zeros except for -0.6714 and +0.6714 in two locations. The eigenvalues (which are the same with either one) has the 52nd eigenvalue being exactly 19. I also do not have the NA problem if I choose symmetric=F. My main question is whether there is any reason I should not use the EISPACK option (I do not know that what the EISPACK option really means, except that its not preferred)? Or stated another way, should I trust that the results for EISPACK=T, and just ignore the very odd behavior of EISPACK=F? Or is there something inherently problematic or unstable about my eigen decomposition of this matrix -- and if so, is it my matrix or the program? I have no idea what's causing it, and I can't get a reproducible example, other than with my large matrix. My original matrix has no NAs in it. Here is code, but of course it requires my original, 601x601 symmetric matrix called mat any(is.na(mat)) [1] FALSE any(is.na(d)) [1] FALSE dim(mat) [1] 601 601 length(which(d==0)) [1] 5 d-rowSums(mat) temp1-eigen(diag(d)-mat,symmetric=T) temp2-eigen(diag(d)-mat,symmetric=T,EISPACK=T) any(is.na(temp1$vec)) [1] TRUE any(is.na(temp1$vec[,-52])) [1] FALSE any(is.na(temp2$vec)) [1] FALSE all.equal(abs(temp1$vec[,-52]),abs(temp2$vec[,-52])) [1] Mean relative difference: 0.3278133 all.equal(temp1$val,temp2$val) [1] TRUE temp2$val[52] [1] 19 Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] NA in eigen()
Hi, I am using eigen to get an eigen decomposition of a square, symmetric matrix. For some reason, I am getting a column in my eigen vectors (the 52nd column out of 601) that is a column of all NAs. I am using the option, symmetric=T for eigen. I just discovered that I do not get this behavior when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is (up to rounding error) a vector of all zeros except for -0.6714 and +0.6714 in two locations. The eigenvalues (which are the same with either one) has the 52nd eigenvalue being exactly 19. I also do not have the NA problem if I choose symmetric=F. My main question is whether there is any reason I should not use the EISPACK option (I do not know that what the EISPACK option really means, except that its not preferred)? Or stated another way, should I trust that the results for EISPACK=T, and just ignore the very odd behavior of EISPACK=F? Or is there something inherently problematic or unstable about my eigen decomposition of this matrix -- and if so, is it my matrix or the program? I have no idea what's causing it, and I can't get a reproducible example, other than with my large matrix. My original matrix has no NAs in it. Here is code, but of course it requires my original, 601x601 symmetric matrix called mat any(is.na(mat)) [1] FALSE any(is.na(d)) [1] FALSE dim(mat) [1] 601 601 length(which(d==0)) [1] 5 d-rowSums(mat) temp1-eigen(diag(d)-mat,symmetric=T) temp2-eigen(diag(d)-mat,symmetric=T,EISPACK=T) any(is.na(temp1$vec)) [1] TRUE any(is.na(temp1$vec[,-52])) [1] FALSE any(is.na(temp2$vec)) [1] FALSE all.equal(abs(temp1$vec[,-52]),abs(temp2$vec[,-52])) [1] Mean relative difference: 0.3278133 all.equal(temp1$val,temp2$val) [1] TRUE temp2$val[52] [1] 19 Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Question about Sweave
Hi, I'm not sure if Sweave questions should go to the general list, but it seems to be part of the core R package without a separate maintainer. I am writing a tutorial for R in a latex file. I'd like to use Sweave, since this seems its ideal usage. The problem is that I want to purposefully put errors in and then the output that comes with it in the text of my tutorial. However the errors kill the function Sweave() in R when what I would like is for Sweave to just run it and include the error message as part of the output. I have set options(error=NULL). It doesn't seem that the error options would affect Sweave in the right way, since an error in my .Rnw file causes an error in Sweave() itself, not just in the processing of the code, but maybe there's an error-handling system I don't know about that would do it. (I tried error=expression(NULL) but Sweave couldn't finish regardless). I don't see any options in the documentation of Sweave that allow this behavior, either. Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] 'all' inconsistent?
Hello, I came across the following behavior, which seems illogical to me. I don't know if it is a bug or if I'm missing something: all(logical(0)) [1] TRUE any(logical(0)) [1] FALSE isTRUE(logical(0)) [1] FALSE This actually came up in practice when I did something like all( names(x) %in% vec ) as an error-handling, and I was hoping that it would work regardless of whether x had names or not. I can clearly work around it, but it seemed like strange behavior to me. Thanks, Elizabeth Purdom R 2.2.1, Windows XP __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Downloads -- possible bug?
Hi, When I go to the CRAN page to download a new version of R, there are not the same versions available depending on which mirror I pick. When I go to http://cran.cnr.berkeley.edu/, for example, I get 2.2.1, but if I go http://cran.stat.ucla.edu/ the option is 2.2.0 (I'm downloading the Windows base file). Neither refreshing nor clearing my cache changes it. For future reference, I'd like to know if this is a mistake or if different mirrors are just updated at different times? Thanks, Elizabeth Purdom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R CMD not recognized at command-line
Hi, I am trying to run a batch command on Windows XP and R CMD is not recognized. I get the error, 'R' is not recognized as an internal or external command, operable program or batch file. I have C:\Program Files\R\rw2010\bin in my $PATH variable and Rcmd.exe has been installed in that folder. I have restarted the computer to make sure any changes in the $PATH variable registered. I have tried directly calling Rcmd.exe or R.exe. None of this had any effect and I can't think what I'm forgetting. In Cygwin, I can get around this by explicitly giving the path at the prompt line, for example, ~/Program\ Files/R/rw2010/bin/R CMD --help This work-around does not seem work from the usual DOS Command Prompt, but I rarely use DOS commands so I may be missing something in syntax. Similarly, if I want to run several successive input files with a .bat file, this work-around won't work as a line in the .bat file. I have two questions: 1) how can I make the computer recognize R so I can just type R CMD at the prompt 2) what is a work-around like I did in cygwin that will work in a .bat file or the standard command-line prompt so that you don't have to change the path variable? (often students do not have permission to add the R folder to the path variable of a networked computer, so I'd like to know an alternative if someone asks me) Thanks, Elizabeth Purdom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Generic Functions
Hi, I've been using the package graph in the BioConductor assortment and writing some functions based on its classes. My question is not specific to this package or BioConductor (I think), but it serves as a useful example. I recently wanted to look at the code for the function edgeMatrix for the class graphNEL. Usually I would type func.foo and the code for the function func for class foo would appear (where func and foo are edgeMatrix and graphNEL respectively). Similarly I would type methods(func) to see for what classes the function func is defined. However, these do not work for these functions (they are not S3 functions I am told, though I don't know what that means). After a great deal of guessing and help.search requests, I finally found functions that seem to work: getMethod(func,foo) showMethods(func) I get the corresponding code and possible methods available. What is this about and is there a section in the R language definition that explains the difference? Similarly I'm use to the object oriented program described in the R language online based on the command UseMethod: func - function(x, ...) UseMethod(func, x) Under this system, I could just create a function func.foo and it would work for my class foo -- most notably I would create a print command print.foo and it would just seamlessly work. However my function print.graphNEL, for example, never worked and I'm just now guessing from the pieces of documentation from R, that I have to set it up differently but it is not clear to me how. How can I add a method to an existing function under this setup? On another note: even if these different functions are internally quite different, can't the functions everyone is already accustomed to be made to access the properties, rather than creating new, similar functions? (what is the need for a different function showMethods when a function methods already exists? I have the same issue for slots where I have to use a function slotNames rather than the more commonly known function names). It becomes such a learning curve, that I shy away from packages that use new techniques in coding and stick with packages and functions I can comfortably dissect and personalize. Thank you for any assistance, Elizabeth Purdom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] listing datasets from all my packages
Hi, I am using R 2.1.0 on Windows XP and when I type data() to list the datasets in R, there is a helpful hint to type 'data(package = .packages(all.available = TRUE))' to see the datasets in all of the packages -- not just the active ones. However, when I do this, I get the following message: data(package = .packages(all.available = TRUE)) Error in rbind(...) : number of columns of matrices must match (see arg 2) In addition: Warning messages: 1: datasets have been moved from package 'base' to package 'datasets' in: data(package = .packages(all.available = TRUE)) 2: datasets have been moved from package 'stats' to package 'datasets' in: data(package = .packages(all.available = TRUE)) I possibly have old libraries in my R libraries because I copy them forward and update them with new versions of R, rather than redownload them. Is there a way to fix this or do the same another way? (I saw something in archives about a problem similar to this with .packages(), but I got the impression it was fixed for 2.1.0) Thanks, Elizabeth __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] name space of a package
I am trying to copy a R function (specifically boot of the boot package, but I don't think my problem is related to the specific function/package I'm using) and modify it slightly for my own use and/or understanding. For example, I want to understand why I'm getting an error from func, so I want to create a temporary function myfunc that will print out intermediate steps so I understand why my input creates an error. But when the function uses programs internal to the name space, my new function myfunc cannot find the function. I've tried attachNamespace, but it's already attached from my library() call. I know the function is around, because I can type in, for example, boot:::isMatrix and get the function. Other than inserting boot::: in front of all the problematic functions, how can I get myfunc to run? Note: If I do: myboot-boot edit(myboot) this seems to work, so I do that now. But sometimes I just want to work with it as a separate file in my editor just like any other function I would write (and I would like to understand better how the name spaces work). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] sapply behavior
Hi, I use sapply very frequently, but I have recently noticed a behavior of sapply which I don't understand and have never seen before. Basically, sapply returns what looks like a matrix, says it a matrix, and appears to let me do matrix things (like transpose). But it is also a list and behaves like a list when I subset it, not a vector (so I can't sort a row for instance). I don't know where this is coming from so as to avoid it, nor how to handle the beast that sapply is returning. I double checked my old version of R and apparently this same thing happens in 1.8.0, though I never experienced it. I had a hard time reproducing it, and I don't know what's setting it off, but the code below seems to do it for me. (I'm using R on Windows XP, either 1.8.0 or 1.9.1) Thanks for any help, Elizabeth Purdom temp2-matrix(sample(1:6,6,replace=F),byrow=F,nrow=6,ncol=4) colnames(temp2)-paste(A,as.character(1:4),sep=) temp2-as.data.frame(temp2) newtemp2-sapply((1:6),function(x){xmat-temp2[temp2[,1]==x,,drop=F];return(xmat[1,])}) print(newtemp2) #looks like matrix [,1] [,2] [,3] [,4] [,5] [,6] A1 123456 A2 123456 A3 123456 A4 123456 is.matrix(newtemp2) #says it's matrix [1] TRUE class(newtemp2) [1] matrix is.list(newtemp2) #but also list [1] TRUE newtemp2[,1] #can't subset and get a vector back; same thing happens for rows. $A1 [1] 1 $A2 [1] 1 $A3 [1] 1 $A4 [1] 1 #other things about it: names(newtemp2) NULL dimnames(newtemp2) [[1]] [1] A1 A2 A3 A4 [[2]] NULL dim(newtemp2) [1] 4 6 length(newtemp2) [1] 24 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html