Re: [R] for loop not working

2012-12-24 Thread arun
HI Eliza, You could try this: set.seed(15) mat1<-matrix(sample(1:2000,1776,replace=TRUE),ncol=444) colnames(mat1)<-paste("Col",1:444,sep="") res<-lapply(seq_len(ncol(mat1)),function(i) mat1[,seq(i,444,37)]) #If you want only this from 1:37, then  res1<-lapply(1:37,function(i) mat1[,seq(i,444,37)]

Re: [R] How to do it through 1 step?

2012-12-24 Thread meng
Yes!It works well and really what I want! Many thanks for your help! Merry Christmas. At 2012-12-24 22:15:36,arun wrote: >Hi, >How about this? > >set.seed(5) >dat<-data.frame(x=sample(1:20,6,replace=TRUE),a=sample(20:40,6,replace=TRUE)) > dat1<-within(dat,{f=a/median(a);x_new=x*f}) > d

[R] apply with missing values

2012-12-24 Thread jenna
I am trying to get the means of each participants avg saccade amplitude as a function of the group they were in (designated by "shape_"), but there are missing values in the datasetthis is what i tried... with(data055,tapply(AVERAGE_SACCADE_AMPLITUDE,shape_,mean)) i get an error saying the arg

[R] R and Matlab

2012-12-24 Thread Amirehsan Ranginkaman
Hi, How can I call R functions or Package in MatLab? Is there any way? Thanks Regards Ranginkaman [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posti

Re: [R] whats wrong in my codes???

2012-12-24 Thread arun
HI Eliza, I tried the function, on this example dataset in linux system. res<-list(read.table(text=" month  2005  2006  2008  2009   1 1.7360776 0.8095275 1.6369044 0.8195241   2 0.6962079 3.8510720 0.4319758 2.3304495   3 1.0423625 2.7687266 0.2904245 0.7015527   

Re: [R] for loop not working

2012-12-24 Thread Pascal Oettli
Hi, Why don't you use Arun's solution? Regards, Pascal Le 25/12/2012 15:57, eliza botto a écrit : Dear Arun, as usuall you were spot on. i tried the following *_>lapply(_**_seq_len(ncol(e)), function(i) {_* _ _ _>a<-e[,(e[i]:444)]_ >a[,c(TRUE, rep(FALSE,36))] }) but it never worked.

Re: [R] for loop not working

2012-12-24 Thread eliza botto
Dear Arun,as usuall you were spot on. i tried the following >lapply(seq_len(ncol(e)), function(i) { >a<-e[,(e[i]:444)] >a[,c(TRUE, rep(FALSE,36))] >}) but it never worked. thanks for your kind help.lots of love elisa > Date: Mon, 24 Dec 2012 22:40:08 -0800 > From: smartpink...@yahoo.com >

Re: [R] for loop not working

2012-12-24 Thread Pascal Oettli
Hello, I provided you all the information you need. Replace i by 1,2,3...37 in seq(i,444,37). Pascal Le 25/12/2012 14:19, eliza botto a écrit : Dear Pascal, thanks for replying. it is working about it only executes the first set of column, it does not bring about all the sets of columns. an

Re: [R] for loop not working

2012-12-24 Thread eliza botto
Dear Pascal,thanks for replying. it is working about it only executes the first set of column, it does not bring about all the sets of columns.any thoughts?? eliza > Date: Tue, 25 Dec 2012 14:12:01 +0900 > From: kri...@ymail.com > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org > Subject:

Re: [R] for loop not working

2012-12-24 Thread Pascal Oettli
Hello, ?seq seq(i,444,37) with i = 1,2,3...37 HTH Pascal Le 25/12/2012 14:03, eliza botto a écrit : dear R family,i have a matrix of 444 columns. what i want to do is the following. 1. starting from column 1 i want to select every 37th column on the way. more precisely i want to select c

[R] for loop not working

2012-12-24 Thread eliza botto
dear R family,i have a matrix of 444 columns. what i want to do is the following. 1. starting from column 1 i want to select every 37th column on the way. more precisely i want to select column 1, 38,75,112,149 and so on. 2.starting from column 2, i again want to select every 37th column. which

Re: [R] parallelized version of "by" and "ave"

2012-12-24 Thread Gabor Grothendieck
On Mon, Dec 24, 2012 at 1:25 PM, ivo welch wrote: > Dear R experts--- > > Has anyone written parallel versions of "by" (i.e., mcby) and "ave" > (i.e. mcave) ? I did ask a question like this a year ago, and then > the answer was no. > > for those who are googling the group for the answer to this q

Re: [R] whats wrong in my codes???

2012-12-24 Thread eliza botto
thanks arun it is well done. elisa.. > Date: Mon, 24 Dec 2012 12:02:52 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] whats wrong in my codes??? > To: eliza_bo...@hotmail.com > CC: r-help@r-project.org > > HI Eliza, > > I tried the function, on this example dataset in linux system.

Re: [R] parallelized version of "by" and "ave"

2012-12-24 Thread David Winsemius
'split' works on vectors , too. -- David. Sent from my iPhone On Dec 24, 2012, at 10:25 AM, ivo welch wrote: > Dear R experts--- > > Has anyone written parallel versions of "by" (i.e., mcby) and "ave" > (i.e. mcave) ? I did ask a question like this a year ago, and then > the answer was no.

[R] parallelized version of "by" and "ave"

2012-12-24 Thread ivo welch
Dear R experts--- Has anyone written parallel versions of "by" (i.e., mcby) and "ave" (i.e. mcave) ? I did ask a question like this a year ago, and then the answer was no. for those who are googling the group for the answer to this question, in the meantime, the poor man's version of "by" is mcl

[R] Is there a point-biserial corr version of mvrnorm?

2012-12-24 Thread Xiaoxu LI
Dear R fans, MASS::mvrnorm with empirical=T is very useful to reproduce practice data of published papers. Now I want to reproduce a binomial variable with multiple normal variables. The target paper gave a big corr table with sd(s) and Means including a GENDER variable. Is there a point-biserial

Re: [R] Spammer radhi

2012-12-24 Thread Rui Barradas
Hello, I believe that today's spam filters already use statistical tools, namely, non-parametric bayesian methods. This would mean that they can adapt to known attacks but are useless against new ones. Merry Christmas, Rui Barradas Em 24-12-2012 15:57, Ben Bolker escreveu: Arun Kumar Saha

Re: [R] whats wrong in my codes???

2012-12-24 Thread Hasan Diwan
Eliza, On 24 December 2012 08:34, eliza botto wrote: > > Dear R family,i am trying to plot and save, simultaneously, about 1000. > the name of each plot is contained in "names" file. when i run this loop, i > get an error. > "Error in plot.new() : Unable to open file > 'C:/R/SAVEHERE/myplot_Ta

[R] whats wrong in my codes???

2012-12-24 Thread eliza botto
Dear R family,i am trying to plot and save, simultaneously, about 1000. the name of each plot is contained in "names" file. when i run this loop, i get an error. "Error in plot.new() : Unable to open file 'C:/R/SAVEHERE/myplot_Tak.jpg' for writing". could you please correct the mistake in t

Re: [R] How to do it through 1 step?

2012-12-24 Thread arun
Hi, How about this? set.seed(5) dat<-data.frame(x=sample(1:20,6,replace=TRUE),a=sample(20:40,6,replace=TRUE))  dat1<-within(dat,{f=a/median(a);x_new=x*f})  dat1 #   x  a x_new f #1  5 31  5.081967 1.0163934 #2 14 36 16.524590 1.1803279 #3 19 40 24.918033 1.3114754 #4  6 22  4.327869 0.

Re: [R] wireframe and margins

2012-12-24 Thread David Winsemius
On Dec 24, 2012, at 1:30 AM, krusty the klown wrote: > Thanks, I'm setting now the mai parameter, but it is not so intuitive how it > works with persp... > Sometimes specialized functions will coerce par options and one needs to work around of hack the code. I don't know if this is the case in

Re: [R] Spammer radhi

2012-12-24 Thread Ben Bolker
Arun Kumar Saha gmail.com> writes: > > Can the Statisticians here develop some good Statistical tool to stop this > Spamming keeping Type-I error almost zero? As Bruce Schneier (surely among others) has pointed out, the difference between security against natural risks (analogous to most stat

Re: [R] NRI reclassification table improveProb Cox

2012-12-24 Thread Frank Harrell
There are several issues. First the Cox model is not for a binary outcome. It is for a time-to-event outcome whose status (event vs. censored) is binary. Second, split-sample validation does not work well with n < 2 in the combined sample. Third, reclassification tables are not used to vali

Re: [R] Spammer radhi

2012-12-24 Thread Arun Kumar Saha
Can the Statisticians here develop some good Statistical tool to stop this Spamming keeping Type-I error almost zero? Thanks and regards, _ Arun Kumar Saha, FRM QUANTITATIVE RISK AND HEDGE CONSULTING SPECIALIST Visit me at: http://in.linkedin.co

Re: [R] Spammer radhi

2012-12-24 Thread Martin Maechler
> Duncan Murdoch > on Sun, 23 Dec 2012 13:59:08 -0500 writes: > On 23/12/2012 1:46 PM, Rui Barradas wrote: >> This happened two or three weeks ago and it's happening >> again. Spammers are using Nabble to attack R-Help. indeed. What a bad way to misuse Christmas holiday

Re: [R] How to do it through 1 step?

2012-12-24 Thread meng
Yes,this is my final solution,but if I wanna add many new variables,and maybe the following "new variables" are computed based on the previous " new variables", this solution maybe difficult. At 2012-12-24 17:01:03,arun wrote: >HI, > >Not sure if this works for you. >set.seed(5) >dat<-

Re: [R] wireframe and margins

2012-12-24 Thread krusty the klown
Thanks, I'm setting now the mai parameter, but it is not so intuitive how it works with persp... -- View this message in context: http://r.789695.n4.nabble.com/wireframe-and-margins-tp4653838p4653865.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] How to do it through 1 step?

2012-12-24 Thread arun
HI, Not sure if this works for you. set.seed(5) dat<-data.frame(x=sample(1:20,6,replace=TRUE),a=sample(20:40,6,replace=TRUE))  dat1<-transform(dat,f=a/median(a),x_new=x*(a/median(a)))  head(dat1,2) #   x  a    f x_new #1  5 31 1.016393  5.081967 #2 14 36 1.180328 16.524590 A.K. - O

[R] How to do it through 1 step?

2012-12-24 Thread meng
A data set(dat),has 2 variables: x and a, and 100 rows. I wanna add 2 variables,and call the new data set dat1: var1:f = a/median(a) var2:x_new = x*f My solution: dat1<-transform(dat,f = a/median(a),x_new = x*f) But gets error reply which says that "f" is not exits since dat has no variables c