[R] Matrix manipulation in for loop

2011-05-16 Thread clips10
Hi all, I have a problem with getting my code to do what I want! This is the code I have: create.means.one.size<-function(nsample,var,nboot){ mat.x<-matrix(0,nrow=nboot,ncol=nsample) for(i in 1:nboot){ mat.x[i,]<-sample(var,nsample,replace=T) } mean.mat<-rep(0,nboot) for(i in 1

Re: [R] Creating vectors

2010-08-12 Thread clips10
I think your code will work but only for the two columns I gave. I used those as an example but my actual data is 200 in length with two columns and I need code that will give a label to each unique pair but still have the original length for instance, one that will turn something such as

Re: [R] Creating vectors

2010-08-12 Thread clips10
Thanks for the help, I tried to apply this to a vector with two columns, well I suppose it is not a vector but for instance like this: [,1] [,2] [1,]1 2 [2,]2 3 [3,]1 2 [4,]1 2 [5,]3 4 and return a vector : 1,2,1,1,3, so that it recognises b

[R] Creating vectors

2010-08-11 Thread clips10
I didn't really know what to post as the topic subject, but I have a vector, for instance (2,2,4,6,2,4,4,6,8,6) and I want to create another vector which is just numbers from 1 to 4 since there are only 4 unique numbers in my vector, so for instance 2 would be 1, 4 would be 2, 6 would be 3, and 8

[R] distance matrix?

2010-06-28 Thread clips10
I have a vector 0 to 10 and want to create a matrix with the differences between the numbers in it for instance: 0 1 2 3 4 5 6 7 8 9 10 0 0 1 2 3 4 5 6 7 8 9 10 1 1 0 1 2 3 4 5 6 789 2 3 4 5 6 7 8 9 10 Etc etc. S

[R] Vector manipulation, for loop needed?

2010-06-18 Thread clips10
Hi, I have a vector of time in days t<-1:48. I have observations and the day they were recorded. I also have a vector, S which takes different values depending on which day the observation was recorded. For example if on day 1 all in vector S get a value of 46/48, on day 2 get 42/48, day 3 38/48

[R] Plotting different symbols in R for different values in a vector

2010-06-17 Thread clips10
I have some point locations I want to add to a plot and have the command pts1<-as.points(Xcoordinate,Ycoordinate) then plot(poly1,type="l",lwd=1) what I want to do is add the locations onto the plot. I can do this using the points command but I have another vector in my data frame with the x