Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread Joshua Wiley
Hi, Here is a little function that will do what you want and return a nice output: #Function To calculate top two values and return my.finder - function(mydata) { my.fun - function(data) { strongest - which.max(data) secondstrongest - which.max(data[-strongest]) strongestantenna -

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread Joshua Wiley
Maybe efficiency is less of an issue than I thought, on 2 million rows, it only took a bit over a minute, and my system only jumped up ~ 600 MB of memory so it wasn't much of a strain there either. data.test - matrix( + sample(seq(min(yourdata),max(yourdata)), size = 1000, replace = TRUE),

Re: [R] , Updating Table

2010-07-24 Thread Linlin Yan
If I am not wrong, it seems that you want to get factor counts in the whole scale of data.raw. Maybe you can do that just like this: table(data.raw) On Sat, Jul 24, 2010 at 1:44 AM, Marcus Liu marcusliu...@yahoo.com wrote: Hi everyone, Is there any command for updating table withing a loop? 

Re: [R] union data in column

2010-07-24 Thread Jeff Newmiller
Fahim Md wrote: Is there any function/way to merge/unite the following data GENEID col1 col2 col3col4 G234064 1 0 0 0 G234064 1 0 0 0

Re: [R] How to import simple java/mathematica expression to R

2010-07-24 Thread Andrey Siver
Hello, 2010/7/24 jim holtman jholt...@gmail.com: Well, I took you equation and put the following at the start: Power - function(x,y) x^y EE - function(x) x alp - 2 x - 900*Power(-0.2030178326474623 + 0.23024073983368956*(1 - alp) + ... Actually, there are many functions like this

Re: [R] How to import simple java/mathematica expression to R

2010-07-24 Thread Andrey Siver
2010/7/24 David Winsemius dwinsem...@comcast.net: On Jul 23, 2010, at 10:29 PM, jim holtman wrote: It has some interesting properties with that identity definition of EE(x). Local maxima at 1 and 0, blows up beyond -1 and 2, and several local minima nearby: Math.Fn - function(alp) {

[R] Understanding Prototype of class

2010-07-24 Thread Christofer Bogaso
Hi R gurus, here I am trying to understand how R define and work with the prototype property in class definition. Here I have created a class: setClass(a, representation=list(x=numeric, y=character)) [1] a As I did not explicitly define the prototype in above code, R is supposed to generate

Re: [R] interpretation of stress in NMDS

2010-07-24 Thread Thomas Petzoldt
On 7/22/2010 2:21 PM, Graves, Gregory wrote: Among those users of Primer, stress values greater than 0.3 are interpreted as questionable. Using both isoMDS and metaMDS (vegan package), the stress values returned are much higher using my own data and using examples provided in R Help. For

Re: [R] how to calculate the product of every two elements in two vectors

2010-07-24 Thread Dennis Murphy
as.vector(t(outer(A, B))) [1] 9 10 11 12 18 20 22 24 27 30 33 36 HTH, Dennis On Fri, Jul 23, 2010 at 8:11 AM, aegea gche...@gmail.com wrote: Thanks in advance! A=c(1, 2,3) B=c (9, 10, 11, 12) I want to get C=c(1*9, 1*10, 1*11, 1*12, ., 3*9, 3*10, 3*11, 3*12)? C is still a vector

Re: [R] Question regarding panel data diagnostic

2010-07-24 Thread Setlhare Lekgatlhamang
My thought is this: It depends on what you have in the panel. Are your data cross-section data observed over ten years for, say, 3 countries (or regions within the same country)? If so, yes you can perform integration properties (what people usually call unit root test) and then test for

Re: [R] Question regarding panel data diagnostic

2010-07-24 Thread Setlhare Lekgatlhamang
Let me correct an omission in my response below. The last sentence should read But if the data are 10 quarterly or monthly values, these techniques are not relevant. Cheers Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of

Re: [R] Question regarding panel data diagnostic

2010-07-24 Thread Setlhare Lekgatlhamang
Let me correct an omission in my response below. The last sentence should read But if the data are 10 quarterly or monthly values, these techniques are not relevant. Cheers Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread David Winsemius
On Jul 23, 2010, at 9:20 PM, mpw...@illinois.edu wrote: I have a data frame with a couple million lines and want to retrieve the largest and second largest values in each row, along with the label of the column these values are in. For example row 1 strongest=-11072 secondstrongest=-11707

[R] local polynomial with differnt kernal functions

2010-07-24 Thread assaedi76 assaedi76
Hi, R users   I need to use the function (locpoly) to fit a local poynomial regression model, The defult for kernal function is normal , but  I need to use different kernal functions such as :Uniform,Triangular,Epanechnikov,.. Could someone help me define these functions to fit local

[R] Weights in mixed models

2010-07-24 Thread David R.
Hello everyone, I wonder if sample size can be used as weight  in a weighted mixed model. Or should I use just the inverse of the variance? For example, the class'lmer' in the 'lme4' package have an option 'weights' (as in the class 'lm' of 'stats'). In the help of lme4 there is an example

Re: [R] Odp: Help me with prediction in linear model

2010-07-24 Thread Research student
Thanks Murphy and pikal, I need another help,for fitting first fourier transformation ,i used following thing .Please advise on this beer_monthl has 400+ records EXample: head(beer_monthly) beer 1 93.2 2 96.0 3 95.2 4 77.1 5 70.9 6 64.8 time-seq(1956,1995.2,length=length(beer_monthly))

Re: [R] union data in column

2010-07-24 Thread Hadley Wickham
On Sat, Jul 24, 2010 at 2:23 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Fahim Md wrote: Is there any function/way to merge/unite the following data  GENEID      col1          col2             col3                col4  G234064         1             0                  0                

Re: [R] UseR! 2010 - my impressions

2010-07-24 Thread Frank E Harrell Jr
On 07/23/2010 06:50 PM, Ravi Varadhan wrote: Dear UseRs!, Everything about UseR! 2010 was terrific! I really mean everything - the tutorials, invited talks, kaleidoscope sessions, focus sessions, breakfast, snacks, lunch, conference dinner, shuttle services, and the participants. The

Re: [R] , Updating Table

2010-07-24 Thread Charles C. Berry
On Fri, 23 Jul 2010, Marcus Liu wrote: Hi everyone, Is there any command for updating table withing a loop?? Loops? We don't need no stinking loops! (From 'The Good, the Bad, and the Rgly') tab - table(data.raw, findInterval(seq(along=data.raw), ind+1 ) ) tab %*%

Re: [R] , Updating Table

2010-07-24 Thread Duncan Murdoch
On 24/07/2010 11:25 AM, Charles C. Berry wrote: On Fri, 23 Jul 2010, Marcus Liu wrote: Hi everyone, Is there any command for updating table withing a loop?� Loops? We don't need no stinking loops! (From 'The Good, the Bad, and the Rgly') Actually, that quote comes from

Re: [R] glm - prediction of a factor with several levels

2010-07-24 Thread Ben Bolker
blackscorpio olivier.collignon at live.fr writes: I'm currently attempting to predict the occurence of an event (factor) having more than 2 levels with several continuous predictors. The model being ordinal, I was waiting the glm function to return several intercepts, which is not the case

[R] Doubt about a population competition function

2010-07-24 Thread Bruno Bastos Gonçalves
Hi, I'm doing a function that describe two populations in competition. that's the function that i wrote: exclusao-function(n10, n20, k1, k2, alfa, beta, t){ n1-k1-(alfa*n20) n2-k2-(beta*n10) if(t==0){plot(t, n10, type='b', xlim=range(c(1:t),c (1:t)), ylim=range(n10, n20), xlab='tempo',

[R] Doubt about a population competition function

2010-07-24 Thread Gmail
Hi, I'm doing a function that describe two populations in competition. that's the function that i wrote: exclusao-function(n10, n20, k1, k2, alfa, beta, t){ n1-k1-(alfa*n20) n2-k2-(beta*n10) if(t==0){plot(t, n10, type='b', xlim=range(c(1:t),c (1:t)), ylim=range(n10, n20), xlab='tempo',

[R] Book on R's Programming Language

2010-07-24 Thread Matt Stati
Can someone please recommend to me a book on the programming language that R is based on? I'm looking for a foundational book that teaches the logic of the S language. It seems that knowing the underpinnings of the language can only make using R a bit easier. Any leads are greatly appreciated

Re: [R] how to calculate the product of every two elements in two vectors

2010-07-24 Thread Henrique Dallazuanna
Try this: c(as.matrix(B) %*% A) On Fri, Jul 23, 2010 at 12:11 PM, aegea gche...@gmail.com wrote: Thanks in advance! A=c(1, 2,3) B=c (9, 10, 11, 12) I want to get C=c(1*9, 1*10, 1*11, 1*12, ., 3*9, 3*10, 3*11, 3*12)? C is still a vector with 12 elements Is there a way to do that?

Re: [R] Book on R's Programming Language

2010-07-24 Thread Joshua Wiley
Hi Matt, http://www.r-project.org/doc/bib/R-books.html Lists a variety of books, and seems to include most (i.e., my searches through google, amazon, and barnes and noble, didn't really turn up others) books dedicated to R. I have always been under the impression that Programming with Data

Re: [R] how to calculate the product of every two elements in two vectors

2010-07-24 Thread Gabor Grothendieck
On Fri, Jul 23, 2010 at 11:11 AM, aegea gche...@gmail.com wrote: Thanks in advance! A=c(1, 2,3) B=c (9, 10, 11, 12) I want to get C=c(1*9, 1*10, 1*11, 1*12, ., 3*9, 3*10, 3*11, 3*12)? C is still a vector with 12 elements Is there a way to do that? Here are yet a few more. The first

Re: [R] Book on R's Programming Language

2010-07-24 Thread Joseph Magagnoli
Matt, you might want to check out programming with data by John Chambers. http://www.amazon.com/Programming-Data-Guide-S-Language/dp/0387985034/ref=sr_1_1?ie=UTF8s=booksqid=1279990404sr=8-1 Best Joe On Sat, Jul 24, 2010 at 11:39 AM, Matt Stati mattst...@yahoo.com wrote: Can someone please

Re: [R] Constrain density to 0 at 0?

2010-07-24 Thread Greg Snow
Look at the logspline package. This is a different approach to density estimation from the kernel densities used by 'density', but does allow you to set fixed boundaries. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

[R] matest function for multiple factors

2010-07-24 Thread shabnam k
Hi, I am using maanova package for analysis. In my dataset, two fixed factors time and treatment and sample as random factor is there. Am able to get madata object and fitmaanova object. But, am unable to do f-test with two factors, but i have done f-test seperately for two factors.

Re: [R] How to deal with more than 6GB dataset using R?

2010-07-24 Thread Greg Snow
You may want to look at the biglm package as another way to regression models on very large data sets. -- 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

[R] Using R to fill ETM+ data gaps?

2010-07-24 Thread Abdi, Abdulhakim
Hi, I was wondering if anyone knows of a method (or if it's possible) to use R in interpolating Landsat ETM+ data gaps? Regards, Hakim Abdi _ Abdulhakim Abdi, M.Sc. Conservation GIS/Remote Sensing Lab Smithsonian Conservation Biology Institute

[R] How to generate a sequence of dates without hardcoding the year

2010-07-24 Thread Felipe Carrillo
Hi: I have a dataframe named 'spring' and I am trying to add a new variable named 'IdDate' This line of code works fine: spring$idDate - seq(as.Date(2008-07-01),as.Date(2009-06-30),by=week) But I don't want to hardcode the year because it will be used again the following year Is it possible to

Re: [R] How to generate a sequence of dates without hardcoding the year

2010-07-24 Thread Henrique Dallazuanna
Try this: format(seq(as.Date(2008-07-01),as.Date(2009-06-30),by=week), %d/%m) On Sat, Jul 24, 2010 at 6:07 PM, Felipe Carrillo mazatlanmex...@yahoo.comwrote: Hi: I have a dataframe named 'spring' and I am trying to add a new variable named 'IdDate' This line of code works fine:

Re: [R] (no subject)

2010-07-24 Thread Paul Smith
2010/7/23 w 霍 hw_joyce...@hotmail.com: I use the constrOptim to maximize a function with four constriants but the answer does not leave from the starting value and there is only one outer iteration. The function is defined as follows: tm-function(p){ p1-p[1]; p2-p[2]; p3-p[3];

Re: [R] How to generate a sequence of dates without hardcoding the year

2010-07-24 Thread jim holtman
Is this what you want if you want to assume that the date without a year is this year: seq(as.Date(7-1,%m-%d),by=week, length=52) [1] 2010-07-01 2010-07-08 2010-07-15 2010-07-22 2010-07-29 2010-08-05 2010-08-12 2010-08-19 [9] 2010-08-26 2010-09-02 2010-09-09 2010-09-16 2010-09-23 2010-09-30

Re: [R] glm - prediction of a factor with several levels

2010-07-24 Thread zachmohr
As far as I know, glm only works with dichotomous or count data. polr in the MASS package works and so does lrm {Design} for ordinal dependent variables. I would assume that the model produced by glm is a dichotomous version of your model but not sure. Only one intercept would be given because

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread David Winsemius
On Jul 24, 2010, at 4:54 PM, mpw...@illinois.edu wrote: THANKS, but I have one issue and one question. For some reason the secondstrongest value for row 3 and 6 are incorrect (they are the strongest) the remaining 10 are correct?? In my run of Wiley's code I instead get identical values

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread Joshua Wiley
On Sat, Jul 24, 2010 at 5:09 PM, David Winsemius dwinsem...@comcast.net wrote: On Jul 24, 2010, at 4:54 PM, mpw...@illinois.edu wrote: THANKS, but I have one issue and one question. For some reason the secondstrongest value for row 3 and 6 are incorrect (they are the strongest) the

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread David Winsemius
On Jul 24, 2010, at 8:09 PM, David Winsemius wrote: On Jul 24, 2010, at 4:54 PM, mpw...@illinois.edu wrote: THANKS, but I have one issue and one question. For some reason the secondstrongest value for row 3 and 6 are incorrect (they are the strongest) the remaining 10 are correct?? In

Re: [R] Trouble retrieving the second largest value from each row of a data.frame

2010-07-24 Thread David Winsemius
On Jul 24, 2010, at 9:27 PM, David Winsemius wrote: On Jul 24, 2010, at 8:09 PM, David Winsemius wrote: On Jul 24, 2010, at 4:54 PM, mpw...@illinois.edu wrote: THANKS, but I have one issue and one question. For some reason the secondstrongest value for row 3 and 6 are incorrect (they

[R] c-statiscs 95% CI for cox regression model

2010-07-24 Thread paaventhan jeyaganth
Dear all, how can i do the calculate the C-statistics 95% confidences interval for the cox regression model. Thanks very much for your any help. Paaveenthan _ [[elided Hotmail spam]]

Re: [R] UseR! 2010 - my impressions

2010-07-24 Thread Dirk Eddelbuettel
On Sat, Jul 24, 2010 at 08:55:01AM -0500, Frank E Harrell Jr wrote: On 07/23/2010 06:50 PM, Ravi Varadhan wrote: I want to echo what Ravi said. The talks were terrific (thanks to the program committee and the speakers) and Kate Mullen and her team did an extraordinary job in putting the

Re: [R] c-statiscs 95% CI for cox regression model

2010-07-24 Thread Frank E Harrell Jr
On 07/24/2010 09:51 PM, paaventhan jeyaganth wrote: Dear all, how can i do the calculate the C-statistics 95% confidences interval for the cox regression model. Thanks very much for your any help. Paaveenthan install.packages('Hmisc') require(Hmisc ?rcorr.cens (there is an example at

[R] Equivalent to go-to statement

2010-07-24 Thread Michael Haenlein
Dear all, I'm working with a code that consists of two parts: In Part 1 I'm generating a random graph using the igraph library (which represents the relationships between different nodes) and a vector (which represents a certain characteristic for each node): library(igraph) g -