Re: [R] somebody help me about this error message...

2010-02-27 Thread Allan Engelhardt
You forgot the assign the second time: assign(paste(a,2,sep=), 4) does what you want. Hope this helps a little Allan. On 27/02/10 05:13, Joseph Lee wrote: I created variables automatically like this way for(i in 1:5){ nam- paste(a,i,sep=) assign(nam,1:i) } and then, i want

Re: [R] Help Computing Probit Marginal Effects

2010-02-27 Thread Ted Harding
On 27-Feb-10 03:52:19, Cardinals_Fan wrote: Hi, I am a stata user trying to transition to R. Typically I compute marginal effects plots for (example) probit models by drawing simulated betas by using the coefficient/standard error estimates after I run a probit model. I then use these

Re: [R] Preserving lists in a function

2010-02-27 Thread baptiste auguie
Hi, I think I would follow this approach too, using updatelist() from the reshape package, updatelist - function (x, y) { common - intersect(names(x), names(y)) x[common] - y[common] x } myfunction=function(list1=NULL, list2=NULL, list3=NULL){ list1=updatelist(list(variable1=1,

Re: [R] Error in mvpart example

2010-02-27 Thread Gavin Simpson
These functions (rpart, the mvpart wrapper, and summary.rpart) are fairly complex doing many things. For contributed packages you'd be best served by contacting the author/maintainer. I've CC'd Glenn (the maintainer) here. HTH G On Fri, 2010-02-26 at 13:55 +, Wearn, Oliver wrote: Dear

Re: [R] counting the number of ones in a vector

2010-02-27 Thread Gavin Simpson
On Fri, 2010-02-26 at 10:43 -0800, David Reinke wrote: The length will remain the same no matter what expression appears in the subscript. No it won't! x == 1 evaluates to logical and when used to *subset* x, it *will* return the required answer. As observed with this example: set.seed(1) x

Re: [R] Preserving lists in a function

2010-02-27 Thread Gabor Grothendieck
Or use modifyList which is in the core of R. On Sat, Feb 27, 2010 at 5:22 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, I think I would follow this approach too, using updatelist() from the reshape package, updatelist - function (x, y) {    common - intersect(names(x),

Re: [R] two questions for R beginners

2010-02-27 Thread Johannes Huesing
Dieter Menne dieter.me...@menne-biomed.de [Fri, Feb 26, 2010 at 08:39:14AM CET]: Patrick Burns wrote: * What were your biggest misconceptions or stumbling blocks to getting up and running with R? (This derives partly from teaching) [...] The concept of environment. With

Re: [R] Help Computing Probit Marginal Effects

2010-02-27 Thread Peter Ehlers
On 2010-02-27 1:38, (Ted Harding) wrote: On 27-Feb-10 03:52:19, Cardinals_Fan wrote: Hi, I am a stata user trying to transition to R. Typically I compute marginal effects plots for (example) probit models by drawing simulated betas by using the coefficient/standard error estimates after I

[R] reading data from web data sources

2010-02-27 Thread Tim Coote
Hullo I'm trying to read some time series data of meteorological records that are available on the web (eg http://climate.arm.ac.uk/calibrated/soil/dsoil100_cal_1910-1919.dat) . I'd like to be able to read in the digital data directly into R. However, I cannot work out the right function and

[R] Overlap plot

2010-02-27 Thread abotaha
Hello, I have plot in R (which is curve during time series) and it is working well. i want to add a circle symbol to one place within the plot but i do not know how to do that? I used matplot() because i have many data in the plot. any help please, cheers -- View this message in

Re: [R] reading data from web data sources

2010-02-27 Thread Gabor Grothendieck
Try this. First we read the raw lines into R using grep to remove any lines containing a character that is not a number or space. Then we look for the year lines and repeat them down V1 using cumsum. Finally we omit the year lines. myURL -

Re: [R] Overlap plot

2010-02-27 Thread jim holtman
points(x, y, pch=1, cex=10) adjust cex to the size circle you want. On Sat, Feb 27, 2010 at 4:22 AM, abotaha yaseen0...@gmail.com wrote: Hello, I have plot in R (which is curve during time series) and it is working well. i want to add a circle symbol to one place within the plot but i do

Re: [R] two questions for R beginners

2010-02-27 Thread John Sorkin
I don't think I am a tyro but neither am I a wizard. This being said R has a number of aspects that make it difficult. Error messages that are not helpful Manual pages that are written in Martin. Lack of examples on some manual pages Lack of comments in code There are other hurdles. The concept

Re: [R] R Aerodynamic Package(s)?

2010-02-27 Thread Jason Rupert
I received zero responses to this post, so I guess this confirms that R is not the correct target language for this project. Maybe Octave is better suited... Thank you again. - Original Message From: Jason Rupert jasonkrup...@yahoo.com To: R-help@r-project.org Cc: Me

Re: [R] Preserving lists in a function

2010-02-27 Thread Barry Rowlingson
On Sat, Feb 27, 2010 at 11:29 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Or use modifyList which is in the core of R. All these solutions appear to be adding on more and more code with less and less semantics. Result: messy code which is harder to read and debug. It seems that the

Re: [R] Random Forest

2010-02-27 Thread Dror
Hi, I'm working with randomForest package and i have 2 questions: 1. how can i drop a specific tree from the forest? 2. i'm trying to get the voting of each tree in a prediction datum using the folowing code pr-predict(RF,NewData,type=prob,predict.all=TRUE) my forest has 300 trees and i get

Re: [R] simple main effect.

2010-02-27 Thread Or Duek
I am very new to R and thus find those examples a bit confusing although I believe the solution to my problems lies there. Lets take for example an experiment in which I had two between subject variables - Strain and treatment, and one within - exposure. all the variables had 2 levels each. I

Re: [R] Error in mvpart example

2010-02-27 Thread Peter Ehlers
On 2010-02-26 6:55, Wearn, Oliver wrote: Dear all, I'm getting an error in one of the stock examples in the 'mvpart' package. I tried: require(mvpart) data(spider) fit3- rpart(gdist(spider[,1:12],meth=bray,full=TRUE,sq=TRUE)~water+twigs+reft+herbs+moss+sand,spider,method=dist) #directly

Re: [R] Preserving lists in a function

2010-02-27 Thread baptiste auguie
Point well taken --- grid::gpar() is also a good example; I'll make use of your suggestion in my future coding. Best, baptiste On 27 February 2010 15:02, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sat, Feb 27, 2010 at 11:29 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote:

[R] R from Java (cluster heatmaps)

2010-02-27 Thread Rameswara Sashi Kiran Challa
Hello All, I am trying to get cluster heatmaps using R from Java in my application. I got the Rserve using which I am able to make TCP/IP connection to R. I am trying to send a double[][] array (say 5x8 dimensions) to R and convert it into matrix using as.matrix() function in R. Is it correct to

Re: [R] Error in mvpart example

2010-02-27 Thread Glenn De'ath
Thanks for the info -- I'll check it out ASAP. Regards Glenn +++ Glenn De'ath Principal Research Scientist Australian Institute of Marine Science Ph: +61-7-4758-1747; +61-7-4753-4314 In a world without walls and fences, who needs windows and gates.

Re: [R] somebody help me about this error message...

2010-02-27 Thread John Kane
paste(a,2,sep=) is simply creating a new character a2 Why not just a2 - 4 ? --- On Sat, 2/27/10, Joseph Lee seokhyun...@gmail.com wrote: From: Joseph Lee seokhyun...@gmail.com Subject: [R] somebody help me about this error message... To: r-help@r-project.org Received: Saturday, February

Re: [R] How to add a variable to a dataframe whose values are conditional upon the values of an existing variable

2010-02-27 Thread Greg Snow
Here is another approach (I think this is the simplest): daylkp - c(SAT=1, SUN=2, MON=3, TUE=4, WED=5, THU=6, FRI=7) tmp.in - sample( names(daylkp), 25, TRUE ) tmp.out - daylkp[tmp.in] names(tmp.out) - NULL # optional hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center

[R] Newbie help with ANOVA and lm.

2010-02-27 Thread rkevinburton
Would someone be so kind as to explain in English what the ANOVA code (anova.lm) is doing? I am having a hard time reconciling what the text books have as a brute force regression and the formula algorithm in 'R'. Specifically I see: p - object$rank if (p 0L) { p1 - 1L:p

Re: [R] simple main effect.

2010-02-27 Thread DrorD
I tried to implement Ista's procedure and would like to provide it as a working example, with the intention to get feedback from the R community: The data contains three variables: One dependent var: t.total and two independent vars: group (between: D2C2, C2D2) and present.type (within: C2, D2).

[R] scan and skip - without line breaks in the input file

2010-02-27 Thread Balzer Susanne
Dear all, I am trying to read in big amounts of data with scan. It's only one variable, numeric values, separated by tabs,.. and it's many of them. So I was thinking that I could use the skip option and read in 10 values at a time - but skip doesn't work, probably because I don't have line

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 11:24 AM, Balzer Susanne wrote: Dear all, I am trying to read in big amounts of data with scan. It's only one variable, numeric values, separated by tabs,.. and it's many of them. So I was thinking that I could use the skip option and read in 10 values at a time

Re: [R] Defective help pages

2010-02-27 Thread Duncan Murdoch
On 26/02/2010 3:22 PM, Peter Danenberg wrote: This seems to be plain text help, right? It is. Does the html version give the same result? Interestingly, the html seems to be whole; but it's less convenient to access from ESS, though. Do you know what program generates the plain text; and

Re: [R] Newbie help with ANOVA and lm.

2010-02-27 Thread Peter Ehlers
On 2010-02-27 8:53, rkevinbur...@charter.net wrote: Would someone be so kind as to explain in English what the ANOVA code (anova.lm) is doing? I am having a hard time reconciling what the text books have as a brute force regression and the formula algorithm in 'R'. Specifically I see:

Re: [R] using grep

2010-02-27 Thread Greg Snow
Look at the gsubfn package, it gives more options and will probably make what you are trying to do easier. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org

Re: [R] reading data from web data sources

2010-02-27 Thread Gabor Grothendieck
Mark Leeds pointed out to me that the code wrapped around in the post so it may not be obvious that the regular expression in the grep is (i.e. it contains a space): [^ 0-9.] On Sat, Feb 27, 2010 at 7:15 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this.  First we read the raw

Re: [R] using grep

2010-02-27 Thread Gabor Grothendieck
Here it is using strapply in gsubfn. x is the input, followed by the regular expression which is just New York followed by a parenthesized string of digits. The parenthesized portion is passed to the function, as.numeric, and then everything is simplified using c (otherwise we would get a list as

Re: [R] Converting IEEE Float in 16 char hex back to float

2010-02-27 Thread Duncan Murdoch
On 27/02/2010 12:43 AM, xlr82sas wrote: Hi, If I do the following sprintf(%A,pi) 0X1.921FB54442D18 I have this 16 byte character string hx-400921FB54442D18 This is the exact hex16 representation of PI in IEEE float that R uses in Intel 32bit(little endian) Windows SAS uses the same

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 11:47 AM, Balzer Susanne wrote: Hei David, Thanks for your quick response, but unfortunately n and nmax alone don't do the job. If I want to read items no. 11 to 20, the n=10 option will work, but skip=10 (to NOT read the first 10 items) won't.

Re: [R] Help Computing Probit Marginal Effects

2010-02-27 Thread Cardinals_Fan
One last question. I'm trying to use the rnorm() function to draw a distribution for my coefficient estimates. Let's say I have a model y* = a + b1x1. I have the coefficient estimate for b1 stored as b1 and the standard error estimate for b1 stored as s1. I run rnorm function as a -

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread Balzer Susanne
Hi David, That looks magic and works - if and only if you keep the file connection open. Cool, that was the hint I needed! scan(myfile.txt, nmax=10) will always give you the first 10 items, obviously. However, I did the workaround with tr under unix now and changed all the tabs into line

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread Peter Ehlers
David, Susanne, There may be a misunderstanding here. As I understand it, Susanne wants to be able to read the _second_ (and third, etc) 100K values after reading the first 100K, presumably to be processed separately for reasons I can't imagine. If that is correct, then I have no solution other

Re: [R] two questions for R beginners

2010-02-27 Thread xlr82sas
Hi, I don't think you should split the list for beginners. On the SAS list we get questions from novices such as secretaries, janitorial services, human resources and even top executives. They often approach SAS from a very intuitive standpoint. These questions often shake the experts

Re: [R] Help Computing Probit Marginal Effects

2010-02-27 Thread Peter Ehlers
On 2010-02-27 10:57, Cardinals_Fan wrote: One last question. I'm trying to use the rnorm() function to draw a distribution for my coefficient estimates. Let's say I have a model y* = a + b1x1. I have the coefficient estimate for b1 stored as b1 and the standard error estimate for b1 stored

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread Peter Ehlers
Talk about asleep at the switch. My sincere apologies to both Susanne and David for my stupid message and to group for wasting everyone's time. Ouch, that headslap hurt. -Peter On 2010-02-27 11:05, Peter Ehlers wrote: David, Susanne, There may be a misunderstanding here. As I understand it,

Re: [R] Help Computing Probit Marginal Effects

2010-02-27 Thread Ted Harding
On 27-Feb-10 17:57:56, Cardinals_Fan wrote: One last question. I'm trying to use the rnorm() function to draw a distribution for my coefficient estimates. Let's say I have a model y* = a + b1x1. I have the coefficient estimate for b1 stored as b1 and the standard error estimate for b1

Re: [R] two questions for R beginners

2010-02-27 Thread xlr82sas
Hi, I don't think you should split the list for beginners. On the SAS list we get questions from novices such as secretaries, janitorial services, human resources and even top executives. They often approach SAS from a very intuitive standpoint. These questions often shake the experts

Re: [R] R Aerodynamic Package(s)?

2010-02-27 Thread Charles Annis, P.E.
Jason: What are you trying to do? Your reference link provides several Fortran programs. Why can't you use those? Or you could translate them into R code if you would like to take advantage of R's wonderful graphics and multitudinous other statistical adjuncts. Your request seems too broad to

Re: [R] Converting IEEE Float in 16 char hex back to float

2010-02-27 Thread xlr82sas
Thanks Nice code. I appreciate the function. I don't know if you ever use SAS datasets but I am working with the devloper of 'dsread' to create a lossless transfer from SAS to R. I am also working on an in memory Java interface which would allow me to mix SAS and R code. Here is the link to

[R] Bug in ecdf? Or what am I missing?

2010-02-27 Thread Ajay Shah
x - c(6.6493705109108, 7.1348436721241, 8.76886994525624, 6.12907548096037, 6.88379118678109, 7.17841879427688, 7.90737237492867, 7.1207373264833, 7.82949407630692, 6.90411547316105) plot(ecdf(x), log=x) It does the plot fine, but complains: Warning message: In

[R] Best Hardware OS For Large Data Sets

2010-02-27 Thread J. Daniel
Greetings, I am acquiring a new computer in order to conduct data analysis. I currently have a 32-bit Vista OS with 3G of RAM and I consistently run into memory allocation problems. I will likely be required to run Windows 7 on the new system, but have flexibility as far as hardware goes. Can

Re: [R] Overlap plot

2010-02-27 Thread abotaha
Thank you for this simple help. It is sufficient for my plot. cheers. -- View this message in context: http://n4.nabble.com/Overlap-plot-tp1571803p1572061.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

Re: [R] scan and skip - without line breaks in the input file

2010-02-27 Thread Balzer Susanne
Hei David, Thanks for your quick response, but unfortunately n and nmax alone don't do the job. If I want to read items no. 11 to 20, the n=10 option will work, but skip=10 (to NOT read the first 10 items) won't. Or with your example, scan(textConnection('1 2 3 4 5 6 7'),

Re: [R] R Aerodynamic Package(s)?

2010-02-27 Thread Sharpie
Charles Annis, P.E. wrote: Jason: What are you trying to do? Your reference link provides several Fortran programs. Why can't you use those? Or you could translate them into R code if you would like to take advantage of R's wonderful graphics and multitudinous other statistical

Re: [R] Best Hardware OS For Large Data Sets

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 12:47 PM, J. Daniel wrote: Greetings, I am acquiring a new computer in order to conduct data analysis. I currently have a 32-bit Vista OS with 3G of RAM and I consistently run into memory allocation problems. I will likely be required to run Windows 7 on the new

Re: [R] reading data from web data sources

2010-02-27 Thread Tim Coote
Thanks, Gabor. My take away from this and Phil's post is that I'm going to have to construct some code to do the parsing, rather than use a standard function. I'm afraid that neither approach works, yet: Gabor's gets has an off-by-one error (days start on the 2nd, not the first), and the

Re: [R] two questions for R beginners

2010-02-27 Thread Kingsford Jones
On Fri, Feb 26, 2010 at 8:00 AM, Robert Baer rb...@atsu.edu wrote: [...] The things that led from frustration to independence was understanding the difference between data types like matrix and dataframe and learning there were commands to tell what you were working with at any given time. Did

Re: [R] Best Hardware OS For Large Data Sets

2010-02-27 Thread Sharpie
David Winsemius wrote: Perhaps the fact that the stable CRAN version of R for (any) Windows is 32-bit? It would expand your memory space somewhat but not as much as you might naively expect. (There was a recent announcement that an experimental version of a 64- bit R was

Re: [R] How to add a variable to a dataframe whose values are conditional upon the values of an existing variable

2010-02-27 Thread David Freedman
there's a recode function in the Hmisc package, but it's difficult (at least for me) to find documentation for it library(Hmisc) week - c('SAT', 'SUN', 'MON', 'FRI'); recode(week,c('SAT', 'SUN', 'MON', 'FRI'),1:4) HTH -- View this message in context:

Re: [R] Best Hardware OS For Large Data Sets

2010-02-27 Thread Tim Coote
Is it possible to run a Linux guest VM on the Wintel box so that you can run the 64 bit code? I used to do this on XP (but not for R). On 27 Feb 2010, at 20:03, David Winsemius wrote: On Feb 27, 2010, at 12:47 PM, J. Daniel wrote: Greetings, I am acquiring a new computer in order to

Re: [R] reading data from web data sources

2010-02-27 Thread Gabor Grothendieck
No one else posted so the other post you are referring to must have been an email to you, not a post. We did not see it. By one off I think you are referring to the row names, which are meaningless, rather than the day numbers. The data for day 1 is present, not missing. The example code did

Re: [R] simple main effect.

2010-02-27 Thread RICHARD M. HEIBERGER
Lets take for example an experiment in which I had two between subject variables - Strain and treatment, and one within - exposure. all the variables had 2 levels each. I found an interaction between exposure and Strain and I want to compare Strain A and B under every exposure (first and

Re: [R] reading data from web data sources

2010-02-27 Thread Phil Spector
Sorry, I forgot to cc the group: Tim - Here's a way to read the data into a list, with one entry per year: x = read.table('http://climate.arm.ac.uk/calibrated/soil/dsoil100_cal_1910-1919.dat', header=FALSE,fill=TRUE,skip=13) cts = apply(x,1,function(x)sum(is.na(x))) wh =

Re: [R] reading data from web data sources

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 4:33 PM, Gabor Grothendieck wrote: No one else posted so the other post you are referring to must have been an email to you, not a post. We did not see it. By one off I think you are referring to the row names, which are meaningless, rather than the day numbers. The data

[R] help with Gantt chart

2010-02-27 Thread Zoppoli, Gabriele (NIH/NCI) [G]
Hi, I don't know to solve this error that is returned, even though I understand it: library(plotrix) Ymd.format-%Y/%m/%d gantt.info-list(labels= c(First task,Second task (1st part),Third task (1st part),Second task (2nd part),Third task (2nd part), Fourt task,Fifth task,Sixth task),

Re: [R] New methods for generic functions show and print : some visible with ls(), some not

2010-02-27 Thread Joris Meys
Thank you both for your answers. On Fri, Feb 26, 2010 at 7:58 PM, Duncan Murdoch murd...@stats.uwo.cawrote: You aren't seeing the print method, you are seeing a newly created print generic function. As Uwe mentioned, print() is not an S4 generic, so when you create your print method, a new

Re: [R] reading data from web data sources

2010-02-27 Thread Phil Spector
Tim - I don't understand what you mean about interleaving rows. I'm guessing that you want a single large data frame with all the data, and not a list with each year separately. If that's the case: x = read.table('http://climate.arm.ac.uk/calibrated/soil/dsoil100_cal_1910-1919.dat',

[R] Combining 2 columns into 1 column many times in a very large dataset

2010-02-27 Thread Sherri Rose
*Combining 2 columns into 1 column many times in a very large dataset* The clumsy solutions I am working on are not going to be very fast if I can get them to work and the true dataset is ~1500 X 45000 so they need to be efficient. I've searched the R help files and the archives for this list

Re: [R] New methods for generic functions show and print : some visible with ls(), some not

2010-02-27 Thread Duncan Murdoch
On 27/02/2010 6:15 PM, Joris Meys wrote: Thank you both for your answers. On Fri, Feb 26, 2010 at 7:58 PM, Duncan Murdoch murd...@stats.uwo.cawrote: You aren't seeing the print method, you are seeing a newly created print generic function. As Uwe mentioned, print() is not an S4 generic, so

[R] Change the scale on a barplot's y axis

2010-02-27 Thread Thomas Levine
I have grades data. I read them from a csv in letter-grade format. I then converted them to levels levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') And then to numbers grades$gp=grades$grade levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)

[R] Reducing a matrix

2010-02-27 Thread Juliet Ndukum
I wish to rearrange the matrix, df, such that all there are not repeated x values. Particularly, for each value of x that is reated, the corresponded y value should fall under the appropriate column. For example, the x value 3 appears 4 times under the different columns of y, i.e. y1,y2,y3,y4.

Re: [R] Reducing a matrix

2010-02-27 Thread Linlin Yan
Try this: df[!duplicated(df[,'x']),] On Sun, Feb 28, 2010 at 8:56 AM, Juliet Ndukum jpnts...@yahoo.com wrote: I wish to rearrange the matrix, df, such that all there are not repeated x values. Particularly, for each value of x that is reated, the corresponded y value should fall under the

Re: [R] reading data from web data sources

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 6:17 PM, Phil Spector wrote: Tim - I don't understand what you mean about interleaving rows. I'm guessing that you want a single large data frame with all the data, and not a list with each year separately. If that's the case: x =

Re: [R] Automate generation of multiple reports using odfWeave

2010-02-27 Thread Max Kuhn
On a more complicated note, is there a way to embed the station name in a header or footer of the document? It seems there is no way to evaluate a chunk or an inline \Sexpr{...} in a header or footer? This would put station ID on every report page, making reading comparing multiple reports

Re: [R] Change the scale on a barplot's y axis

2010-02-27 Thread S Ellison
Thomas, You could perhaps do a tad better by simply adding a right-hand-side axis using axis(): axis(4, at=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7), labels=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-'), las=1) That way you have both numeric and grade scales. if you

Re: [R] Reducing a matrix

2010-02-27 Thread Jorge Ivan Velez
Hi Juliet, Here is a suggestion using aggregate(): # aux function foo - function(x){ y - sum(x, na.rm = TRUE) ifelse(y==0, NA, y) } # result aggregate(df[,-1], list(df$x), foo) Here, df is your data. HTH, Jorge On Sat, Feb 27, 2010 at 7:56 PM, Juliet

Re: [R] Change the scale on a barplot's y axis

2010-02-27 Thread Thomas Levine
Yay! That's perfect. Thanks, Steve! Tom 2010/2/27 S Ellison s.elli...@lgc.co.uk: Thomas, You could perhaps do a tad better by simply adding a right-hand-side axis using axis(): axis(4, at=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7),

Re: [R] Combining 2 columns into 1 column many times in a very large datasetB

2010-02-27 Thread Phil Spector
Sherri - Here's one way: nms = c('rs123','rs157','rs132') lowf = function(one,two){ both = paste(pop[[one]],pop[[two]],sep='') tt = table(both) lowfreq = names(tt)[which.min(tt)] ifelse(both == lowfreq,1,0) } res = mapply(lowf,nms,paste(nms,'.1',sep=''),SIMPLIFY=FALSE)

[R] Which system.time() component to use?

2010-02-27 Thread Ravi Varadhan
Hi, The `system.time(expr)' command provide 3 different times for evaluating the expression `expr'; the first two are user and system CPUs and the third one is total elapsed time. Suppose I want to compare two different computational procedures for performing the same task, which component

Re: [R] Reducing a matrix

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 8:43 PM, Jorge Ivan Velez wrote: Hi Juliet, Here is a suggestion using aggregate(): # aux function foo - function(x){ y - sum(x, na.rm = TRUE) ifelse(y==0, NA, y) } # result aggregate(df[,-1], list(df$x), foo) That does work in this

Re: [R] Which system.time() component to use?

2010-02-27 Thread Gabor Grothendieck
Try this: system.time(Sys.sleep(60)) user system elapsed 0.000.00 60.05 pt - proc.time(); Sys.sleep(60); proc.time() - pt user system elapsed 0.000.00 60.01 On Sat, Feb 27, 2010 at 9:33 PM, Ravi Varadhan rvarad...@jhmi.edu wrote: Hi, The `system.time(expr)'

[R] lapply with data frame

2010-02-27 Thread Noah Silverman
I'm a bit confused on how to use lapply with a data.frame. For example. lapply(data, function(x) print(x)) WHAT exactly is passed to the function. Is it each ROW in the data frame, one by one, or each column, or the entire frame in one shot? What I want to do apply a function to each row

[R] Error in tapply when reordering levels of a factor

2010-02-27 Thread Thomas Levine
I have this grades$grade ... [4009] A B A- A- A- B+ A A- B+ B A B B B A A- A A- A- B+ A- A A B+ [4033] A- A- A- A A- B A A A- A Levels: A A- A+ B B- B+ C C+ I want to change the order of the levels reorder(grades$grade,c('A+','A','A-','B+','B','B-','C+','C')) Error in

Re: [R] lapply with data frame

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 9:49 PM, Noah Silverman wrote: I'm a bit confused on how to use lapply with a data.frame. For example. lapply(data, function(x) print(x)) WHAT exactly is passed to the function. Is it each ROW in the data frame, No. one by one, or each column, Yes. Dataframes

Re: [R] lapply with data frame

2010-02-27 Thread jim holtman
x - read.table(textConnection(idgroupvalue + 1A3.2 + 2A3.0 + 3A3.1 + 4B5.5 + 5B6.0 + 6B6.2), header=TRUE) # dataframe is processed by column by lapply lapply(x, c) $id [1] 1 2 3 4 5 6 $group

Re: [R] Error in tapply when reordering levels of a factor

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 10:01 PM, Thomas Levine wrote: I have this grades$grade ... [4009] A B A- A- A- B+ A A- B+ B A B B B A A- A A- A- B+ A- A A B+ [4033] A- A- A- A A- B A A A- A Levels: A A- A+ B B- B+ C C+ I want to change the order of the levels

Re: [R] reading data from web data sources

2010-02-27 Thread Gabor Grothendieck
Here is a continuation to turn DF into a zoo series: It depends on the fact that all NAs are structural, i.e. they indicate dates which cannot exist such as Feb 31 as opposed to missing data. dd is the data as one long series with component names being the dates in the indicated format. That

[R] Editing a function

2010-02-27 Thread learner1978
I am beginner to R. I have written a function: f= function(n=100,p=0.5){ X=rbinom(100,n,p) (mean(X)-n*P)/sqrt(n*p*(1-p)) } But I made a mistake by typing P instead of p. How do I edit this function and improve my mistake. If I use edit(f) it opens an edit window where I am able to change the

[R] pass an array of array from Java to R- Rserve

2010-02-27 Thread Rameswara Sashi Kiran Challa
hello all, Could someone please tell me how should I pass a double[][] (matrix of any size) that I have in Java, into R using Rserve. Thanks Sashikiran -- Sashikiran Challa MS Cheminformatics, School of Informatics and Computing, Indiana University, Bloomington,IN scha...@indiana.edu

Re: [R] bwplot() {lattice}

2010-02-27 Thread Peng Cai
Thanks a lot Deepayan, one question: Is it possible to place these barplots side-by-side instaed of super imposing? Something like this: http://www.imachordata.com/wp-content/uploads/2009/09/boxplot.png library(lattice) bwplot(yield ~ variety, data = barley, col = 1, pch = 16, panel =

Re: [R] Editing a function

2010-02-27 Thread Ben Bolker
learner1978 sakp4mcl at gmail.com writes: I am beginner to R. I have written a function: f= function(n=100,p=0.5){ X=rbinom(100,n,p) (mean(X)-n*P)/sqrt(n*p*(1-p)) } But I made a mistake by typing P instead of p. How do I edit this function and improve my mistake. Two answers:

Re: [R] Editing a function

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 11:15 PM, Ben Bolker wrote: learner1978 sakp4mcl at gmail.com writes: I am beginner to R. I have written a function: f= function(n=100,p=0.5){ X=rbinom(100,n,p) (mean(X)-n*P)/sqrt(n*p*(1-p)) } But I made a mistake by typing P instead of p. How do I edit this function

Re: [R] Which system.time() component to use?

2010-02-27 Thread Ravi Varadhan
Thanks, Gabor. Your reply is helpful, but it still doesn't answer whether I should use the sum of the first two components of system.time (user + system CPU) or only the first one (user CPU). Ravi. Ravi Varadhan, Ph.D.

Re: [R] Reducing a matrix

2010-02-27 Thread jim holtman
Will this work for you: x - read.table(textConnection( x y1 y2 y3 y4 + 1 3 7 NA NA NA + 2 3 NA 16 NA NA + 3 3 NA NA 12 NA + 4 3 NA NA NA 18 + 5 6 8 NA NA NA + 6 10 NA NA 2 NA + 7 10 NA 11 NA NA + 8 14 NA NA NA 8 + 9 14 NA 9 NA NA + 10 15 NA NA NA 11 + 11 50 NA NA 13 NA + 12

Re: [R] Which system.time() component to use?

2010-02-27 Thread Gabor Grothendieck
The last component seems the most meaningful since its the amount of time you actually waited for the code to run. On Sat, Feb 27, 2010 at 11:44 PM, Ravi Varadhan rvarad...@jhmi.edu wrote: Thanks, Gabor.  Your reply is helpful, but it still doesn't answer whether I should use the sum of the

Re: [R] Which system.time() component to use?

2010-02-27 Thread Gabor Grothendieck
Also you might want to try out this which will repeatedly run your benchmarks to average out the values and make comparisons easier: http://rbenchmark.googlecode.com On Sat, Feb 27, 2010 at 11:55 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: The last component seems the most

Re: [R] Which system.time() component to use?

2010-02-27 Thread jim holtman
A lot depends on what you are trying to measure. You should add the system and user CPU times to get a better idea of the CPU utilization. For some classes of problems it might be good to separate them if you were doing a lot of I/O or other system calls that might be using time, but for 99% of

Re: [R] help with Gantt chart

2010-02-27 Thread jim holtman
You might want to debug your data. Anytime there is an error message, take a look at your data. You have some illegal dates in your 'end' (2010/9/31 2010/6/31 are not legal and are probably causing your error). Simply printing out your test data would have shown that: gantt.info $labels [1]

[R] Types of missingness

2010-02-27 Thread Christian Raschke
Dear R-List, My questions concerns missing values. Specifically, is is possible to use different types of missingness in a dataset and not a one-size-fits-all NA? For example, data may be missing because of an outright refusal by a respondent to answer a question, or because she didn't know an

Re: [R] Reducing a matrix

2010-02-27 Thread Dimitris Rizopoulos
if you don't mind having zeros instead of NAs, then yet another solution is: df - read.table(textConnection(x y1 y2 y3 y4 1 3 7 NA NA NA 2 3 NA 16 NA NA 3 3 NA NA 12 NA 4 3 NA NA NA 18 5 6 8 NA NA NA 6 10 NA NA 2 NA 7 10 NA 11 NA NA 8 14 NA NA NA 8 9 14 NA 9 NA NA 10 15 NA NA