[R] Error: "subscript out of bounds"

2008-12-01 Thread Alex99
Hi All, I am trying to replace the "NA" values in a matrix by using the following function: it gets a "name" of the matrix or list or vector and turns it to a matrix called "m". then checks the elements of the matrix and if any of them is "NA" replace them with "0". rep=function(name){ m=as.mat

[R] Help: "mean" and "replicate"

2008-11-28 Thread Alex99
Hi all, I used the "replicate" function to make 2 samples from file "test" with 5 records in each sample and saved the output in "result". result=replicate(2,test[,sample(colnames(test),5,replace =FALSE)],simplify=FALSE) now I need to calculate the mean of each cell; i.e. I need to add "the nu

[R] Transpose and replicate

2008-11-28 Thread Alex99
Hi all, I used the "replicate" function to make 2 samples from file test with 5 records in each sample and saved the output in "result". result=replicate(2,test[,sample(colnames(test),5,replace = FALSE)],simplify=FALSE) now I need to transpose each sample, but when I use: t(result) or res

[R] Help with "replicate"

2008-11-27 Thread Alex99
Hello everyone, I have a file called "trans" which has 100 records (rows) and 60 columns. I need to make 2 samples (with 5 records in each) out of this file with no replacement, so I used "replicate". The sampling part works fine and I called the outcome "result". my problem is then I need to ca

[R] Help With Graphs

2008-11-07 Thread Alex99
Hi guys, I am truing to draw a circle and choose 10 points on the circle and put a number from 1 to 10 above each point. I don't have a problem with drawing a circle and choosing 10 points. my problem is with numbering . is it even possible to put a number above each chosen point? if so any idea

[R] Help with Plots

2008-10-29 Thread Alex99
Hi there, I am trying to have a connectivity graph (two plots at once) in R: this is an example: x1=sin((0:100)*2*pi/100) y1=cos((0:100)*2*pi/100) plot(x1,y1) will draw a circle and x2=c(1,9,3,4,8,4,2,0) y2=c(3,6,8,2,4,1,9,6) plot(x2,y2,type="b") will draw a graph with corresponding x's and

[R] Fuctions help!

2008-10-23 Thread Alex99
Hi everyone, I have a question about functions. I have two functions: Sampling=function(fname,Total,nSample,nPatient){..return(list(Gmean,Gsd))} Power=function(alfa,m1,m2,s1,s2,n1,n2){return(powe)} I want to use "Gmean" and "Gsd" which are the returned values from "Sampling" function,

[R] Help with functions

2008-10-22 Thread Alex99
Hi there, I have a the following function which takes a name(fname), total number of rows (Total), number of times to make a sample(nSample), number of records/rows to be included in each sample(nPatient). then it generates required samples and calculates the mean and standard deviation of the c

[R] Error in sample(colnames(B), 10) : invalid 'x' argument

2008-10-21 Thread Alex99
HI, I have a file named "s1"(which has 14 rows and 4 columns) which is in csv format. I import and call it "A" the file using: A <- read.csv(file="s1.csv",head=TRUE,sep=",") then I transpose it and call it "B"(which will have 4 rows and 14 columns) using: B=t(A) when I want to make 5 samples

[R] Inserting a new row in a matrix

2008-10-21 Thread Alex99
Hi guys, I need to insert a row to a matrix in a for loop. I have matrix named "Avg" which is a 5x4 matrix of zeros. I have a file named "A"(4 rows,14 columns) which I make a sample of it 5 times. each time I get the mean for each column and put the result in the "Avg" matrix. this is my code:

[R] calculating mean for samples

2008-10-20 Thread Alex99
Hi everyone, > does any one knows how can I calculate mean for different samples > i.e. I have a data like this: > > s1 s2 s3 s4 > 1 0 0 0 1 > 2 1 0 1 0 > 3 0 0 0 0 > 4 0 0 0 0 > 5 0 1 0 1 > 6 1 0 0 0 > 7 0 0 0 0 > 8 0 0 0 0 > 9 0 0 0 0 > 10 0 0 0

[R] Row Sampling

2008-10-20 Thread Alex99
Hi everyone, does any one knows how can I make sample from rows? i.e. I have a data like this: s1 s2 s3 s4 1 0 0 0 1 2 1 0 1 0 3 0 0 0 0 4 0 0 0 0 5 0 1 0 1 6 1 0 0 0 7 0 0 0 0 8 0 0 0 0 9 0 0 0 0 10 0 0 0 1 I need to make 5 different sample wit

[R] function help

2008-10-17 Thread Alex99
Hi everyone, I have dataset which I make a sample of it couple of times and each time I get the mean and standard deviation of each row for each sample. I have a function for that, which takes the name of the file and number of times to sample and then returns the mean and standard deviation for e

Re: [R] saving result of a "for" loop

2008-10-16 Thread Alex99
es(results.1) <- r > colnames(results.1) <- f[1] > > This is a for loop that I used not too long ago defining the results > outside of the loop worked for me. > hope this helps > > stephen > > On Thu, Oct 16, 2008 at 9:10 AM, Alex99 <[EMAIL PROTECTED]> wrote:

Re: [R] saving result of a "for" loop

2008-10-16 Thread Alex99
tion(x) rowMeans(x))) > rownames(Means)=paste('sample',1:5,sep="") > Means > > # Global mean for sample > colMeans(Means) > > > HTH, > > Jorge > > > On Thu, Oct 16, 2008 at 9:10 AM, Alex99 <[EMAIL PROTECTED]> wrote: > >&

[R] saving result of a "for" loop

2008-10-16 Thread Alex99
Hi everyone, I have dataset which I take random samples of it 5 times. each time I get the mean for rows for each sample. at the end I need to calculate the Average of all means for each sample and each row. to clear it up I give an example: say this is my dataset. X8 X9X10X12 X13 X14 X15 X1

Re: [R] Standard deviation for rows

2008-10-15 Thread Alex99
gt; From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Alex99 > Sent: Wednesday, October 15, 2008 1:17 PM > To: r-help@r-project.org > Subject: [R] Standard deviation for rows > > > Hi everyone, > > I have just started using R, and I have a simple ques

[R] Standard deviation for rows

2008-10-15 Thread Alex99
Hi everyone, I have just started using R, and I have a simple question. How can I get the Standard deviation for rows. basically I am looking for something like "rowMeans()" but for Standard deviation (I tried "rowSds()" didn't exist) Thanks, -- View this message in context: http://www.nabb

Re: [R] Help Help with sampling

2008-10-15 Thread Alex99
sep="") > > # Using 5 samples only > res=replicate(5,my[,sample(colnames(my),5)],simplify=FALSE) > > # mean > lapply(res,function(x) rbind(rowMeans(x)) > > # standard deviation > lapply(res,function(x) apply(x,1,sd,na.rm=TRUE)) > > > HTH, > > Jorg

Re: [R] Help Help with sampling

2008-10-15 Thread Alex99
gt; 0"),header=TRUE) > closeAllConnections() > rownames(my)=paste('s',1:4,sep="") > > # Samples > res=list() > for(i in 1:5) res[[i]]<- my[,sample(colnames(my),5)] > res > > HTH, > > Jorge > > > On Wed, Oct 15, 2008 at 10

Re: [R] Help Help with sampling

2008-10-15 Thread Alex99
et is just one mean for each sample. not the mean for each S. any suggestion how to do it? thanks again for all your help Peter Dalgaard wrote: > > Alex99 wrote: >> Hi everyone, >> >> I have a dataset(named "Mydata") which includes 4 different variables >>

[R] Help Help with sampling

2008-10-15 Thread Alex99
Hi everyone, I have a dataset(named "Mydata") which includes 4 different variables named; s1,s2,s3,s4 .Each variable(symptom) has 14 patients. I need to use random sampling to make, 5 different samples from my data with 5 patients in each sample. i.e. using all 4 variables I need to make 5 differ

[R] Question: how to make a sample from my data set

2008-10-14 Thread Alex99
Hi everyone, I have a question about sampling. I have a data set which includes 25 different variables named; symptom1, symptom2,.,symptom25(25 columns).Each variable(symptom) has 9 patients (9 columns). I need to use random sampling to make, 5 different samples from my data. i.e. using all

[R] Sampling

2008-10-10 Thread Alex99
Hi Guys, I am in desperate need with sampling. I am suppose to sample from a dataset. I use the following code: > for(i in 1:5){temp[i]<-sample(T2,40,replace=F) + show(temp)} but all the samples are the same, but I want them to be different.any suggestion? Thanks -- View this message in con