Re: [R] merging matrices
Hi ?merge and if you are in reading help pages ?matrix ?data.frame and of course R-intro.pdf especially chapters about data objects and their differences. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of jim holtman Sent: Monday, October 21, 2013 5:21 PM To: Mohammad Goodarzi Cc: R mailing list Subject: Re: [R] merging matrices ?list.files ?read.table ?rbind Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Mon, Oct 21, 2013 at 6:18 AM, Mohammad Goodarzi mohammad.goda...@gmail.com wrote: Dear all, I have to load more than 1000 matrices from desktop which all of them have the same size. If I do it manually, it would be very hard, can you please guide me how to load them and merge them together ? for example I want to put them one after another X1 X2 X3 etc Many thanks, Mohammad [[alternative HTML version deleted]] __ R-help@r-project.org 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-help@r-project.org 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-help@r-project.org 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] Merging data.frames with overlapping intervals
How do I merge two data.frames with overlapping intervals? Data Frame 1 read.table(textConnection( from to Lith Form 1 0 1.2 GRN BCM 2 1.2 5.0 GDI BDI ),header=TRUE) Data Frame 2 read.table(textConnection( from to Weath Str 1 0 1.1 HW ES 2 1.1 2.9 SW VS 3 2.9 5.0 HW ST ),header=TRUE) Resulting Data Frame fromto WeathStrLithForm10.01.1HW ES GRN BCM 21.11.2SW VS GRN BCM 31.22.9SW VS GDI BDI 42.95.0HW ST GDI BDI [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] Merging data.frames with overlapping intervals
Hi Your HTML formated message was scrammbled so it is impossible to say what result you expected. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Julius Tesoro Sent: Tuesday, October 22, 2013 9:35 AM To: r-help@r-project.org Subject: [R] Merging data.frames with overlapping intervals How do I merge two data.frames with overlapping intervals? Data Frame 1 read.table(textConnection( from to Lith Form 1 0 1.2 GRN BCM 2 1.2 5.0 GDI BDI ),header=TRUE) Data Frame 2 read.table(textConnection( from to Weath Str 1 0 1.1 HW ES 2 1.1 2.9 SW VS 3 2.9 5.0 HW ST ),header=TRUE) Resulting Data Frame fromto WeathStrLithForm10.01.1HW ES GRN BCM 21.11.2SW VS GRN BCM 31.22.9SW VS GDI BDI 42.95.0HW ST GDI BDI [[alternative HTML version deleted]] __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] Quick advice on loading packages
On Mon, 21 Oct 2013 19:32:17 -0400 Data Analytics Corp. w...@dataanalyticscorp.com wrote: Hi, I need some quick advice/help on loading packages. I want to write a simple function to load a number of packages I intend to use at a conference presentation. I'm thinking of something like: fn.install - function(){install.packages(c(ggplot2, scales), repos = c:\\temp)} There will be many more than just the two I listed. All the zip files are in a Windows directory c:\temp. Will this work? Thanks, Walt Just use a short script. Install R, install the packages. To load them, write a short script, e.g. #Sets working directory and loads essential libraries. setwd([working directory here]) library(MASS, aplpack, cclust, ggplot, ...) Call that from R and provided you have everything where you've R it was, you're set. JWDougherty __ R-help@r-project.org 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.
Re: [R] RWeka and multicore package
On Thu, 17-Oct-2013 at 02:21PM -0300, Luís Paulo F. Garcia wrote: | I work very mutch with the packages RWeka and multicore. If you try to run | J48 or any tree of RWeka with multicore we hava some errors. | | Example I: | | library(RWeka); | library(multicore); | | mclapply(1:100, function(i) { | J48(Species ~., iris); | }); | | | Output: Error in .jcall(o, \Ljava/lang/Class;\, \getClass\) : \n | java.lang.ClassFormatError: Incompatible magic value 1347093252 in class | file java/lang/ProcessEnvironment$StringEnvironment\n | | | Example II: | | library(multicore); | | mclapply(1:100, function(i) { | RWeka::J48(Species ~., iris); | }); | | Output: Erro em .jcall(x$classifier, S, toString) : | RcallMethod: attempt to call a method of a NULL object. | | | Do you know some way to work with parallel processing and RWeka? I tried | MPI and SNOW without success. Not much help, but I too have not been able to get parallelling RWeka to work. OTOH, what RWeka can do is very fast compared with, say, gbm (which does work well with mclapply). I suspect that it has something to do with how Java is set up, but I know nothing about setting up Java. | | R version 3.0.2 (2013-09-25) -- Frisbee Sailing | Ubuntu 12.04 x64 | | | -- | Lu?s Paulo Faina Garcia | Engenheiro de Computa??o - Universidade de S?o Paulo | S?o Carlos - SP - Brasil | | [[alternative HTML version deleted]] | | __ | R-help@r-project.org 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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org 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.
Re: [R] R - How to physically Increase Speed
I would start with taking a subset of the data (definitely some that would run in less than 10 minutes) and use the profiler Rprof to see where time is being spent. you can use the the task monitor (if on windows) to see how much memory you are using; it sounds like you did not need the extra memory. You might see if you can partition your data so you can run multiple versions of R and then merge the results. Anything that takes more than a half hour, for me, is looked into to see where the problems are. For example dataframes arevexpensive to access and conversion to matrices is one way to speed it up. the is where the profiler helps. Sent from my iPad On Oct 21, 2013, at 19:12, Alexandre Khelifa akhel...@logitech.com wrote: Hi, My name is Alexandre Khelifa and I have been using R at my work for about 2 years. I have been working on a project when we do Monte Carlo Simulation and it involves a lot of calculations. I am currently using R x64.3.0.1 and used to work on a 4GB machine. However, the calculation time was very long (about 2 weeks), and the IT team and I decided to add more memory and to make it a 8GB virtual machine. I also added the following line in my code: * * - *options(java.parameters = -Xmx8192m) * I re-did the same calculations (4GB vs. 8GB) but did not see a significant increase in the calculation time, so I was wondering if I did anything wrong and/or what would be the best solution to increase this time. Thanks a lot for your help and more generally for building such an amazing (and free) tool. Let me know if you have any questions. Regards, Alexandre Khelifa [[alternative HTML version deleted]] __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] May I send a zip attachment to a post?
On Mon, Oct 21, 2013 at 10:51 PM, David Winsemius dwinsem...@comcast.net wrote: On Oct 21, 2013, at 2:15 PM, Hurr wrote: May I send a .zip file attached to a post? No. That's not explicit from the posting guide: No binary attachments except for PS, PDF, and some image and archive formats you have to click through to the General Instructions to see: Furthermore, most binary e-mail attachments are not accepted, i.e., they are removed from the posting completely. As an exception, we allow application/pdf, application/postscript, and image/png (and x-tar and gzip on R-devel). Maybe the posting guide should be more explicit - not that anyone reads it... Barry __ R-help@r-project.org 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] Where is element 30?
Hi I have a vector like that readCsvFile$V1 [1] 30 31 32 33 34 35 36 37 38 39 310 311 312 313 314 315 316 317 318 [20] 319 320 321 20 21 22 23 24 25 26 27 28 29 210 211 212 213 214 215 [39] 216 217 218 219 220 221 222 223 40 41 42 43 44 45 46 47 48 49 410 [58] 411 412 413 414 415 416 417 418 419 420 421 and I am looking to find where the number 31 is located. So I need one function to return me the index of where the number 31 is. Is there a function for that in R? Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] Where is element 30?
Hi, Alaios, check out ?which and in particular its Examples and See Also section. Hth -- Gerrit On Tue, 22 Oct 2013, Alaios wrote: Hi I have a vector like that readCsvFile$V1 [1] 30 31 32 33 34 35 36 37 38 39 310 311 312 313 314 315 316 317 318 [20] 319 320 321 20 21 22 23 24 25 26 27 28 29 210 211 212 213 214 215 [39] 216 217 218 219 220 221 222 223 40 41 42 43 44 45 46 47 48 49 410 [58] 411 412 413 414 415 416 417 418 419 420 421 and I am looking to find where the number 31 is located. So I need one function to return me the index of where the number 31 is. Is there a function for that in R? Regards Alex__ R-help@r-project.org 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.
Re: [R] May I send a zip attachment to a post?
Barry Rowlingson wrote On Mon, Oct 21, 2013 at 10:51 PM, David Winsemius lt; dwinsemius@ gt; wrote: On Oct 21, 2013, at 2:15 PM, Hurr wrote: May I send a .zip file attached to a post? No. That's not explicit from the posting guide: No binary attachments except for PS, PDF, and some image and archive formats you have to click through to the General Instructions to see: Furthermore, most binary e-mail attachments are not accepted, i.e., they are removed from the posting completely. As an exception, we allow application/pdf, application/postscript, and image/png (and x-tar and gzip on R-devel). Maybe the posting guide should be more explicit - not that anyone reads it... Barry __ R-help@ 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. There's really no justification for attaching *any* file to a post. Posts should be clear and concise. If there's really some value to providing an image, a hyperlink should be provided. I'd argue against any attempt to work around the intent of the posting guide, regardless of the alleged format of the attachment (remember, folks, if posting a file.pdf is allowed, you could rename your junk.zip to junk.pdf) -- View this message in context: http://r.789695.n4.nabble.com/May-I-send-a-zip-attachment-to-a-post-tp4678742p4678782.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] Error in heatmap
Do you have a row or column that is all missing? sum(apply(is.na(as.matrix(SPIV2)), 1, all)) 0 sum(apply(is.na(as.matrix(SPIV2)), 2, all)) 0 For example, this code m - as.matrix(mtcars) m[8, ] - NA heatmap(m, na.rm=TRUE) throws this error Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) Jean On Mon, Oct 21, 2013 at 1:04 PM, David Romero drom...@mda.cinvestav.mxwrote: Hi, Could you please help? Heatmap doesn't work with: heatmap(as.matrix(SPIV2),na.rm = T) Error in hclustfun(distfun(x)) : NA/NaN/Inf in foreign function call (arg 11) There are no 0 data rows or column Thanks a lot Regards --- David __ R-help@r-project.org 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. [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] XML package not working
Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something else is interfering with your downloads? Duncan Murdoch -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Saturday, October 19, 2013 8:23 PM To: Steven Dwayne Randolph; r-help@r-project.org Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-19 3:47 PM, Steven Dwayne Randolph wrote: I know I cannot be the only one who is not able to install the XML package from CRAN (zip or tar file) Many packages depend on this XML package. Can someone help me either access the source for a good binary? I have received no assistance from the author/developer of the package. It installs fine for me. Duncan Murdoch __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
I am using a sum of squared differences in the objective function of an optimization problem I am doing and I have managed to speed it up using the outer function versus the nested for loops, but my suspicion is that the calculation could be done even quicker. Please see the code below for a simple example. If anyone can point out a faster way I would appreciate it greatly. First, look at ?system.time ; it's intended for finding out how much compute time a command takes. You're also calculating elapsed time which is dependent on (among other things) other processes running so maybe not the most reliable thing for benchmarking. Second, outer() is fast because it avoids loops and uses the fastest vector routines R can (essentially, replicating the vector and then relying on simple subtraction of vectors). In principle calling outer() loses a little time in internal checks on what object types and function you've provided etc.; in practice that doesn't add up to much. You can check by using just the core code from outer with an added multiplication instead of the dimensioning statement: ssqdif - function(X, Y=X) { #From 'outer' without modification Y - rep(Y, rep.int(length(X), length(Y))) X - rep(X, times = ceiling(length(Y)/length(X))) #For this case: sum((X-Y)^2) #SLIGHTLY quicker than d-X-Y; sum(d*d) } system.time(ssqdif(X)) #Comparing outer() method: system.time({gg - outer(X, X, FUN=-); sum(gg*gg)}) There's little practical difference; both hover from 0.00 to 0.03 s system time. I could barely tell the difference even averaged over 100 runs; I was getting an average around 0.007 (system time) and 2.5s user time for both methods. Conclusion: hard to beat outer() for this purpose in R S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's suggestion of dist() or Rccp. Nice indeed. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
Actually, you don't need to use c() in the dist example, either, which should shave off a few microseconds for a function call. It was late last night ... Ken On 22-10-2013 15:08, S Ellison wrote: Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's suggestion of dist() or Rccp. Nice indeed. S Ellison *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK -- Kenneth Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org 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.
Re: [R] How do I use simple calls to java methods?
I am surprised to not get a reply. I suppose this means that extremely few, if any, use rJava. rJava.pdf says this, but I am too stupid to interpret it: Description .jcall calls a Java method with the supplied arguments. Usage .jcall(obj, returnSig = V, method, ..., evalArray = TRUE, evalString = TRUE, check = TRUE, interface = RcallMethod, simplify = FALSE, use.true.class = FALSE) Perhaps it means that to replace: calCk - calStgOfLinTim(linTm,tlev) and use something like: calCk - .jcall(CalqsLin.class,returnSig = S, calStgOfLinTim(linTm,tlev),evalArray=FALSE, evalString = TRUE, check = TRUE, interface = RcallMethod, simplify = FALSE, use.true.class = TRUE) I suppose there are other setup things to do, like start the JVM (java Virtual machine) and I don't know what obj means. Anyway, if I am able to do these simple java method calls, it will be a big plus to our data analysis lab to use R conveniently. Please help -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-use-simple-calls-to-java-methods-tp4678753p4678786.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] More Columns than column names Error
What is the exact code you are using to try to load this file? I strongly suspect the problem is a mixture of spaces and multiple tabs in your text file. -- View this message in context: http://r.789695.n4.nabble.com/More-Columns-than-column-names-Error-tp4678770p4678787.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
Thanks for the Rccp example Ken! I vaguely knew about Rccp, but I didn't realize how easy it was to use it. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Kenneth Knoblauch Sent: Tuesday, October 22, 2013 9:13 AM To: S Ellison Cc: r-help@r-project.org Subject: Re: [R] speeding up sum of squared differences calculation Actually, you don't need to use c() in the dist example, either, which should shave off a few microseconds for a function call. It was late last night ... Ken On 22-10-2013 15:08, S Ellison wrote: Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's suggestion of dist() or Rccp. Nice indeed. S Ellison *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK -- Kenneth Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] XML package not working
On 13-10-22 9:19 AM, Steven Dwayne Randolph wrote: Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into ‘C:/Users/xxx/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified) trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/XML_3.98-1.1.zip' Content type 'application/zip' length 4287270 bytes (4.1 Mb) opened URL downloaded 4.1 Mb Warning in install.packages : downloaded length 4276224 != reported length 4287270 Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection Read the message: your download is failing. The file is being mangled during the download. I just tried from the same mirror, and it was fine. As I said before, there is something wrong on your system that is messing up file transfers. You could try downloading the file some other way, and confirming that the length comes out to 4287270. Duncan Murdoch -- STeven -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, October 22, 2013 8:09 AM To: Steven Dwayne Randolph Cc: Duncan Murdoch; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something else is interfering with your downloads? Duncan Murdoch -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Saturday, October 19, 2013 8:23 PM To: Steven Dwayne Randolph; r-help@r-project.org Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-19 3:47 PM, Steven Dwayne Randolph wrote: I know I cannot be the only one who is not able to install the XML package from CRAN (zip or tar file) Many packages depend on this XML package. Can someone help me either access the source for a good binary? I have received no assistance from the author/developer of the package. It installs fine for me. Duncan Murdoch __ R-help@r-project.org 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
Re: [R] More Columns than column names Error
Carl is right. Going to the nabble post and looking in the source data file http://r.789695.n4.nabble.com/file/n4678770/Garbage.txt I see the headings row has 'Material' tab 'Weight...' tab 'Percent'. Each of the data rows has 1 tab character between the 'Material' and 'Weight' columns and 3 tab characters between the 'Weight...' and 'Percent' columns. On 22/10/2013 14:15, Carl Witthoft wrote: What is the exact code you are using to try to load this file? I strongly suspect the problem is a mixture of spaces and multiple tabs in your text file. -- View this message in context: http://r.789695.n4.nabble.com/More-Columns-than-column-names-Error-tp4678770p4678787.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] More Columns than column names Error
Hi, Try: lines1 - readLines(Garbage.txt,warn=FALSE) dat1 - read.table(text=gsub(\t+,\t,lines1),stringsAsFactors=FALSE,sep=\t,check.names=FALSE,header=TRUE) str(dat1) #'data.frame': 10 obs. of 3 variables: # $ Material : chr Food Scraps Glass Metals Paper ... # $ Weight(Million Tons): num 25.9 12.8 18 86.7 24.7 ... # $ Percent : num 11.2 5.5 7.8 37.4 10.7 6.8 5.5 11.9 3.2 100 jpeg(garbageweight.jpg,width=800) barplot(dat1[-10,2],names.arg=dat1[-10,1],ylab=colnames(dat1)[2],col=rainbow(9),main=American garbage) dev.off() A.K. Hello guys, I'm having this weird problem with my assignment. I can't seem to import the data that I have created. I keep getting an error that says Error: More Columns than Column names This is my data file. Garbage.txt Was also wondering if you guys could send me into the right direction on how to do this. 1. Create a data frame with the data given above. 2. Create the bar plot for weight variable with appropriate labels. Resize the graphics panel/ window so that all labels are visible. 3. Add colors. Suppose n is the number of bars. barplot(..., col = rainbow(n)) 4. Save the plot to garbageweight.jpg This is how it's supposed to look like at the end. __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
There's little practical difference; both hover from 0.00 to 0.03 s system time. I could barely tell the difference even averaged over 100 runs; I was getting an average around 0.007 (system time) and 2.5s user time for both methods. It's almost always better to use a high precision timer, as implemented in the microbenchmark package: library(microbenchmark) ssqdif - function(X, Y=X) { #From 'outer' without modification Y - rep(Y, rep.int(length(X), length(Y))) X - rep(X, times = ceiling(length(Y)/length(X))) #For this case: sum((X-Y)^2) #SLIGHTLY quicker than d-X-Y; sum(d*d) } outerdif - function(X, Y = X) { gg - outer(X, Y, FUN=-) sum(gg*gg) } X - runif(1000) microbenchmark( ssqdif(X), outerdif(X) ) Unit: milliseconds expr min lq median uq max neval ssqdif(X) 9.035473 9.912253 14.65940 16.34044 68.30620 100 outerdif(X) 8.962955 9.647820 14.85338 17.00048 66.89351 100 Looking at the range of values you can see indeed that the performance is indeed almost identical. Hadley -- Chief Scientist, RStudio http://had.co.nz/ __ R-help@r-project.org 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.
Re: [R] R - How to physically Increase Speed
The advice given is sensible. For a timing study see http://rwiki.sciviews.org/doku.php?id=tips:rqcasestudy We found that for optimization calculations, putting the objective function calculation or parts thereof in Fortran was helpful. But we kept those routines pretty small -- less than a page -- and we just called them to evaluate things, avoiding passing around information back and forth to R. JN On 13-10-22 06:00 AM, r-help-requ...@r-project.org wrote: Message: 58 Date: Tue, 22 Oct 2013 05:47:15 -0400 From: Jim Holtman jholt...@gmail.com To: Alexandre Khelifa akhel...@logitech.com Cc: r-help@r-project.org r-help@r-project.org Subject: Re: [R] R - How to physically Increase Speed Message-ID: 73d989da-b6b3-421d-838c-903da3435...@gmail.com Content-Type: text/plain; charset=us-ascii I would start with taking a subset of the data (definitely some that would run in less than 10 minutes) and use the profiler Rprof to see where time is being spent. you can use the the task monitor (if on windows) to see how much memory you are using; it sounds like you did not need the extra memory. You might see if you can partition your data so you can run multiple versions of R and then merge the results. Anything that takes more than a half hour, for me, is looked into to see where the problems are. For example dataframes arevexpensive to access and conversion to matrices is one way to speed it up. the is where the profiler helps. __ R-help@r-project.org 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.
Re: [R] How do I use simple calls to java methods?
I don't use rJava, but numerous examples came up when I Googled for rjava examples. The fact that you have not referenced any of that material may be leaving a bad taste in the mouths of those few people who do use both R and Java. Or, they may just not spend time wading through emails on this list. Also, note that Nabble has a poor reputation on this list, because it encourages you to look at Nabble for message history rather than including it in the email. Please re-read the Posting Guide for this list. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Hurr hill0...@umn.edu wrote: I am surprised to not get a reply. I suppose this means that extremely few, if any, use rJava. rJava.pdf says this, but I am too stupid to interpret it: Description .jcall calls a Java method with the supplied arguments. Usage .jcall(obj, returnSig = V, method, ..., evalArray = TRUE, evalString = TRUE, check = TRUE, interface = RcallMethod, simplify = FALSE, use.true.class = FALSE) Perhaps it means that to replace: calCk - calStgOfLinTim(linTm,tlev) and use something like: calCk - .jcall(CalqsLin.class,returnSig = S, calStgOfLinTim(linTm,tlev),evalArray=FALSE, evalString = TRUE, check = TRUE, interface = RcallMethod, simplify = FALSE, use.true.class = TRUE) I suppose there are other setup things to do, like start the JVM (java Virtual machine) and I don't know what obj means. Anyway, if I am able to do these simple java method calls, it will be a big plus to our data analysis lab to use R conveniently. Please help -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-use-simple-calls-to-java-methods-tp4678753p4678786.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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-help@r-project.org 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] colour code areas of a plot
Hi, I would like to colour different areas of a plot. But I don't know how to do this efficiently. As an example; lets say three stimuli were presented in an experiment, alternating, one at a time. Now I want to plot time on the x-axis and the plot-area should colour code the stimulus that was presented at that time interval (green for stimulus 1, yellow for stimulus 2 etc.) here an example: (t = time) t - 1:100 bg_colors - c(rep('green',20), rep('yellow',10), rep('green',20), rep('red',5), rep('yellow',45)) color_scheme - data.frame(t, bg_colors) plot(c(), c(), xlim = c(1,100), ylim=c(-1,1)) rect(xleft = 1, ybottom = -1, xright = 20, ytop = 1, col = 'green', lwd=0) rect(xleft = 20, ybottom = -1, xright = 30, ytop = 1, col = 'yellow', lwd=0) … now how can I do this efficiently based on the color_scheme data-frame and without having to manually draw all the rectangles as in the example above? thanks for any suggestions! __ R-help@r-project.org 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.
Re: [R] colour code areas of a plot
Martin Batholdy batholdy at googlemail.com writes: I would like to colour different areas of a plot. But I don't know how to do this efficiently. here an example: (t = time) t - 1:100 bg_colors - c(rep('green',20), rep('yellow',10), rep('green',20), rep('red',5), rep('yellow',45)) color_scheme - data.frame(t, bg_colors) plot(c(), c(), xlim = c(1,100), ylim=c(-1,1)) rect(xleft = 1, ybottom = -1, xright = 20, ytop = 1, col = 'green', lwd=0) rect(xleft = 20, ybottom = -1, xright = 30, ytop = 1, col = 'yellow', lwd=0) … now how can I do this efficiently based on the c olor_scheme data-frame and without having to manually draw all the rectangles as in the example above? The first 4 arguments of rect can be vectors as can be the col argument. So you might be able to draw all of the regions with a single call to rect. I've done this to create alternating light and dark regions to highlight condition changes. See ?rect, of course. thanks for any suggestions! -- Kenneth Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org 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.
Re: [R] XML package not working
Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something else is interfering with your downloads? Duncan Murdoch -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Saturday, October 19, 2013 8:23 PM To: Steven Dwayne Randolph; r-help@r-project.org Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-19 3:47 PM, Steven Dwayne Randolph wrote: I know I cannot be the only one who is not able to install the XML package from CRAN (zip or tar file) Many packages depend on this XML package. Can someone help me either access the source for a good binary? I have received no assistance from the author/developer of the package. It installs fine for me. Duncan Murdoch __ R-help@r-project.org 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.
Re: [R] [ADMB Users] R2admb compile problem
Hello guys Arni, you were correct. The R search path contained 'C:/MinGW/bin;' which contains a g++ compiler. I removed it and now it works fine! Thank you for the help. Just for completeness sake: (the R code and output is included below) # require(R2admb) setup_admb() [1] c:\\ADMB\\admb101-gcc452-win64 fn=Function1 compile_admb(fn, verbose=T) compiling with args: ' ' ... compile output: *** tpl2cpp Function1 xxglobal.tmp xxhtop.tmp header.tmp xxalloc.tmp xxtopm.tmp 1 file(s) copied. *** adcomp Function1 g++ -c -O3 -Wno-deprecated -D__GNUDOS__ -Dlinux -DOPT_LIB -DUSE_LAPLACE -fpermissive -I. -Ic:\ADMB\admb101-gcc452-win64\include -o Function1.obj Function1.cpp *** adlink Function1 g++ -s -static -Lc:\ADMB\admb101-gcc452-win64\lib Function1.obj -ldf1b2o -ladmod -ladt -lado -ldf1b2o -ladmod -ladt -lado -o Function1 Done compile log: run_admb(fn) results - read_admb(fn) results Model file: Function1 Negative log-likelihood: 0 Coefficients: x 5 clean_admb(fn) #= I am not sure why 'C:/MinGW/bin;' is in the R search path since it it not in any of the environment variables? regards On 21 October 2013 15:56, Ben Bolker bbol...@gmail.com wrote: On 13-10-21 09:53 AM, Arni Magnusson wrote: I've seen similar linking errors when there's more than one compiler in the PATH, causing a version conflict. In this case, the solution is to remove all but one compiler from the PATH. Arni So in this respect, to see what's going on in the within-R2admb/R context, you should run Sys.getenv(PATH) and compare it with whatever the equivalent command for examining the PATH environment variable is in Windows (I don't know, my Windows skills are really rusty) On 13-10-21 05:48 AM, Ben Stevenson wrote: Hi Allan, Given that ADMB seems to be working fine on its own, you're probably better off asking this question to an R2admb package maintainer as only a few people here use R2admb. R2admb uses the system() R function to in order to compile the .tpl file. My guess is that it is not finding the admb command, and this will be something to do with environment variables. What happens when you run system(admb) in R? Do you get an error saying about the admb command not being found? This would confirm my suspicion. If this is the case, find where the admb binary is on your system. From the output of setup_admb, my guess is that it's in c:\\ADMB\\admb101-gcc452-win64\\bin. If you call Sys.getenv(PATH), does this directory appear? Cheers, Ben On Mon, 21 Oct 2013, Ben Bolker wrote: I am the R2admb package maintainer -- I saw this message go by on the R mailing list as well. The only clue I have here is that something is going wrong with the linking -- that's what's indicated by the last line you included in your R-help message, 'collect2: ld returned 1 exit status' Can you provide more of the 'verbose' output? I wonder if there is an environment variable related to linking that's set in your external environment but not within R. (Do you have spaces in any of your path names ... ?) You can respond to the list or e-mail me off-list (my e-mail is available via maintainer(R2admb) ... ___ Users mailing list us...@admb-project.org http://lists.admb-project.org/mailman/listinfo/users ___ Users mailing list us...@admb-project.org http://lists.admb-project.org/mailman/listinfo/users [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] colour code areas of a plot
On Tue, 22 Oct 2013 16:43:18 +0200 Martin Batholdy batho...@googlemail.com wrote: Hi, you should replace your color names by calls to the rgb() function in order to generate the adequate colors, something like: bg_colors - c(rep (rgb (0,1,0),20), rep (rgb (0,1,1),10), rep (rgb (0,1,0),20), rep(rgb (1,0,0),5), rep(rgb (1,1,0),45)) (though it should obviously be automatically extracted from your data I suppose). Then it is possible to use the color vector as an option to any plotting command e.g.: plot(color_scheme$t, color_scheme$t,col=bg_colors) or (something like): rect(xleft = color_scheme$t[1:99], ybottom = -1, xright = color_scheme$t [2:100], ytop = 1, col=bg_colors, lwd=0) Olivier. Hi, I would like to colour different areas of a plot. But I don't know how to do this efficiently. As an example; lets say three stimuli were presented in an experiment, alternating, one at a time. Now I want to plot time on the x-axis and the plot-area should colour code the stimulus that was presented at that time interval (green for stimulus 1, yellow for stimulus 2 etc.) here an example: (t = time) t - 1:100 bg_colors - c(rep('green',20), rep('yellow',10), rep('green',20), rep ('red',5), rep('yellow',45)) color_scheme - data.frame(t, bg_colors) plot(c(), c(), xlim = c(1,100), ylim=c(-1,1)) rect(xleft = 1, ybottom = -1, xright = 20, ytop = 1, col = 'green', lwd=0) rect(xleft = 20, ybottom = -1, xright = 30, ytop = 1, col = 'yellow', lwd=0) … now how can I do this efficiently based on the color_scheme data-frame and without having to manually draw all the rectangles as in the example above? thanks for any suggestions! __ R-help@r-project.org 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. -- Olivier Crouzet, PhD Laboratoire de Linguistique -- EA3827 Université de Nantes Chemin de la Censive du Tertre - BP 81227 44312 Nantes cedex 3 France phone:(+33) 02 40 14 14 05 (lab.) (+33) 02 40 14 14 36 (office) fax: (+33) 02 40 14 13 27 e-mail: olivier.crou...@univ-nantes.fr http://www.lling.univ-nantes.fr/ __ R-help@r-project.org 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.
Re: [R] list and -
Many thanks:) I have a list(), eg. named opt, I want to check and assign values to it: if(is.null(opt$a)) opt$a = 'x' if(is.null(opt$b)) opt$a = 'y' ... I need to do a lot of these jobs, so I write a function to simplify it: '%=%' = function(x, y){ if(is.null(x)) { x - y } } x=NULL y=list() is.null(x) [1] TRUE is.null(y$a) [1] TRUE x %=% 1; x [1] 2 y$a %=% 2; ## Can't assign 2 to y$a, still NULL y$a NULL On Mon, Oct 21, 2013 at 11:38 PM, Greg Snow 538...@gmail.com wrote: See fortune(174). It is best to avoid using '-', if you tell us what you are trying to accomplish then we may be able to provide a better means to accomplish it. On Sat, Oct 19, 2013 at 10:28 PM, Taiyun Wei weitai...@gmail.com wrote: Dear All, opt = list() opt$aa - TRUE Error in opt$aa - TRUE : object 'opt' not found Why? -- Regards, Taiyun -- Taiyun Wei weitai...@gmail.com Homepage: http://blog.cos.name/taiyun/ Phone: +86-15201142716 Renmin University of China __ R-help@r-project.org 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com -- Regards, Taiyun -- Taiyun Wei weitai...@gmail.com Homepage: http://blog.cos.name/taiyun/ Phone: +86-15201142716 Renmin University of China [[alternative HTML version deleted]] __ R-help@r-project.org 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] integer - factor
Hi! I have a dataset composed by bmi, sex, age, and race. I have to convert bmi, sex and race in factor and they have still to be in the same dataset with their names. That's because I need to do an Ordered Logistic Regression. Can you help me? really tnx! -- View this message in context: http://r.789695.n4.nabble.com/integer-factor-tp4678778.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] XML package not working
Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into ‘C:/Users/xxx/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified) trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/XML_3.98-1.1.zip' Content type 'application/zip' length 4287270 bytes (4.1 Mb) opened URL downloaded 4.1 Mb Warning in install.packages : downloaded length 4276224 != reported length 4287270 Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection -- STeven -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, October 22, 2013 8:09 AM To: Steven Dwayne Randolph Cc: Duncan Murdoch; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something else is interfering with your downloads? Duncan Murdoch -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Saturday, October 19, 2013 8:23 PM To: Steven Dwayne Randolph; r-help@r-project.org Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-19 3:47 PM, Steven Dwayne Randolph wrote: I know I cannot be the only one who is not able to install the XML package from CRAN (zip or tar file) Many packages depend on this XML package. Can someone help me either access the source for a good binary? I have received no assistance from the author/developer of the package. It installs fine for me. Duncan Murdoch __ R-help@r-project.org 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.
Re: [R] integer - factor
Hi, You should probably start by reading ?factor Sarah On Tue, Oct 22, 2013 at 5:50 AM, luana luana.pap...@libero.it wrote: Hi! I have a dataset composed by bmi, sex, age, and race. I have to convert bmi, sex and race in factor and they have still to be in the same dataset with their names. That's because I need to do an Ordered Logistic Regression. Can you help me? really tnx! -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org 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.
Re: [R] cor matrix in multivariate regression
Suyan Tian st...@mail.rockefeller.edu on Tue, 22 Oct 2013 01:18:10 + writes: Sorry to bother, I want to construct a correlation matrix in multivariate regression (several dependent variables and they are correlated in some ways) like the followings, 1 0.8 0 0 … 0 0 0.8 1 0 0 …0 0 00 1 0.8 … 0 0 0 0 0.8 1 … 0 0 . . . . …. . .. . 0 0 1 0.8 0 0 0.8 1 Does anyone know how to do it? Of course, with many such problems in R, there are *many* ways. I believe one of the nicest ways here is to use toeplitz() : n - 12 ## or whatever your n is toeplitz(c(1,0.8, rep(0, n-2))) Note that for larger n, under some circumstances it may be beneficial to use the Matrix package and its *sparse* matrices, e.g., require(Matrix) n - 12; toeplitz(as(c(1,0.8, rep(0, n-2)), sparseVector)) 12 x 12 sparse Matrix of class dsCMatrix [1,] 1.0 0.8 . . . . . . . . . . [2,] 0.8 1.0 0.8 . . . . . . . . . [3,] . 0.8 1.0 0.8 . . . . . . . . [4,] . . 0.8 1.0 0.8 . . . . . . . [5,] . . . 0.8 1.0 0.8 . . . . . . [6,] . . . . 0.8 1.0 0.8 . . . . . [7,] . . . . . 0.8 1.0 0.8 . . . . [8,] . . . . . . 0.8 1.0 0.8 . . . [9,] . . . . . . . 0.8 1.0 0.8 . . [10,] . . . . . . . . 0.8 1.0 0.8 . [11,] . . . . . . . . . 0.8 1.0 0.8 [12,] . . . . . . . . . . 0.8 1.0 Best regards, Martin Maechler, ETH Zurich __ R-help@r-project.org 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.
Re: [R] integer - factor
... and ?ordered for bmi. And if the OP has not already done so, read An Introduction to R or other web tutorial and stop posting such basic questions here. Cheers, Bert On Tue, Oct 22, 2013 at 8:21 AM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi, You should probably start by reading ?factor Sarah On Tue, Oct 22, 2013 at 5:50 AM, luana luana.pap...@libero.it wrote: Hi! I have a dataset composed by bmi, sex, age, and race. I have to convert bmi, sex and race in factor and they have still to be in the same dataset with their names. That's because I need to do an Ordered Logistic Regression. Can you help me? really tnx! -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org 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. -- Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 __ R-help@r-project.org 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.
Re: [R] Am I working with regularly spaced time series?
On 13-10-22 06:00 AM, Weiwu Zhang zhangwe...@realss.com wrote: My data is sampled once per minute. At the same second each minute or not? Regularly spaced would mean exactly one minute between observations. There are invalid samples, leaving a lot of holes in the samples, successful sample is around 80% of all minutes in a day. and during the last 4 months sampling, one month's data was stored on a harddisk that failed, leaving a month's gap in between. This is called missing observations. With regular spacing you need to fill in the holes with NA. With irregular spacing you can either drop the missing observations or, if you know the time at which they were missed, you could fill in with NA. So am I working with regularly spaced time series or not? Should I padd all missing data with NAs, and start with ts(), and followed by forecast package (which seems to have all the functions I need in the begining) or should I start with a library with irregular time series in mind? Also, ts() manual didn't say how to create time-series with one minute as daltat. Its seems to assume time-series is about dates. So the data I have with me, is it really time series at all? ts() representations works best with regularly spaced monthly, quarterly, or annual data. You can use it for other things if they fit nicely into the regular spaced observations with a frequency of observation, such as 12 times per year or 60 times per hour. This usually only makes sense if the frequency has something to do with your problem, like seasonality questions. You can also use frequency 1 for one observation per period, like annual data, which in your case would be once per minute. I'm inclined to think that a zoo (see package zoo) represenation would fit your problem better. HTH, Paul Newbie question indeed. Thanks. __ R-help@r-project.org 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.
Re: [R] Am I working with regularly spaced time series?
On Tue, Oct 22, 2013 at 11:37 AM, Paul Gilbert pgilbert...@gmail.com wrote: On 13-10-22 06:00 AM, Weiwu Zhang zhangwe...@realss.com wrote: My data is sampled once per minute. At the same second each minute or not? Regularly spaced would mean exactly one minute between observations. There are invalid samples, leaving a lot of holes in the samples, successful sample is around 80% of all minutes in a day. and during the last 4 months sampling, one month's data was stored on a harddisk that failed, leaving a month's gap in between. This is called missing observations. With regular spacing you need to fill in the holes with NA. With irregular spacing you can either drop the missing observations or, if you know the time at which they were missed, you could fill in with NA. So am I working with regularly spaced time series or not? Should I padd all missing data with NAs, and start with ts(), and followed by forecast package (which seems to have all the functions I need in the begining) or should I start with a library with irregular time series in mind? Also, ts() manual didn't say how to create time-series with one minute as daltat. Its seems to assume time-series is about dates. So the data I have with me, is it really time series at all? ts() representations works best with regularly spaced monthly, quarterly, or annual data. You can use it for other things if they fit nicely into the regular spaced observations with a frequency of observation, such as 12 times per year or 60 times per hour. This usually only makes sense if the frequency has something to do with your problem, like seasonality questions. You can also use frequency 1 for one observation per period, like annual data, which in your case would be once per minute. I'm inclined to think that a zoo (see package zoo) represenation would fit your problem better. Also note that the zoo package has two classes: 1. zoo for irregularly spaced series 2. zooreg for series with an underlying regularity but for which some of the points are missing (which seems to be the situation under discussion) The two classes are nearly the same but zooreg series have a frequency and some methods act differently -- most notably lag and diff. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org 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.
Re: [R] list and -
Look carefully at your output (and I don't think that you are showing us the output of what you actually ran in the order that you ran it). After running `x %=% 1` you should see that x has the value `1`, but your output shows `2`, this is the result of the next command `y$a %=% 2`, see the `-` assignment will always assign to `x`, not to the variable named in the local variable x. An operator like %=% should be used to somehow combine its 2 arguments and return the result, not ever change a variable value. The job of assigning the result should go to the user/caller. You could possibly create a new class and an assignment method for that class that would work like the assignment. If you can give us more of an idea of what your ultimate goal is then we may be able to help you find a better approach. On Tue, Oct 22, 2013 at 2:04 AM, Taiyun Wei weitai...@gmail.com wrote: Many thanks:) I have a list(), eg. named opt, I want to check and assign values to it: if(is.null(opt$a)) opt$a = 'x' if(is.null(opt$b)) opt$a = 'y' ... I need to do a lot of these jobs, so I write a function to simplify it: '%=%' = function(x, y){ if(is.null(x)) { x - y } } x=NULL y=list() is.null(x) [1] TRUE is.null(y$a) [1] TRUE x %=% 1; x [1] 2 y$a %=% 2; ## Can't assign 2 to y$a, still NULL y$a NULL On Mon, Oct 21, 2013 at 11:38 PM, Greg Snow 538...@gmail.com wrote: See fortune(174). It is best to avoid using '-', if you tell us what you are trying to accomplish then we may be able to provide a better means to accomplish it. On Sat, Oct 19, 2013 at 10:28 PM, Taiyun Wei weitai...@gmail.com wrote: Dear All, opt = list() opt$aa - TRUE Error in opt$aa - TRUE : object 'opt' not found Why? -- Regards, Taiyun -- Taiyun Wei weitai...@gmail.com Homepage: http://blog.cos.name/taiyun/ Phone: +86-15201142716 Renmin University of China __ R-help@r-project.org 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com -- Regards, Taiyun -- Taiyun Wei weitai...@gmail.com Homepage: http://blog.cos.name/taiyun/ Phone: +86-15201142716 Renmin University of China -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org 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.
Re: [R] speeding up sum of squared differences calculation
outer() and dist() are good for speed on smaller problems but they require O(length(X)^2) memory. This can slow things down or even stop the calculations for large problems. You can gain a lot of speed without the memory problem by summing things up in chunks. E.g., On a Linux box I compared fChunk - function(x) { ans - 0 for(i in seq_along(x)[-1]) { ans - ans + sum( (x[i] - x[seq_len(i-1)])^2) } 2*ans } with the original algorithm (slightly cleaned up) fOrig -function (x) { ans - 0 for (i in seq_along(x)[-1]) { for (j in seq_len(i)) { ans - ans + (x[i] - x[j])^2 } } 2 * ans } and the ones based on outer() and dist(). fOuter - function(x) sum(outer(x, x, FUN=`-`)^2) fDist - function(x) 2 * sum(dist(x)^2) for a vector of length 1. z - rnorm(10^4) t(sapply(list(fOrig=fOrig, fChunk=fChunk, fDist=fDist, fOuter=fOuter), function(f)tryCatch(system.time(f(z)), error=function(e)NA)[1:3])) user.self sys.self elapsed fOrig 90.2620.000 90.378 fChunk 0.7760.004 0.779 fDist 1.0920.276 1.370 fOuter 0.7401.068 1.855 They all give slightly different answers because the round-off error depends on the order in which sums and squares are done. Of course, the Rcpp version has no memory penalty and is faster than any of them. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of S Ellison Sent: Tuesday, October 22, 2013 6:08 AM To: r-help@r-project.org Cc: Ken Knoblauch Subject: Re: [R] speeding up sum of squared differences calculation Conclusion: hard to beat outer() for this purpose in R ... unless you use Ken Knoblauch's suggestion of dist() or Rccp. Nice indeed. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] XML package not working
On 22-10-2013, at 15:19, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into ‘C:/Users/xxx/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified) trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.0/XML_3.98-1.1.zip' Content type 'application/zip' length 4287270 bytes (4.1 Mb) opened URL downloaded 4.1 Mb Warning in install.packages : downloaded length 4276224 != reported length 4287270 Look at what is reported here. The downloaded length is not equal to the reported (i.e. actual) length of the zip. What is the length if you download the .zip file manually? So something has gone wrong with the download. Can you open a .zip file in another program? If so see what happens if you open it in that program. You have to do detective work. Berend Warning in install.packages : error 1 in extracting from zip file Warning in install.packages : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' Error in install.packages : cannot open the connection -- STeven -Original Message- From: Ista Zahn [mailto:istaz...@gmail.com] Sent: Tuesday, October 22, 2013 8:09 AM To: Steven Dwayne Randolph Cc: Duncan Murdoch; r-help@r-project.org; stevendrando...@aol.com; Piyush Singh - Network Subject: Re: [R] XML package not working Hi Steven, I still don't understand why you are downloading it manually. What happens when you install.packages(XML) ? Best, Ista On Tue, Oct 22, 2013 at 8:03 AM, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Duncan... Thank you. 1. I am able to download the XML file via my corporate network, other packages without this same issue, even rcurl and bitops which are pre-requisites on the same page as XML. 2. I have attempted to download this from my own wifi at home using xfinity/Comcast to my personal pc and still get the same error on this package alone. 3. I am genuinely baffled by this package download and install experience. 4. I would gladly build this from source, If indeed I could find the source and then use RTools to compile it. That has been unsuccessful as well. Nightmare? Slightly. Thanks for your response. Steven -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Sunday, October 20, 2013 12:13 PM To: Steven Dwayne Randolph; r-help@r-project.org; Ista Zahn Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-20 9:23 AM, Steven Dwayne Randolph wrote: My apologies for not conforming to the posting guideline. Sys.info() sysname release version Windows 7 x64 build 7601, Service Pack 1 nodename machine login xxNU247BZ1S x86-64 XX user effective_user xxxxxx When I attempt to install a local copy of the xml.zip file: in read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open the connection In addition: Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, DESCRIPTION), c(Package, Type)) : cannot open compressed file 'XML/DESCRIPTION', probable reason 'No such file or directory' I think it is pretty clear that the problem is at your end: you aren't downloading the file properly, even though everyone else is. Perhaps you are behind a firewall, or something else is interfering with your downloads? Duncan Murdoch -Original Message- From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] Sent: Saturday, October 19, 2013 8:23 PM To: Steven Dwayne Randolph; r-help@r-project.org Cc: stevendrando...@aol.com Subject: Re: [R] XML package not working On 13-10-19 3:47 PM, Steven Dwayne Randolph wrote: I know I cannot be the only one who is not able to install the XML package from CRAN (zip or tar file) Many packages depend on this XML package. Can someone help me either access the source for a good binary? I have received no assistance from the author/developer of the package. It installs fine for me. Duncan Murdoch __ R-help@r-project.org mailing list
[R] [R-pkgs] scholar 0.1.0 on CRAN
Dear R users, A new package 'scholar' (version 0.1.0) is now available on CRAN: http://cran.r-project.org/web/packages/scholar/index.html. The scholar package provides functions to extract citation data from Google Scholar. In addition to retrieving basic information about a single scholar, the package also allows you to compare multiple scholars and predict future h-index values based on the method of Acuna et al. For example, we can compare the careers of Richard Feynman and Stephen Hawking as follows: ids - c('B7vSqZsJ', 'qj74uXkJ') df - compare_scholar_careers(ids) ggplot(df, aes(x=career_year, y=cites)) + geom_line(aes(linetype=name)) For more information and examples of how to use the package, please see https://github.com/jkeirstead/scholar. Your comments and suggestions would be appreciated. Best wishes, James -- Dr James Keirstead Lecturer Dept of Civil and Environmental Engineering Imperial College South Kensington, London SW7 2AZ ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org 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] Hdf files Download
I am triing one more time since my first message was rejected by the filter: Dear all, I need to download and process large amounts of MODIS surface reflectance imagery. I have adapted a script written by T. Hengl ( http://www.spatial-analyst.net/wiki/?title=Download_and_resampling_of_MODIS _images http://www.spatial-analyst.net/wiki/?title=Download_and_resampling_of_MODIS_ images) for download from the new HTTP (since FTP is no longer available). The downloaded .HDF files however have no headers and it is impossible to work with them. If I download directly from the webpage everything is fine. Does anyone know what the problem might be, please? I am attaching my code Please it is urgent. Thanks a lot. __ R-help@r-project.org 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] How to draw figures in a graph?
Hi All, Hope you guys are doing well. I am thinking of drawing some figures within a graph to make it more interesting. To make a graph more storytelling, like the attached one. I am looking for a couple of days but couldn't come up with any solution on how to do it with R. Any ideas will be greatly appreciated. Thanks, --- Md. Abdul Halim Assistant Professor Department of Forestry and Environmental Science Shahjalal University of Science and Technology,Sylhet-3114, Bangladesh. Cell: +8801714078386. alt. e-mail: xo...@yahoo.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. attachment: Sample graph.png__ R-help@r-project.org 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] Graphing complex functions
Does R have any facilities, or packages, for graphing complex functions? I find that 'curve' does not do the trick. Example: f = function(x) cos(x) + 1i * sin(x) curve(f, -pi, pi) Error in xy.coords(x, y, xlabel, ylabel, log) : (converted from warning) imaginary parts discarded in coercion Enter a frame number, or 0 to exit 1: curve(f, -pi, pi) 2: plot(x = x, y = y, type = type, xlab = xlab, ylab = ylab, xlim = xlim, log = lg, ...) 3: plot.default(x = x, y = y, type = type, xlab = xlab, ylab = ylab, xlim = xlim, log = lg, ...) 4: xy.coords(x, y, xlabel, ylabel, log) 5: .signalSimpleWarning(imaginary parts discarded in coercion, quote(xy.coords(x, y, xlabel, ylabel, log))) 6: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 7: withOneRestart(expr, restarts[[1]]) 8: doWithOneRestart(return(expr), restart) 9: (function () { error() utils::recover() })() Selection: [[alternative HTML version deleted]] __ R-help@r-project.org 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] nls model definition help
Hi fellow R users, I'm trying to fit a model using nls with the following model definition: y(t+1)=(th1*x1 + R1*x2) * exp(a1*x3) + (1-th1*x1 + R1*x2)*y(t) y is the dependent variable (note on both sides of eq) and the x's represent the regressors. th1, R1 and a1 are parameters to be estimated. The problem is non- linear and hence why I'm trying to fit using the well used nls function. To fit the model I would like to be able to use the formula interface rather than build my own ugly function definition. Any ideas if this is achievable and if not any ideas on how to fit this model? Many thanks, Wayne Wayne Jones Statistics Chemometrics Shell Global Solutions (UK) Shell Technology Centre Thornton P.O. Box 1, Chester CH1 3SH, United Kingdom Tel: +44 (0) 151 373 5977 Mobile: +44 (0) 7896 536026 Email: wayne.w.jo...@shell.commailto:wayne.w.jo...@shell.com Intranet: Statistics and Chemometrics - Shell Wikihttp://sww.wiki.shell.com/wiki/index.php/Statistics_and_Chemometrics Internet: Shell Global Solutionshttp://www.shell.com/globalsolutions Shell Global Solutions (UK) is a division of Shell Research Limited which has its Registered Office at Shell Centre, London SE1 7NA and is registered in England Wales with No.539964. [[alternative HTML version deleted]] __ R-help@r-project.org 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] reference class error
hi, I'm new to reference classes but as I have experience with python I decided to port some of my code in this frame work. I have the following two reference classes in separate files: #1# uvRndVar = setRefClass( Class = 'uvRndVar', fields = list( desc = 'character', type = 'character', pars = 'list', MAP = c('numeric'), post = c('numeric') ), methods = list( initialize = function (desc, type, pars) { types = c('norm', 'lnorm', 'beta', 'gamma') parameters = list(norm = c('mean', 'sd'), lnorm = c('mean', 'sd'), beta = c('shape1', 'shape2'), gamma = c('shape', 'rate')) if (!any(types == type)) { stop('not correct type provided') } else { if (length(names(pars)) == length(parameters[[type]])) { for (i in 1:length(names(pars))) { a = which(parameters[[type]] == names(pars)[i]) if (length(a)) { parameters[[type]] = parameters[[type]][-a] } else { stop(paste('parameter', names(pars)[i], 'not compatible with provided type')) } } .self$desc = desc .self$type = type .self$pars = pars .self$MAP = NaN .self$post = NaN } else { stop('parameter list provided has wrong length') } } } ) ) #2# NG = setRefClass( Class = 'NG', fields = list( Y = 'matrix', X = 'matrix', CvFun = 'Cf', CfHp = 'list', lam = 'uvRndVar', lam.upd = 'logical', A = 'array', basis = 'matrix', Y.star = 'matrix', X.star = 'matrix', lam.star = 'numeric', lam.star.upd = 'logical', A.star = 'matrix' ), methods = list( initialize = function (Y, X, Cf, CfHp, lam, A, basis) { if (nrow(Y) != nrow(X)) { stop('X and Y have different numbers of rows') } else if (dim(A)[1] != dim(A)[2]) { stop('A is not a square matrix') } else if (dim(A)[1] != nrow(basis)) { stop('basis matrix and precision matrix A have different number of rows') } else if (dim(A)[3] != nrow(X)) { stop('dim(A)[3] != nrow(X)') } else if (ncol(basis) != ncol(Y)) { stop('basis matrix and Y have different number of columns') } else { CvFun$checkModel(Y, X, CfHp) } .self$q = ncol(Y) .self$m = nrow(X) .self$p = ncol(X) .self$n = nrow(basis) .self$Y = Y .self$X = X .self$CvFun = CvFun .self$CfHp = CfHp .self$lam = lam .self$A = A .self$basis = basis } ) ) the second takes an object of the first class in two of its fields. I load the first class and then the second with the 'source' command, but then I got this error which i don't understand: Error in match(x, table, nomatch = 0L) : argument type is missing, with no default I'm working with Ubuntu 12.04 and R 3.0.2. Any suggestions about what is going wrong? Thanks in advance, Filippo __ R-help@r-project.org 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.
Re: [R] Hdf files Download
Your script didn't make it. There are restrictions on the mail list for attached files. You might try putting the script directly into the email. -Roy On Oct 22, 2013, at 9:40 AM, Tereza Smejkalova terka...@gmail.com wrote: I am triing one more time since my first message was rejected by the filter: Dear all, I need to download and process large amounts of MODIS surface reflectance imagery. I have adapted a script written by T. Hengl ( http://www.spatial-analyst.net/wiki/?title=Download_and_resampling_of_MODIS _images http://www.spatial-analyst.net/wiki/?title=Download_and_resampling_of_MODIS_ images) for download from the new HTTP (since FTP is no longer available). The downloaded .HDF files however have no headers and it is impossible to work with them. If I download directly from the webpage everything is fine. Does anyone know what the problem might be, please? I am attaching my code Please it is urgent. Thanks a lot. __ R-help@r-project.org 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. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: roy.mendelss...@noaa.gov (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ R-help@r-project.org 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.
Re: [R] Replace NA values with previous valid value in array
Hi, c1 = (1,2,3,4,5,6,NA,7,8,NA,9,10,NA) library(zoo) na.locf(c1) # [1] 1 2 3 4 5 6 6 7 8 8 9 10 10 A.K. Hi, I want to fix an array that contains several NA elements. And I would like to replace them with the previous valid element. So my array c = (1,2,3,4,5,6,NA,7,8,NA,9,10,NA) become cfixed= (1,2,3,4,5,6,6,7,8,8,9,10,10) (that's an example the actual array has thousands of elements) Thanks! __ R-help@r-project.org 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.
Re: [R] More Columns than column names Error
Hi, The Garbage.txt file you showed in the original post is slighly different (in spacing) from the one you are showing now. lines1 - readLines(Garbage.txt,warn=FALSE) lines2 - readLines(GarbageNew.txt,warn=FALSE) #saved the new as GarbageNew.txt lines1 [1] Material\tWeight(Million Tons)\tPercent [2] Food Scraps\t25.9\t\t\t11.2 [3] Glass\t\t12.8\t\t\t5.5 [4] Metals\t\t18.0\t\t\t7.8 [5] Paper\t\t86.7\t\t\t37.4 [6] Plastics\t24.7\t\t\t10.7 [7] Textiles\t15.8\t\t\t6.8 [8] Wood\t\t12.7\t\t\t5.5 [9] Yard trimmings\t27.7\t\t\t11.9 [10] Other\t\t7.5\t\t\t3.2 [11] Total\t\t231.9\t\t\t100.0 lines2 [1] Material\tWeight(Million Tons)\tPercent [2] Food Scraps\t25.9\t11.2 [3] Glass\t12.8\t5.5 [4] Metals\t18.0\t7.8 [5] Paper\t86.7\t37.4 [6] Plastics\t24.7\t10.7 [7] Textiles\t15.8\t6.8 [8] Wood\t12.7\t5.5 [9] Yard trimmings\t27.7 11.9 #here there are two delimiters \t and space [10] Other\t7.5\t3.2 [11] Total\t231.9\t100.0 Looks like you changed the tab spaces. dat1 - read.table(text=gsub(\t+,\t,lines1),stringsAsFactors=FALSE,sep=\t,check.names=FALSE,header=TRUE) #no errors #able to reproduce the error mentioned dat2 - read.table(text=gsub(\t+,\t,lines2),stringsAsFactors=FALSE,sep=\t,check.names=FALSE,header=TRUE) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 8 did not have 3 elements #Try this dat2 - read.table(text=gsub((.*\\d+) (\\d+),\\1\t\\2,lines2),stringsAsFactors=FALSE,sep=\t,check.names=FALSE,header=TRUE) identical(dat1,dat2) #[1] TRUE jpeg(garbageweight.jpg,width=800) barplot(dat2[-10,2],names.arg=dat2[-10,1],ylab=colnames(dat2)[2],col=rainbow(9),main=American garbage) dev.off() Attached is the pdf of the figure A.K. Garbage.txt The error I get now is Line 8 did not have 3 elements On Tuesday, October 22, 2013 9:41 AM, arun smartpink...@yahoo.com wrote: Hi, Try: lines1 - readLines(Garbage.txt,warn=FALSE) dat1 - read.table(text=gsub(\t+,\t,lines1),stringsAsFactors=FALSE,sep=\t,check.names=FALSE,header=TRUE) str(dat1) #'data.frame': 10 obs. of 3 variables: # $ Material : chr Food Scraps Glass Metals Paper ... # $ Weight(Million Tons): num 25.9 12.8 18 86.7 24.7 ... # $ Percent : num 11.2 5.5 7.8 37.4 10.7 6.8 5.5 11.9 3.2 100 jpeg(garbageweight.jpg,width=800) barplot(dat1[-10,2],names.arg=dat1[-10,1],ylab=colnames(dat1)[2],col=rainbow(9),main=American garbage) dev.off() A.K. Hello guys, I'm having this weird problem with my assignment. I can't seem to import the data that I have created. I keep getting an error that says Error: More Columns than Column names This is my data file. Garbage.txt Was also wondering if you guys could send me into the right direction on how to do this. 1. Create a data frame with the data given above. 2. Create the bar plot for weight variable with appropriate labels. Resize the graphics panel/ window so that all labels are visible. 3. Add colors. Suppose n is the number of bars. barplot(..., col = rainbow(n)) 4. Save the plot to garbageweight.jpg This is how it's supposed to look like at the end. garbage.weight.pdf Description: Adobe PDF document __ R-help@r-project.org 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.
Re: [R] Hdf files Download
On Oct 22, 2013, at 11:34 AM, Roy Mendelssohn - NOAA Federal wrote: Your script didn't make it. There are restrictions on the mail list for attached files. You might try putting the script directly into the email. Thinking that the rejection might have be due to a Nabble posting I located it there and here include it. I'm hoping to use the method as well. # # title : MODIS_download_HTTP.R # purpose : Download of MODIS EVI images for the British Colombia; # reference : http://spatial-analyst.net/wiki/index.php?title=Download_and_resampling_of_MODIS_images # producer : Prepared by T. Hengl (addapted by T. Smejkalova) # last update : Southampton, UK, 18 October 2013. # inputs: Coordinates of the area of interest; proj4 parameters; ftp addresses etc.; # outputs : a series of EVI images (geoTIFF) projected in the local coordinate system; # remarks 1 : To run this script, you need to obtain and install the MODIS resampling tool from [https://lpdaac.usgs.gov/lpdaac/tools/modis_reprojection_tool]; # remarks 2 : You should also obtain the WGET from [http://users.ugent.be/~bpuype/wget/] --- simply copy the wget exe to windows system folder; # remarks 3 : make sure you disable your antivirus tools such as Norton or McAfee otherwise it might block wget from running! library(rgdal) library(RCurl) setInternet2(use = TRUE) # Obtain the MODIS tool from: http://lpdaac.usgs.gov/landdaac/tools/modis/index.asp # setwd(E:/PineBeetleBC/MODIS) # location of the MODIS 1 km monthly blocks: MOD09GQ - http://e4ftl01.cr.usgs.gov/MOLT/MOD09GQ.005/; MOD09GQa - http://anonymous:t...@e4ftl01.cr.usgs.gov/MOLT/MOD09GQ.005/; product = MOD09GQ year = 2000 # location of the mosaicing tool: MRT - 'D:\\MRT\\MRT_Win\\bin\\' workd - 'D:\\R_Modis\\' setwd('D:\\R_Modis\\') options(download.file.method=auto) # get the list of directories (thanks to Barry Rowlingson): items1 - strsplit(getURL(MOD09GQ), \n)[[1]] # get the directory names and create a new data frame: dates=data.frame(dirname=substr(items1[20:length(items1)],52,62)) # get the list of *.hdf files: dates$BLOCK1 - rep(NA, length(dates)) dates$BLOCK2 - rep(NA, length(dates)) #dates$BLOCK3 - rep(NA, length(dates)) #dates$BLOCK4 - rep(NA, length(dates)) for (i in 1:1)#length(dates))# for each date per year { getlist - strsplit(getURL(paste(MOD09GQ, dates$dirname[i], sep=)), )[[1]] getlist=getlist[grep(product,getlist)] getlist=getlist[grep(.hdf,getlist)] filenames=substr(getlist,1,nchar(getlist[1])-3) BLOCK1 - filenames[grep(filenames,pattern=MOD09GQ.*.h18v02.*.hdf)[1]] BLOCK2 - filenames[grep(filenames,pattern=MOD09GQ.*.h19v02.*.hdf)[1]] # write up the file names back to the dates.txt: for(j in 2:3){ dates[i,j] - get(paste(BLOCK, j-1, sep=)) } # Download all blocks from the list to a local drive: # while(!is.na(dates[i,2])!is.na(dates[i,3])!is.na(dates[i,4])!is.na(dates[i,5])!is.na(dates[i,6])!is.na(dates[i,7])!is.na(dates[i,8])!is.na(dates[i,9])!is.na(dates[i,10])){ download.file(paste(MOD09GQa, dates$dirname[i], dates$BLOCK1[i],sep=),destfile=paste(getwd(), /, BLOCK1, sep=)) download.file(paste(MOD09GQ, dates$dirname[i], dates$BLOCK2[i],sep=),destfile=paste(getwd(), /, BLOCK2, sep=), cacheOK=FALSE, ) # remove . from the file name: dirname1 - sub(sub(pattern=\\., replacement=_, dates$dirname[[i]]), pattern=\\., replacement=_, dates$dirname[[i]]) # mosaic the blocks: mosaicname = file(paste(MRT, TmpMosaic.prm, sep=), open=wt) write(paste(workd, BLOCK1, sep=), mosaicname) write(paste(workd, BLOCK2, sep=), mosaicname, append=T) #write(paste(workd, BLOCK3, sep=), mosaicname, append=T) #write(paste(workd, BLOCK4, sep=), mosaicname, append=T) close(mosaicname) # generate temporary mosaic: shell(cmd=paste(MRT, 'mrtmosaic -i ', MRT, 'TmpMosaic.prm -s 0 1 0 0 0 0 0 0 0 0 0 -o ', workd, 'TmpMosaic.hdf', sep=)) # resample to epsg=3005: filename = file(paste(MRT, mrt, dirname1, .prm, sep=), open=wt) write(paste('INPUT_FILENAME = ', workd, 'TmpMosaic.hdf', sep=), filename) # write(paste('INPUT_FILENAMES = ( ', workd, BLOCK1, ' ', workd, BLOCK2, ' ', workd, BLOCK3, ' ', workd, BLOCK4, ' ', workd, BLOCK5, ' ', workd, BLOCK6, ' ', workd, BLOCK7, ' ', workd, BLOCK8, ' ', workd, BLOCK9, ' )', sep=), filename) # unfortunatelly does not work via command line :( write(' ', filename, append=TRUE) # write('SPECTRAL_SUBSET = ( 0 1 0 0 0 0 0 0 0 0 0 )', filename, append=TRUE) write('SPECTRAL_SUBSET = ( 1 )', filename, append=TRUE) write(' ', filename, append=TRUE) write('SPATIAL_SUBSET_TYPE = OUTPUT_PROJ_COORDS', filename, append=TRUE) write(' ', filename, append=TRUE) write('SPATIAL_SUBSET_UL_CORNER = ( 50.0 -180.0 )', filename, append=TRUE) write('SPATIAL_SUBSET_LR_CORNER = ( 160.0 -270.0 )', filename, append=TRUE) write(' ', filename, append=TRUE) write(paste('OUTPUT_FILENAME = ', workd,
Re: [R] Graphing complex functions
On 22/10/2013 1:07 PM, John Van Praag wrote: Does R have any facilities, or packages, for graphing complex functions? I don't think base R does, but if you have a complex-valued function of a real variable, it wouldn't be hard to write one. For your example: library(rgl) xvals - seq(0, 2*pi, len=256) f - function(x) cos(x) + 1i * sin(x) zvals - f(xvals) plot3d(xvals, Re(zvals), Im(zvals), type=l) For the case of a real-valued function of a complex variable, you could use persp() or persp3d(). For both argument and value being complex, you'll need 4 dimensions, and that's hard to do nicely, though I suppose you could overlay contour or perspective plots of the real and imaginary parts of the value. For example: x - y - seq(0, 2*pi, len=50) z - outer(x, y, function(x,y) x + 1i*y) zvals - f(z) persp3d(x, y, Re(zvals), col=red, alpha=0.5, xlab=Re(z), ylab=Im(z), zlab=f(z)) surface3d(x, y, Im(zvals), col=blue, alpha=0.5) Duncan Murdoch I find that 'curve' does not do the trick. Example: f = function(x) cos(x) + 1i * sin(x) curve(f, -pi, pi) Error in xy.coords(x, y, xlabel, ylabel, log) : (converted from warning) imaginary parts discarded in coercion Enter a frame number, or 0 to exit 1: curve(f, -pi, pi) 2: plot(x = x, y = y, type = type, xlab = xlab, ylab = ylab, xlim = xlim, log = lg, ...) 3: plot.default(x = x, y = y, type = type, xlab = xlab, ylab = ylab, xlim = xlim, log = lg, ...) 4: xy.coords(x, y, xlabel, ylabel, log) 5: .signalSimpleWarning(imaginary parts discarded in coercion, quote(xy.coords(x, y, xlabel, ylabel, log))) 6: withRestarts({ .Internal(.signalCondition(simpleWarning(msg, call), msg, call)) .Internal(.dfltWarn(msg, call)) }, muffleWarning = function() NULL) 7: withOneRestart(expr, restarts[[1]]) 8: doWithOneRestart(return(expr), restart) 9: (function () { error() utils::recover() })() Selection: [[alternative HTML version deleted]] __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] How to draw figures in a graph?
You will want to be very careful in adding things to a plot that are not conveying information. One term for these things is chartjunk which should give you a feel for the general opinion about doing this. If you still feel the need to add to a graph (and promise to think hard about it and be careful in the implementation that the added figures do not distort the data) then you can start by looking at the rasterImage function (and grid.raster for grid based graphics). The grImport package could also be useful if your images are in a vector format, see the import vignette from that package. Possibly also the my.symbols function in the TeachingDemos package. On Tue, Oct 22, 2013 at 9:08 AM, halim10-fes halim10-...@sust.edu wrote: Hi All, Hope you guys are doing well. I am thinking of drawing some figures within a graph to make it more interesting. To make a graph more storytelling, like the attached one. I am looking for a couple of days but couldn't come up with any solution on how to do it with R. Any ideas will be greatly appreciated. Thanks, --- Md. Abdul Halim Assistant Professor Department of Forestry and Environmental Science Shahjalal University of Science and Technology,Sylhet-3114, Bangladesh. Cell: +8801714078386. alt. e-mail: xo...@yahoo.com -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. __ R-help@r-project.org 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. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org 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.
Re: [R] Graphing complex functions
John Van Praag john at jvp247.com writes: Does R have any facilities, or packages, for graphing complex functions? Package 'elliptic' has function view() for Visualization of complex functions using colourmaps and contours Hans Werner __ R-help@r-project.org 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.
Re: [R] Help with loop ;(
Hi, The conditions are not very clear. For example, it is not mentioned whether vectors are of same length or not. Assuming the former case: fun1 - function(x,y){ if(length(x)==length(y) length(x)%%2==0){ res - x+y } else if(length(x)==length(y) length(x)%%2==1){ res - abs(x-y) } else print(Lengths are not same) res } vec1 - 1:10 vec2 - 11:20 vec3 - 1:9 vec4 - 10:18 fun1(vec3,vec4) fun1(vec1,vec2) fun1(vec1,vec3) A.K. Hi, I'm new on this forum, and I need some help with for loop. I have to write loop that will add two vectors, if they are even. Even if they are odd, it must subtract the two vectors. __ R-help@r-project.org 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.
Re: [R] 'XML' package cannot be un-zipped or un-tar'd
R FAQ 5.1.2: Some CRAN packages that do not build out of the box on Windows, require additional software, or are shipping third party libraries for Windows cannot be made available on CRAN in form of a Windows binary package. Nevertheless, some of these packages are available at the CRAN extras repository at http://www.stats.ox.ac.uk/pub/RWin/ kindly provided by Brian D. Ripley. Note that this repository is a default repository for recent versions of R for Windows. This applies to the 'XML' package. install.packages(XML) should work. This is a regular issue coming up on the mailing list, so a quick search should have found the issue. The XML readme file points out that building on windows is not as simple as on other platforms. Paul Bivand On 19 October 2013 20:51, Steven Dwayne Randolph randolph_steve...@lilly.com wrote: Even when I attempt to unzip the file on windows, I get an error that says its not a compressed file. From: Rolf Turner [mailto:rolf.tur...@xtra.co.nz] Sent: Tuesday, October 01, 2013 4:23 PM To: Steven Dwayne Randolph Cc: r-help@r-project.org Subject: Re: [R] 'XML' package cannot be un-zipped or un-tar'd On 10/02/13 00:22, Steven Dwayne Randolph wrote: R-help, There are several packages that have package 'XML' as a dependency. I cannot get this package (XML) to extract or install. I have tried manually downloaded to local machines (client PC and Linux), unsuccessful extraction. How can this be compiled manually? How can a new version be on CRAN and this problem still exist? See the thread for specific errors and screen shots. What do you mean by cannot get this package (XML) to extract or install? Did you download the tarball XML_3.98-1.1.tar.gz? If so, what happens when you do tar xvf XML_3.98-1.1.tar.gz? Do you have the requisite R development tools (appropriate compilers etc.) installed? What happens if you do the install from within R, as in install.packages(XML,lib=some library for which you have write permission) ??? When I tried that I got a whinge about a lack of xml2-config. After sum yumming around (I use Fedora Linux) I found that sudo yum install libxml2.x86_64 libxml2-devel.x86_64 did the trick, and I was then able to install XML using install.packages(). cheers, Rolf Turner [[alternative HTML version deleted]] __ R-help@r-project.org 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. [[alternative HTML version deleted]] __ R-help@r-project.org 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] warning messages
Hi, i made a loop , then i got more than 50 warning messages, and i know what these messages and why they appears my question here is the warning message affecting in the accuracy of the results this is my loop nrep= 1000 n1=25 set.seed(123) nw1-c() for (i in 1:nrep) { e- rnorm(n1,0,0.1) x- runif(n1,0,1) mx- 1-x+exp(-200*(x-0.5)^2) y- mx+e h- bw.ucv(x,nb = 1000) est1 - ksmooth(x, y, kernel = normal, bandwidth = h, x.points = x)$y nw1 - cbind(nw1,est1) } There were 50 or more warnings (use warnings() to see the first 50) RegardsKhulood H. - áäÓÃá Çááå ÇáÌäÉ æãÇ íÞÑøÈ ÅáíåÇ ãä Þæá æÚãá [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] How do I use simple calls to java methods?
Thanks so much for the reply. I did the search for rJava examples and found the Scott Hoover instructions which seemed like exactly what I needed. I compiled the java code and copied myExchange.java and myExchange.class to the directory where I started R where I did and the calls suggested inside worked. But there are no parameters passed in the examples. I need to do something like this: dateStg - 201310221439591234 dateStg doubleLin - .jcall(CalqsLin, D, linTimOfCalqsStgIsLev,dateStg,-4) or doubleLin - .jcall(CalqsLin, D, linTimOfCalqsStgIsLev,201310221439591234,-4) where the latter two parameters are passed to linTimOfCalqsStgIsLev. Neither way works and I cannot understand the .jcall() instructions in rJava.pdf well enough. I'll keep trying, but would like help. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-use-simple-calls-to-java-methods-tp4678753p4678834.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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] Depends and Imports in DESCRIPTION file
Dear list members: I try to check my updated package to include a new version in CRAN (phenology) but a new error is indicated and I don't find the logic. First my system: * using R version 3.0.2 Patched (2013-09-27 r64011) * using platform: x86_64-apple-darwin10.8.0 (64-bit) Here is the message: * checking dependencies in R code ... NOTE Packages in Depends field not imported from: ‘fields’ ‘zoo’ These packages needs to imported from for the case when this namespace is loaded but not attached. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. It is based on this line in DESCRIPTION file: Depends: fields, zoo, coda, R (= 2.14.0) I use indeed functions from fields and zoo packages. If I create a new line: Imports: fields, zoo and remove these two packages from depends, I have still a problem in Imports and errors because functions from fields and zoo are not available. * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘fields’ ‘zoo’ All declared Imports should be used. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. * checking R code for possible problems ... NOTE .read_phenology: no visible global function definition for ‘na.locf’ plot.phenologymap: no visible global function definition for ‘image.plot’ If I add the packages fields, zoo packages in both Depends and Imports, I have also error because packages fields, zoo are indicated twice and I have the same errors as previously indicated. * checking DESCRIPTION meta-information ... NOTE Packages listed in more than one of Depends, Imports, Suggests, Enhances: ‘fields’ ‘zoo’ A package should be listed in only one of these fields. Of course I read ‘Creating R packages’ of the ‘Writing R Extensions’ manual, but I can't find solution to this problem. Thanks a lot, Marc Girondot -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ R-help@r-project.org 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] cbind() function : Not able to display columns
Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c) Problem: when we print the matrix k, k a b c [1,] 1 a ee [2,] 2 b tt [3,] 3 c rr we can see that rows are represented by [1,] , [2,] and [3,]. Similarly, the columns are denoted by [a], [b] and [c]. When we try to print the corresponding columns, we are able to print for k[a], i.e., the first column but not able to correctly print the second and third columns. k[a] [1] 1 2 3 k[b] [1] NA NA NA k[c] [1] NA NA NA Please let me know what am I doing wrong. -- Thanks and Regards, Vivek Kumar Singh Research Assistant, School of Computing, National University of Singapore Mobile:(0065) 82721535 [[alternative HTML version deleted]] __ R-help@r-project.org 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.
Re: [R] How do I use simple calls to java methods?
What I was missing was that I had to put as.integer(-4) to make it an integer. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-use-simple-calls-to-java-methods-tp4678753p4678844.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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.
Re: [R] cbind() function : Not able to display columns
Hi, Try: k[,a] #[1] 1 2 3 k[,b] #[1] a b c k[,c] #[1] ee tt rr A.K. On Tuesday, October 22, 2013 11:37 PM, Vivek Singh vksingh.ii...@gmail.com wrote: Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c) Problem: when we print the matrix k, k a b c [1,] 1 a ee [2,] 2 b tt [3,] 3 c rr we can see that rows are represented by [1,] , [2,] and [3,]. Similarly, the columns are denoted by [a], [b] and [c]. When we try to print the corresponding columns, we are able to print for k[a], i.e., the first column but not able to correctly print the second and third columns. k[a] [1] 1 2 3 k[b] [1] NA NA NA k[c] [1] NA NA NA Please let me know what am I doing wrong. -- Thanks and Regards, Vivek Kumar Singh Research Assistant, School of Computing, National University of Singapore Mobile:(0065) 82721535 [[alternative HTML version deleted]] __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] cbind() function : Not able to display columns
Hard to say, not sure what you want to do. But the columns are not denoted by [a], [b] or [c]. You should learn to use the str function to understand what various expressions really are, and return to the Introduction to R document that comes with the software. There is a distinct difference between a and a in R, and square brackets are not at all like quotes. See help([) and the ItoR section on indexing. You might get what you want by k[,b] for example. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Vivek Singh vksingh.ii...@gmail.com wrote: Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c) Problem: when we print the matrix k, k a b c [1,] 1 a ee [2,] 2 b tt [3,] 3 c rr we can see that rows are represented by [1,] , [2,] and [3,]. Similarly, the columns are denoted by [a], [b] and [c]. When we try to print the corresponding columns, we are able to print for k[a], i.e., the first column but not able to correctly print the second and third columns. k[a] [1] 1 2 3 k[b] [1] NA NA NA k[c] [1] NA NA NA Please let me know what am I doing wrong. __ R-help@r-project.org 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.
Re: [R] How do I use simple calls to java methods?
Or use the literal form 4L. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Hurr hill0...@umn.edu wrote: What I was missing was that I had to put as.integer(-4) to make it an integer. -- View this message in context: http://r.789695.n4.nabble.com/How-do-I-use-simple-calls-to-java-methods-tp4678753p4678844.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] cbind() function : Not able to display columns
In addition to what the others have told you, it looks like you might be confusing matrices with data.frames. Please see ?data.frame I think what you are looking for is b - c('a','b','c') c - c(ee,tt,rr) k - cbind(a,b,c) K - data.frame(a, b, c) K a b c 1 1 a ee 2 2 b tt 3 3 c rr I recommend using - for assignment (not the spaces on both sides), not =. On Wed, Oct 23, 2013 at 12:01 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Hard to say, not sure what you want to do. But the columns are not denoted by [a], [b] or [c]. You should learn to use the str function to understand what various expressions really are, and return to the Introduction to R document that comes with the software. There is a distinct difference between a and a in R, and square brackets are not at all like quotes. See help([) and the ItoR section on indexing. You might get what you want by k[,b] for example. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Vivek Singh vksingh.ii...@gmail.com wrote: Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c) Problem: when we print the matrix k, k a b c [1,] 1 a ee [2,] 2 b tt [3,] 3 c rr we can see that rows are represented by [1,] , [2,] and [3,]. Similarly, the columns are denoted by [a], [b] and [c]. When we try to print the corresponding columns, we are able to print for k[a], i.e., the first column but not able to correctly print the second and third columns. k[a] [1] 1 2 3 k[b] [1] NA NA NA k[c] [1] NA NA NA Please let me know what am I doing wrong. __ R-help@r-project.org 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-help@r-project.org 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.
Re: [R] Depends and Imports in DESCRIPTION file
Le 23/10/13 05:03, Marc Girondot a écrit : Dear list members: I try to check my updated package to include a new version in CRAN (phenology) but a new error is indicated and I don't find the logic. First my system: * using R version 3.0.2 Patched (2013-09-27 r64011) * using platform: x86_64-apple-darwin10.8.0 (64-bit) Here is the message: * checking dependencies in R code ... NOTE Packages in Depends field not imported from: ‘fields’ ‘zoo’ These packages needs to imported from for the case when this namespace is loaded but not attached. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. I begin to find the origin of the problem... but not still the solution. When the NAMESPACE file is created by package.skeleton(), it includes: import(coda) but not import(fields) import(zoo) If I add these manually, the check is ok. Now the question becomes: why package.skeleton() does not add them and how to force package.skeleton() to add them ? Sincerely, Marc Girondot -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ R-help@r-project.org 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.
Re: [R] Depends and Imports in DESCRIPTION file
On Tue, Oct 22, 2013 at 8:03 PM, Marc Girondot marc_...@yahoo.fr wrote: Dear list members: I try to check my updated package to include a new version in CRAN (phenology) but a new error is indicated and I don't find the logic. First my system: * using R version 3.0.2 Patched (2013-09-27 r64011) * using platform: x86_64-apple-darwin10.8.0 (64-bit) Here is the message: * checking dependencies in R code ... NOTE Packages in Depends field not imported from: ‘fields’ ‘zoo’ These packages needs to imported from for the case when this namespace is loaded but not attached. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. Just as packages under 'Imports:' in your DESCRIPTION file need to have corresponding import()/importFrom() statements in the NAMESPACE file, so do packages under 'Depends:'. That is what this 'R CMD check' NOTE is trying to say. If you don't do this, those package's functions/variables will only be available if you *attach* your package, but not if you only *load* it. That's also what the NOTE tries to say. When you do library()/require(), you *attach* a package and it appear in the search() path and all functions/variables in the search() path will be found by the user and from all packages attached/loaded. When a package is *loaded* - explicitly via loadNamespace()/requireNamespace(), but more commonly via Imports: statements in DESCRIPTION, it is *not* attached to the search() path and therefore none of its functions/variables are found. Such functions/variables are only found if they are explicitly imported via import()/importFrom() in the NAMESPACE file. Most people will *attach* your package, i.e. library(YourPackage), and currently the functions/variables of the packages under Depends: will be on the search() and therefore found by the functions of your package. To see what packages are attached (=on the search() path) and which are only loaded, look as sessionInfo(). So far so, good. However, if someone else decides to use one of your package's functions in their package and put it under 'Imports:, e.g. Package: AnotherPackage Depends: SomePackage Imports: YourPackage = your package you will be in trouble. Because, library(AnotherPackage) will *attach* AnotherPackage and SomePackage to the search() path and *load* YourPackage. In turn, you have specified in your DESCRIPTION will *load* all packages under its Imports: as well as Depends:. However, since your NAMESPACE file does not import()/importFrom() any of the packages under Depends:, none of those functions will be found. Your functions will give errors like 'could not find function foo. Basically, Depends: could be though of as AttachOrLoad: and Imports: as LoadOnly:. To learn more about how all this works and why/why not, I strongly recommend Suraj Gupta's nice write up 'How R Searches and Finds Stuff' (Mar 2012): http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ /Henrik It is based on this line in DESCRIPTION file: Depends: fields, zoo, coda, R (= 2.14.0) I use indeed functions from fields and zoo packages. If I create a new line: Imports: fields, zoo and remove these two packages from depends, I have still a problem in Imports and errors because functions from fields and zoo are not available. * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘fields’ ‘zoo’ All declared Imports should be used. See the information on DESCRIPTION files in the chapter ‘Creating R packages’ of the ‘Writing R Extensions’ manual. * checking R code for possible problems ... NOTE .read_phenology: no visible global function definition for ‘na.locf’ plot.phenologymap: no visible global function definition for ‘image.plot’ If I add the packages fields, zoo packages in both Depends and Imports, I have also error because packages fields, zoo are indicated twice and I have the same errors as previously indicated. * checking DESCRIPTION meta-information ... NOTE Packages listed in more than one of Depends, Imports, Suggests, Enhances: ‘fields’ ‘zoo’ A package should be listed in only one of these fields. Of course I read ‘Creating R packages’ of the ‘Writing R Extensions’ manual, but I can't find solution to this problem. Thanks a lot, Marc Girondot -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide