[R] Select fixed number of elements

2013-10-30 Thread Alaios
Hi all, I have in my code some vectors that are not of equal size. I would like to be able for each of these vectors select 6 elements that are (almost) equally spaced. So the first one would be at (or close) to the beginning the last one at (or close) to the end and the other 4 equally spaced

[R] cannot coerce class function to a data.frame

2013-10-30 Thread hsin-fei tu
Hello: I use the egonet function and have a problem idx - sapply(mats,index.egonet) idx - as.data.frame(t(idx)) idx - cbind(idx,filename=rownames(idx)) data - merge(data,idx,by=filename) cannot coerce class function to a data.frame can someone please help me with this problm? Thank

Re: [R] Select fixed number of elements

2013-10-30 Thread Gerrit Eichner
Hello, Alaois, if x is your vector maybe n - length( x) positions - trunc( quantile( seq( n), prob = 0:5/5)) x[ positions] comes close to what you want. Hth -- Gerrit Hi all, I have in my code some vectors that are not of equal size. I would like to be able for each of these vectors

Re: [R] Select fixed number of elements

2013-10-30 Thread Ken Knoblauch
Alaios alaios at yahoo.com writes: I have in my code some vectors that are not of equal size. I would like to be able for each of these vectors select 6 elements that are (almost) equally spaced. So the first one would be at (or close) to the beginning the last one at (or close) to the end

[R] Yield to maturity in R

2013-10-30 Thread Katherine Gobin
Dear R forum, Just want to know if there is any function / package in R which will calculate Yield to Maturity in R for a given bond? Regards Katherine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread Dan Abner
Hi everybody, I have data in the format of the example data below where essentially a large number of indicator variables (coded [0,1]) reflect traits of the same id across multiple rows. I need to represent the data in a 1 row per id format. I see this as being similar to converting from long to

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Michael Weylandt
Presumably you need to define 'buzz' first, but I don't see evidence that you've done so. Michael On Oct 30, 2013, at 0:06, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello again! I'm using python with a module rpy2 to call functions from R. It works fine on built in R functions like

Re: [R] Revo R for Arima Implementation

2013-10-30 Thread Suzen, Mehmet
On 28 October 2013 14:26, Anindita Chattopadhyay anindit...@mu-sigma.com wrote: We need to understand how we can implement this in Revo R. Most of the people here contribute to community of R not Revo R. I think it is unfair of you to request from this list to solve your Revo R issue.

Re: [R] Fitting multiple horizontal lines to data

2013-10-30 Thread Carl Witthoft
Your question doesn't make much sense if you really believe that the best fit is to draw a horizontal line at every unique value of y. What is the actual problem you are trying to solve? Clearly it's not a matter of linear fits, so forget about using lm or other regression tools. -- View

Re: [R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread Dan Abner
Hi Rui, Thanks for responding. When I make this change, I get an error message: mysum-function(x) tapply(x,d1$id,sum) d2-apply(d1[2:4],mysum) Error in match.fun(FUN) : argument FUN is missing, with no default Thoughts? On Wed, Oct 30, 2013 at 8:01 AM, Rui Barradas ruipbarra...@sapo.pt

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread Carl Witthoft
Did you run the identical code on the identical machine, and did you verify there were no other tasks running which might have limited the RAM available to R? And equally important, did you run these tests in the reverse order (in case R was storing large objects from the first run, thus chewing

Re: [R] Can not read Excel file correctly

2013-10-30 Thread Carl Witthoft
Dunno how to break this to you, but R reads exactly what is in that file, with the data in exactly the proper row/column locations. -- View this message in context: http://r.789695.n4.nabble.com/Can-not-read-Excel-file-correctly-tp4679306p4679350.html Sent from the R help mailing list

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-30 Thread Carl Witthoft
Which suggests the OP should verify that the data in ...$Frequency is the data he expects to be there. Rui Barradas wrote Hello, I can't reproduce your error: windfreq - c(1351L, 2147L, 3317L, 4378L, 5527L, 6667L, 7865L, 8970L, 9987L, 10907L, 11905L, 12642L, 131000L, 14983L, 15847L,

[R] (no subject)

2013-10-30 Thread Stevan Lauriault
Hi, I'm looking for a function that takes a list and calculates a score based on how well like attracts like. For example: list1 - c(john, eric, steve, john, eric, scott, john) list2 - c(john, john, john, eric, eric, steve, scott) score(list1) score(list2) Both lists are composed of the same

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread Heinz Tuechler
All was run on the identical machine in independent sessions. I did not restart Windows. I also tried 32bit R 3.0.2 and it seemed slightly faster than 64bit. Using Process Explorer v15.23 (http://technet.microsoft.com/de-de/sysinternals/bb896653) my impression was that R 3.0.2 manages memory

[R] omitting integer(0) rows from data frame

2013-10-30 Thread Jack Tanner
I'm not sure if this is correct behavior or not, but it seems counterintuitive to me: dat - data.frame(id=1:5, let=letters[1:5]) # A. omits the first row dat[- 1, ] # B. unexpectedly omits ALL rows dat[- integer(0), ] It would be less surprising if there were no rows omitted in the (B) case.

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Erin Hodgess
I did...just didn't show it On Wed, Oct 30, 2013 at 7:01 AM, Michael Weylandt michael.weyla...@gmail.com wrote: Presumably you need to define 'buzz' first, but I don't see evidence that you've done so. Michael On Oct 30, 2013, at 0:06, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Gerrit Eichner
Hi, Jack, well, I disagree: What do you expect to grab out of a bucket (= data frame) if you do not at all grab into it (indexing with an _empty_ index, i.e. with nothing)? And changing the sign of nothing is still nothing ... Hth -- Gerrit On Wed, 30 Oct 2013, Jack Tanner wrote: I'm

Re: [R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread arun
Hi, May be: apply(d1[3:5],2, mysum)   var1 var2 var3 1    2    0    1 2    2    2    3 3    1    1    1 4    0    1    0 #or sapply(d1[3:5],mysum) #or library(plyr) ddply(d1[,-2],.(id),colwise(sum)) A.K. On Wednesday, October 30, 2013 8:30 AM, Dan Abner dan.abne...@gmail.com wrote: Hi Rui,

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread S Ellison
dat[- integer(0), ] unexpectedly omits ALL rows It would be less surprising if there were no rows omitted in the (B) case. I tried this on two experienced R users here and their first thought* was, interestingly, as Jack indicated; that -integer(0) should drop nothing. But Gerrit

Re: [R] Optimization failed in fitdistr (Weibull distribution)

2013-10-30 Thread peter dalgaard
On 29 Oct 2013, at 21:35 , Rolf Turner r.tur...@auckland.ac.nz wrote: On 10/29/13 19:44, peter dalgaard wrote: SNIP There really is no substitute for knowledge and understanding! Did it not occur to you that the Windspeed column needs to enter into your analysis? SNIP

[R] ggplot2 question: keeping the order as in the input data

2013-10-30 Thread Dimitri Liakhovitski
Hello! I am using ggplot2 (see the code below) to plot the data in 'myplotdata'. The first column of 'myplotdata' is called att.levels and contains strings; the second column is called WTP and contains numeric values. Notice - I use 'coord.flip()' The command aes(x=att_levels, y=WTP), if I

[R] Shiny question: what happens after hitting F5

2013-10-30 Thread Dimitri Liakhovitski
I have a Shiny code that is working. In this code, the user uploads some input files, then runs some analyses (using an actionButton), gets some outputs displayed and can also download some results. I am testing this code. After I've run the analysis and have made some small change to the code, I

Re: [R] Can not read Excel file correctly

2013-10-30 Thread MacQueen, Don
I can't help you with cell A1, but I can make a guess at your date format issue. To start, I would suggest you read thoroughly the XLConnect documentation for how it handles dates (and probably also ?Date in R). In both Excel and R, dates are stored internally as a number, and then displayed with

Re: [R] (no subject)

2013-10-30 Thread Adams, Jean
What would the calculated score be for the example you give? Jean On Wed, Oct 30, 2013 at 7:03 AM, Stevan Lauriault stevan.lauria...@gmail.com wrote: Hi, I'm looking for a function that takes a list and calculates a score based on how well like attracts like. For example: list1 -

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread R. Michael Weylandt michael.weyla...@gmail.com
Could you produce a full working example then? Bit hard to debug without knowing what you did. Michael On Oct 30, 2013, at 9:11, Erin Hodgess erinm.hodg...@gmail.com wrote: I did...just didn't show it On Wed, Oct 30, 2013 at 7:01 AM, Michael Weylandt michael.weyla...@gmail.com wrote:

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Collin Lynch
Erin, one question, can you access the defined functions by key? In lieu of: x = R.r.buzz(3) Can you do: x = R.r['buzz'](3) Alternatively if you need only one or two custom functions have you considered just defining them via python as in: PStr = function(LM) { S - summary(LM);

Re: [R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread David Carlson
apply() is a different function from sapply() and has different arguments. - David L Carlson Deparment of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org

Re: [R] Shiny question: what happens after hitting F5

2013-10-30 Thread S Ellison
I get warnings (one for each file) that look like this: Warning in dir.create(dir) : 'C:\Users\DIMITR~1.LIA\AppData\Local\Temp\RtmpklHtMJ\435e92e733e5f0 a8a00f342d' already exists It is still working. But: how could I get rid of these warnings? Delete the temporary files before

Re: [R] ggplot2 question: keeping the order as in the input data

2013-10-30 Thread William Dunlap
Try making att_levels (or att.levels, whatever you really call it) into a factor with the levels in the order you like. E.g., aes(x = factor(att_levels, levels=unique(att_levels)), y = WTP) instead of aes(x = att_levels, y = WTP) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Erin Hodgess
Here we go: buzz function(x) { y - x + pi return(y) } q() Save workspace image? [y/n/c]: python Save workspace image? [y/n/c]: y root@erinminfo [/home/erinminf/public_html]# python Python 2.7.5 (default, Sep 11 2013, 02:14:06) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type help,

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Patrick Burns
This is Circle 8.1.13 of 'The R Inferno'. http://www.burns-stat.com/documents/books/the-r-inferno/ Pat On 30/10/2013 13:04, Jack Tanner wrote: I'm not sure if this is correct behavior or not, but it seems counterintuitive to me: dat - data.frame(id=1:5, let=letters[1:5]) # A. omits the

[R] help me align the legend bar

2013-10-30 Thread Alaios
Hi, I have some code that you can simply execute: require(plotrix) test-matrix(data=rnorm(1,-100,5),nrow=100) color2D.matplot(test,axes=F,xlab=,ylab=,main=color.scale,   extremes=c(#FF,#00),show.legend=FALSE)  

Re: [R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread David Winsemius
On Oct 30, 2013, at 4:07 AM, Dan Abner wrote: Hi everybody, I have data in the format of the example data below where essentially a large number of indicator variables (coded [0,1]) reflect traits of the same id across multiple rows. I need to represent the data in a 1 row per id format.

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread David Winsemius
On Oct 30, 2013, at 6:04 AM, Jack Tanner wrote: I'm not sure if this is correct behavior or not, but it seems counterintuitive to me: dat - data.frame(id=1:5, let=letters[1:5]) # A. omits the first row dat[- 1, ] # B. unexpectedly omits ALL rows dat[- integer(0), ] It would be

Re: [R] Subtotals by id for a large number of columns XXXX

2013-10-30 Thread Dan Abner
Hi David, 1) Thanks very much. Your code shows that this was much simpler than I anticipated. 2) I have made the appropriate changes to email in plain text. My apologies. Thanks! Dan On Wed, Oct 30, 2013 at 1:17 PM, David Winsemius dwinsem...@comcast.net wrote: On Oct 30, 2013, at 4:07 AM,

Re: [R] (no subject)

2013-10-30 Thread Adams, Jean
You should cc r-help on all correspondence so everyone can follow the thread. Clearly I'm missing something. Perhaps others are, too. I don't know what you mean by a score based on the co-localization of names unless you give an example. Jean On Wed, Oct 30, 2013 at 10:34 AM, Stevan

Re: [R] ggplot2 question: keeping the order as in the input data

2013-10-30 Thread Dimitri Liakhovitski
Indeed, it helped - thank you, Bill. And now - how could I now avoid the reversal on my axis with att_levels? Currently it starts with the last one being the first one on the graph and ends with the first one... On Wed, Oct 30, 2013 at 12:04 PM, William Dunlap wdun...@tibco.com wrote: Try

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Erin Hodgess
Solve: I wrote the buzz function to buzz.R And now I have: from rpy2.robjects.packages import SignatureTranslatedAnonymousPackage as STAP with open(buzz.R,r) as f: string = '''.join(f.readlines()) buzz = STAP(string,buzz) buzz.buzz(3) And all is well! Thanks, Erin On Wed, Oct 30, 2013

Re: [R] (no subject)

2013-10-30 Thread Clint Bowman
Just guessing, would the following help? list1 - c(john, eric, steve, john, eric, scott, john) list2 - c(john, john, john, eric, eric, steve, scott) max(rle(list1)$lengths) max(rle(list2)$lengths) Clint Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread William Dunlap
I see a big 2.15.2/3.0.2 speed difference in parse() (which is used by source()) when it is parsing long vectors of numeric data. dump/source has never been an efficient way of transferring data between different R session, but it is much worse now for long vectors. In 2.15.2 doubling the size

[R] multiple concurrent write in R

2013-10-30 Thread Zhifa Liu
I have over 200 CPUs could write to the same file at the same time, does someone know how to handle the multiple concurrent write in R? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] mapping data to a geographic map of Europe

2013-10-30 Thread paladini
Hi Jim, thats the second time that you helped me in a short while so thanks a lot! But it seems to me quite laborious and error-prone to first select all the relevant countries in this long list and then to create a color vector. But perhaps I get it all wrong. For the color vector I

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread William Dunlap
It would be less surprising if there were no rows omitted in the (B) case. -integer(0) is identical to integer(0), so how could '[' handle them differently? Yes. It is surprising. It is also teh reason why the construction is also not returning what a user might expect:

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Carl Witthoft
Both PBurns and DWin are correct. I just thought I'd add a clunky safety check approach I use now and then: Before doing the actual subset, i.e. df[-which(something),] , do something like if (length(which(something)) 1 ) {skip the subsetting} else df[-which(something)] -- View this

[R] getPortfolio(frontier)$weight

2013-10-30 Thread forecast statistics
Dear all, It does not work function getWeights in the fPortfolio package. Returns a vector instead of a matrix. can anyone help me? Thanks in advance. Massimiliano [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Collin Lynch
I don't believe that rpy2 will load a saved workspace. When I have worked with this I always load my functions by sourcing an r file separately: R.r['source'](MyFuncs.r) Best, Collin. On Wed, 30 Oct 2013, Erin Hodgess wrote: Here we go: buzz function(x) { y - x + pi

Re: [R] multiple concurrent write in R

2013-10-30 Thread Jeff Newmiller
I think the answer is no. Use the master process to manage IO. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go...

Re: [R] rpy2 and user defined functions from R

2013-10-30 Thread Wensui Liu
if you don't need to exchange big data between r and python, pyper might be better than rpy2. On Oct 30, 2013 12:08 AM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello again! I'm using python with a module rpy2 to call functions from R. It works fine on built in R functions like rnorm.

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread Heinz Tuechler
Best thanks for confirming my impression. I use dump for storing large data.frames with a number of attributes for each variable. save/load is much faster, but I am unsure, if such files will be readable by R versions years later. What format/functions would you suggest for data

Re: [R] multiple concurrent write in R

2013-10-30 Thread William Dunlap
On Linux, at least, you can have various processes write into the same file, by opening it with r+ mode and calling seek() to position the file pointer before writing. E.g., library(parallel) cl4 - makeCluster(4) tf - tempfile() cat(rep(, 2*length(cl4)), sep=\n, file=tf)

Re: [R] help me align the legend bar

2013-10-30 Thread Adams, Jean
You could use the mar= argument of the par() function to define a wider plot margin on the right, then change the first and third arguments of color.legend() to make the legend fit in the margin. For example, par(mar=c(3, 1, 3, 7)) color2D.matplot(test, axes=F, xlab=, ylab=, main=color.scale,

Re: [R] big speed difference in source btw. R 2.15.2 and R 3.0.2 ?

2013-10-30 Thread William Dunlap
I have to defer to others for policy declarations like how long the current format used by load and save should be readable. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: Heinz Tuechler [mailto:tuech...@gmx.at] Sent: Wednesday, October 30, 2013 1:43

Re: [R] (no subject)

2013-10-30 Thread Jim Lemon
On 10/30/2013 11:03 PM, Stevan Lauriault wrote: Hi, I'm looking for a function that takes a list and calculates a score based on how well like attracts like. For example: list1- c(john, eric, steve, john, eric, scott, john) list2- c(john, john, john, eric, eric, steve, scott) score(list1)

Re: [R] mapping data to a geographic map of Europe

2013-10-30 Thread Jim Lemon
On 10/31/2013 03:04 AM, palad...@trustindata.de wrote: Hi Jim, thats the second time that you helped me in a short while so thanks a lot! But it seems to me quite laborious and error-prone to first select all the relevant countries in this long list and then to create a color vector. But

[R] an rpy2, R cgi type question

2013-10-30 Thread Erin Hodgess
Hi again. I'm putting together a little project with R, python, and a website. So I have an HTML file, a py file, an R file. Here is the HTML file: form action=/cgi-bin/radio4.py method=post target=_blank input type=radio name=subject value=Integrate / Integrate input type=radio name=subject

[R] Rterm

2013-10-30 Thread Patrick Rioux
Hi, Whenever I try to open R from Emacs, it says : apply: Searching for program: permission denied, Rterm I have the new ESS with the latest Emacs version and R-3.0.2. Also, when I open Emacs, it says : No version of R could be found on your system. I wonder if there is anything I could do to

[R] Irregular time series frequencies

2013-10-30 Thread sartene
Hi everyone, I have a data frame with email addresses in the first column and in the second column a list of times (of different lengths) at which an email was sent from the user in the first column. Here is an example of my data: Email Email_sent j...@doe.com 2013-09-26 15:59:55 2013-09-27

[R] getting p-value for comparing to gam's from gmcv

2013-10-30 Thread Robert Lynch
I am trying to compare two different GAM fits. I have something like Course.bam20 -bam(zGrade ~ Rep + ISE + White + Female + Years + AP_TOTAL + MATH + HSGPA+ EOP + factor(P7APrior, ordered = FALSE)+s(Yfrm7A,k=20), data= Course, na.action = na.exclude,samfrac =0.1) Course.bam4 -bam(zGrade ~ Rep

Re: [R] an rpy2, R cgi type question

2013-10-30 Thread Collin Lynch
Erin can you share the internal error details? As a first guess are the files executable by all? CGI requires world rwx. Best, Collin. On Wed, 30 Oct 2013, Erin Hodgess wrote: Hi again. I'm putting together a little project with R, python, and a website. So I have an HTML

Re: [R] an rpy2, R cgi type question

2013-10-30 Thread Erin Hodgess
Hi again: Here is the web output: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmas...@erinm.info and inform them of the time the error occurred, and anything you might