Re: [R] merging matrices

2013-10-22 Thread PIKAL Petr
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

[R] Merging data.frames with overlapping intervals

2013-10-22 Thread Julius Tesoro
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

Re: [R] Merging data.frames with overlapping intervals

2013-10-22 Thread PIKAL Petr
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:

Re: [R] Quick advice on loading packages

2013-10-22 Thread jwd
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:

Re: [R] RWeka and multicore package

2013-10-22 Thread Patrick Connolly
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)

Re: [R] R - How to physically Increase Speed

2013-10-22 Thread Jim Holtman
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

Re: [R] May I send a zip attachment to a post?

2013-10-22 Thread Barry Rowlingson
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

[R] Where is element 30?

2013-10-22 Thread Alaios
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

Re: [R] Where is element 30?

2013-10-22 Thread Gerrit Eichner
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 

Re: [R] May I send a zip attachment to a post?

2013-10-22 Thread Carl Witthoft
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

Re: [R] Error in heatmap

2013-10-22 Thread Adams, Jean
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

Re: [R] XML package not working

2013-10-22 Thread Ista Zahn
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

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread S Ellison
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

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread S Ellison
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}}

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Kenneth Knoblauch
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

Re: [R] How do I use simple calls to java methods?

2013-10-22 Thread Hurr
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

Re: [R] More Columns than column names Error

2013-10-22 Thread Carl Witthoft
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

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Bos, Roger
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

Re: [R] XML package not working

2013-10-22 Thread Duncan Murdoch
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. --

Re: [R] More Columns than column names Error

2013-10-22 Thread Keith Jewell
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

Re: [R] More Columns than column names Error

2013-10-22 Thread arun
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

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread Hadley Wickham
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,

Re: [R] R - How to physically Increase Speed

2013-10-22 Thread Prof J C Nash (U30A)
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

Re: [R] How do I use simple calls to java methods?

2013-10-22 Thread Jeff Newmiller
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

[R] colour code areas of a plot

2013-10-22 Thread Martin Batholdy
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

Re: [R] colour code areas of a plot

2013-10-22 Thread Ken Knoblauch
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))

Re: [R] XML package not working

2013-10-22 Thread Steven Dwayne Randolph
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

Re: [R] [ADMB Users] R2admb compile problem

2013-10-22 Thread Allan Clark
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)

Re: [R] colour code areas of a plot

2013-10-22 Thread Olivier Crouzet
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),

Re: [R] list and -

2013-10-22 Thread Taiyun Wei
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 } }

[R] integer - factor

2013-10-22 Thread luana
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:

Re: [R] XML package not working

2013-10-22 Thread Steven Dwayne Randolph
Ista,... Thank you for your response. Here is what is occurring when I attempt to command-line install. -- install.packages('XML') Installing package into

Re: [R] integer - factor

2013-10-22 Thread Sarah Goslee
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

Re: [R] cor matrix in multivariate regression

2013-10-22 Thread Martin Maechler
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 …

Re: [R] integer - factor

2013-10-22 Thread Bert Gunter
... 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

Re: [R] Am I working with regularly spaced time series?

2013-10-22 Thread Paul Gilbert
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

Re: [R] Am I working with regularly spaced time series?

2013-10-22 Thread Gabor Grothendieck
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.

Re: [R] list and -

2013-10-22 Thread Greg Snow
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 `-`

Re: [R] speeding up sum of squared differences calculation

2013-10-22 Thread William Dunlap
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

Re: [R] XML package not working

2013-10-22 Thread Berend Hasselman
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.

[R] [R-pkgs] scholar 0.1.0 on CRAN

2013-10-22 Thread James Keirstead
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

[R] Hdf files Download

2013-10-22 Thread Tereza Smejkalova
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

[R] How to draw figures in a graph?

2013-10-22 Thread halim10-fes
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

[R] Graphing complex functions

2013-10-22 Thread John Van Praag
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

[R] nls model definition help

2013-10-22 Thread Wayne.W.Jones
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.

[R] reference class error

2013-10-22 Thread Filippo Monari
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',

Re: [R] Hdf files Download

2013-10-22 Thread Roy Mendelssohn - NOAA Federal
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

Re: [R] Replace NA values with previous valid value in array

2013-10-22 Thread arun
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)

Re: [R] More Columns than column names Error

2013-10-22 Thread arun
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

Re: [R] Hdf files Download

2013-10-22 Thread David Winsemius
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

Re: [R] Graphing complex functions

2013-10-22 Thread Duncan Murdoch
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,

Re: [R] How to draw figures in a graph?

2013-10-22 Thread Greg Snow
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

Re: [R] Graphing complex functions

2013-10-22 Thread Hans W Borchers
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 __

Re: [R] Help with loop ;(

2013-10-22 Thread arun
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

Re: [R] 'XML' package cannot be un-zipped or un-tar'd

2013-10-22 Thread Paul Bivand
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”

[R] warning messages

2013-10-22 Thread Ms khulood aljehani
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) {

Re: [R] How do I use simple calls to java methods?

2013-10-22 Thread Hurr
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

[R] Depends and Imports in DESCRIPTION file

2013-10-22 Thread Marc Girondot
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

[R] cbind() function : Not able to display columns

2013-10-22 Thread Vivek Singh
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,].

Re: [R] How do I use simple calls to java methods?

2013-10-22 Thread Hurr
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.

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread arun
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)

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Jeff Newmiller
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

Re: [R] How do I use simple calls to java methods?

2013-10-22 Thread Jeff Newmiller
Or use the literal form 4L. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live:

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Richard M. Heiberger
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

Re: [R] Depends and Imports in DESCRIPTION file

2013-10-22 Thread Marc Girondot
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:

Re: [R] Depends and Imports in DESCRIPTION file

2013-10-22 Thread Henrik Bengtsson
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