Re: [R] creating a function using for if

2012-10-22 Thread Balqis
220,90,55,45) try=fun(1,0.2,150,data=y) On Mon, Oct 22, 2012 at 3:51 PM, Balqis wrote: > Hi all, > > I'm trying to create a function where it can process a vector and also > give a vector output accordingly > #input: a,b anc c are constants, data is the vector > > #

[R] creating a function using for if

2012-10-22 Thread Balqis
Hi all, I'm trying to create a function where it can process a vector and also give a vector output accordingly #input: a,b anc c are constants, data is the vector #set the function fun<-function(a,b,c,data) { N=as.vector() for (i in min(data):max(data)){ if(i>c){ N<-(a*(i-c)^0.5)+(b*(i-c))} else

Re: [R] z.test for dataframe

2012-10-17 Thread Balqis
bridge > so that the students could use a function that was similar to the > t.test function that they would eventually use. > > On Wed, Oct 17, 2012 at 12:45 AM, Balqis wrote: > > Hi! > > I'm trying to use sapply to my dataframe for z.test function (teaching > > demos

Re: [R] how to extract from list

2012-10-16 Thread Balqis
sIr[3,] Thanks! On Tue, Oct 16, 2012 at 12:35 PM, Muhammad Rahiz wrote: > Maybe something along the following lines? > > m <- rep(list(rnorm(10)),3) # dummy data > > data <- c() > for (a in 1:length(m)) { > data[a] <- m[[a]][1] } > > Muhammad > > > On Tue, O

[R] how to extract from list

2012-10-16 Thread Balqis
Hi all, I have a list of 2 data, and the list look like below. I wonder what is the simplest way to extract 'kappa' value (or 'xi' or 'alpha' for the matter) from each of the data. How can I simply code it without having to change the list to a dataframe first? Many thanks! $X19997