similar to: Converting a Matrix to a Vector

Displaying 20 results from an estimated 200 matches similar to: "Converting a Matrix to a Vector"

2004 Nov 29
2
[BASIC] Solution of creating a sequence of object names
Dear R-users, I state that this is for beginners, so you may ignore this in order not to be irritated. By the way, "patience" is another important thing, together with "kindness", we should keep in mind when we teach students and our own children as Jim Lemon pointed out well in the context of the Socratic method. You may know that being kind does not mean giving
2010 Nov 07
2
remove data frame from list of data frames
I have a list of data frames like this: a<- data.frame(x=runif(10), y = runif(10), Acc = 1) b<- data.frame(x=runif(10), y = runif(10), Acc = 0) ls<- list(a,b) and I want to remove the data frames from ls that have Acc values other than 1. How do I do that? Thanks for any help! Matthew
2009 Dec 29
1
extract value from first column based on value in second column
Hi all, I have two columns of data, the first consists of parameter estimates and the second probability estimates. I would like to extract the value from the first column based on the max value of column two, but not sure how to do this other than by extracting the value and then manually finding the value in the first column. Anyone know how to do this? Basically, I need to find the row
2010 May 28
3
how to create automatically names for vectors in a loop?
Hi, I want to generate a number of vectors and store them with different names, like this: x=1 while (x<100) { vector#x# = rnorm(100) x=x+1 } where each vector has, at its hand, instead of #x# a number which goes from 1 to 99. How can I do this? Thanks Gabriele Zoppoli, MD Ph.D. Fellow, Experimental and Clinical Oncology and Hematology, University of Genova, Genova, Italy Guest
2008 Sep 09
1
how to split a data framed with sequences
Hi all, Given a data frame: my.df <- data.frame(a = c(1:5, 1:10, 1:20), b = runif(35)) I want to split it by "a" such that I end up with a list containing 3 components i.e. the first containing a = 1 to 5, the second a = 1 to 10 etc. In other words, sets of sequences of a. I can't seem to find the right form using the split function - can you help? Much appreciated. David
2007 Mar 03
1
function doesnt return/create object
hello, i have written a function to extract certain lines from a matrix. the result is a matrix with 6 cols, named dynamically according to the functions arguments. the problem is now, that i'm not able to return the resultmatrix for further use. the object is not being created. example from my console: getans(27,27) [...] [189,] 3969 161 27 1 0 1 [190,] 2142 87 27
2008 Sep 05
5
Lowest k values of list
Hi @ all, how do I get the largest or lowest k values of list? It must similar to the min() / max() function, but I just don't get it. Best wishes, Markus
2013 May 08
4
Correctly Setting New Seed
Could someone please suggest a method to store the current random seed. I'm having trouble understanding how to correctly use set.seed and .Random.seed. Specifically, I have the following code that crashes: set.seed(seed) for(i in 1:10){ print( runif(1)) } To get around this I need to split the number of iterations into chunks: set.seed(seed) for(i in 1:5){ print(runif(1))
2009 May 25
1
Memory problems when using ifelse
Dear R Users, I have a data frame of 4 columns and ~58000 rows, the top of which looks like this: > head(max_out) Latitude Longitude Model Obs 1 -0.25 -49.25 4 4 2 -0.25 -50.25 4 5 3 -0.25 -50.75 4 4 4 -0.25 -51.25 3 11 5 -0.25 -51.75 6 4 6 -0.25 -52.25 12 5 The above shows, for each coordinate point, the
2010 Aug 03
3
how to do a IF ELSE in a matrix format
Hey, Rers I am new to R and this question may has been asked many times or a very old one.?I have checked the archive but found nothing (maybe I used?the wrong key words).?any advise is appreciated the question is: I try to replace a col vector with some other values, see edu<-matrix(0,1000,2) edu1<-runif(1000,0,1) edu[,1]<-edu1 the colum ?vector?edu[,1]? would?have value
2006 Dec 10
1
how to sort random numbers according to the sample ?
Dear R-users, #### below is my code to randomized x three times. > x=c(6,8,9,11) > plan=NULL > for(i in 1:3){ + set.seed(i) + r<-runif(x) + plan=cbind(plan,r) + } ##### which gave the matrix > plan r r r [1,] 0.2655087 0.1848823 0.1680415 [2,] 0.3721239 0.7023740 0.8075164 [3,] 0.5728534 0.5733263 0.3849424 [4,]
2012 Sep 15
2
How to convert the output of tapply() so that it has the same order as the input?
Hi, I try to apply a function to subsets of a data.frame. tapply() does the job, but the as output, I am looking for a vector (not an array/matrix) ordered in the same way as the original data, so I can simply cbind the result to the original data.frame. Below is a minimal example. I know that there are packages that can do these things easier, but I'm looking for a fast solution not
2010 Mar 15
5
storing matrix(variables) in loop
Hello R-helpers, I have the following code that works well, b <-list() for (i in 1:3){ a <- matrix(runif(1),3,3) b[[i]] <- a } b however, I need to do something similar with two loops and I was looking for something that would look like b <- list() for (i in 1:3){ for (j in 1:4){ a <- matrix(runif(1),3,3) b[[i,j]] <- a #but this doesn?t work } } Anyway, I wanted
2010 Jul 19
2
replacing elements of distance matrix
Hi! I am trying to implement non-bipartite matching. I have around 500 sites which can be clustered by 10 regions. I am able to calculate pairwise Mahalanobis distances between sites (thanks to another post in the forum). However, I want to constrain my match to sites within the same region. Thus I want to replace elements of the distance matrix with a high value, say 999999, for sites not of the
2011 Aug 08
0
Odp: Fw: R function for Gage R&R
Hi Elaine I do not use it very often. I programmed it to mimic Minitab functions (partly) with some adons from czech statistics textbook written by M.Meloun (meloun militky statistics - first hit in google) Basically you can have your data in some data frame or they can be as separated vectors. The function itself expects input of 3 vectors, but you can easily to modify it for imput as
2009 Apr 13
2
weighted mean and by() with two index
Hi expeRts, I would like to calculate weighted mean by two factors. My code is as follows: R> tmp <- by(re$meta.sales.lkm[, c("pc", "sales")], re$meta.sales.lkm[, c("size", "yr")], function(x) weighted.mean(x[,1], x[,2])) The result is as follows: R> tmp size: micro yr: 1994 [1] 1.090
2008 Aug 19
1
RNGkind() state (PR#12567)
I sent this to R-devel early last month, but have received no response, so I guess it really is a bug. This looks like a bug to me, and is a bit hard to describe, but easy to reproduce. ? Basically, if RNGkind is saved as something other than the default, and if the first operation in a session is a set.seed(), the default is reverted to. ?Reproduce by: cafe-rozo> ?R --vanilla R version
2009 Dec 09
1
Why cannot get the expected values in my function
Hi, In the following function, i hope to save my simulated data into the "result" dataset, but why the final "result" dataset seems not to be generated. #Function simdata<-function (nsim) { result<-matrix(NA,nrow=nsim,ncol=2) colnames(result)<-c("x","y") for (i in 1:nsim) { set.seed(i) result[i,]<- cbind(runif(1),runif(1)) }
2014 Mar 06
2
'parallel' package changes '.Random.seed'
Hi, I've implemented parallelization in one of my packages using the 'parallel' package -- many thanks for providing it! In my package I'm importing 'parallel' and so added it to the DESCRIPTION file's 'Import:' tag and also added a 'importFrom("parallel", ...)' statement in the NAMESPACE file. Parallelization works nicely, but my package
2016 Apr 08
0
Is this a bug in quantmod::OpCl?
On 04/06/2016 07:58 PM, Joshua Ulrich wrote: > On Tue, Apr 5, 2016 at 9:17 PM, James Hirschorn > <james.hirschorn at hotmail.com> wrote: >> OpCl works on xts objects but not on quantmod.OHLC objects. Is this a bug? >> > Thanks for the minimal, reproducible example. > > Looks like a bug. There's no as.quantmod.OHLC.xts method, so the zoo > method is