similar to: how to rewrite this for loops in matrix form without loop

Displaying 20 results from an estimated 1000 matches similar to: "how to rewrite this for loops in matrix form without loop"

2010 Jan 17
3
enty-wise closest element
Dear R-users, i have a simple problem maybe, but i don't see the solution. i want to find the entry-wise closest element of an vector compared with another. ind1<-c(1,4,10) ind2<-c(3,5,11) for (i in length(ind2):1) { print(which.min(abs(ind1-ind2[i]))) } for ind2[3] it should be ind1[3] 10, for ind2[2] it should be ind1[2] 4 and for ind2[1] it should be ind1[1] 1. but with the
2011 Mar 10
2
within group sequential subtraction
Hi Everyone, I would like to do sequential subtractions within a group so that I know the time between separate observations for a group of individuals. My data: data <- structure(list(group = c("IND1", "IND1", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5", "IND6", "IND6"), date_obs =
2011 Mar 09
2
Cleaning date columns
Hi Everyone, I have the following problem: data <- structure(list(prochi = c("IND1", "IND1", "IND1", "IND2", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5"), date_admission = structure(c(6468, 6470, 7063, 9981, 9983, 14186, 14372, 5129, 9767, 11168), class = "Date")), .Names =
2009 Sep 11
2
Accumulating results from "for" loop in a list/array
Dear R users, I would like to accumulate objects generated from 'for' loop to a list or array. To illustrate the problem, arbitrary data set and script is shown below, x <- data.frame(a = c(rep("n",3),rep("y",2),rep("n",3),rep("y",2)), b = c(rep("y",2),rep("n",4),rep("y",3),"n"), c =
2011 Dec 04
2
frequency table?
Hello R-users, I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a table which tells me how many times each individual occurs with another. I don't really know how such a table is called...it is not a frequency table....My eventual goal is to make Venn-diagrams from the occurence of my individuals. So I've this: cluster ind1 ind2
2011 Dec 04
1
similarity matrix
Hello R-users, I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a similarity matrix which tells me how many times each individual occurs with another. My eventual goal is to make Venn-diagrams from the occurence of my individuals. So I've this: cluster ind1 ind2 ind3 etc. 1 0 1 2 2 3 0 1 3
2011 Dec 03
1
pivot table help
Hello R-users, I've got a huge table with about 20.00 rows and 50 columns. The table now has headers as Members1, Members2 etc. My data are 8 different individuals. And I've got a column with clusters. So each individual belongs to different clusters and can occurs multiple times within a cluster (that's the reason that there can be more than 8 members). I want a presence/ absence
2009 Jul 09
1
Converting indices of a matrix subset
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have two matrices: > m1 <- matrix(1,4,4) > m1 [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 1 1 [3,] 1 1 1 1 [4,] 1 1 1 1 > m2 <- matrix(0,3,3) > diag(m2) <- 1 > m2 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 I want to get indicies from m2
2006 Feb 10
1
precision of std. error in summary
Hi, I'm doing robust regression with the following command rlm(dip~ind1+ind2-1,method="M",psi=psi,maxit=1000,acc=1e-15) now when I ask for a summary summary(rlm(dip~ind1+ind2-1,method="M",psi=psi,maxit=1000,acc=1e-15)) I get Coefficients: Value Std. Error t value ind1 -0.0377 0.0000 -24203.1415 ind2 1.0370 0.0000 668735.7195 taht is
2015 Nov 20
1
Good practice for naming classes, builders, attributes, getters/setters for object composition
Hey everyone, I am developing a package and I am wondering if there is a good practice for naming classes, builders, attributes getters and setters when dealing with object composition. I know that it is usually a good practice to give to the builder the same name as the class and, if possible, to avoid to use upper case letters. My problem is that, when I build an object containing an other
2005 Jan 17
2
Omitting constant in ols() from Design
Hi! I need to run ols regressions with Huber-White sandwich estimators and the correponding standard errors, without an intercept. What I'm trying to do is create an ols object and then use the robcov() function, on the order of: f <- ols(depvar ~ ind1 + ind2, x=TRUE) robcov(f) However, when I go f <- ols(depvar ~ ind1 + ind2 -1, x=TRUE) I get the following error: Error in
2009 Aug 09
1
problem adding columns to matrix
Hi all, i purchased a copy of the book Morphometrics with R by Springer. at the end of each chapter there are exercises to train what you just read and (hope) learned... so i have this problem: Define a hypothetical data frame containing five measurments normally distributed(size,head,pectoral,area,weight) for four individuals (named ind1, ind2, etc). ADD A COLUMN corresponding to the
2003 Jun 05
1
Logical vectors
Hi everybody, just a quick question that drives me crazy: Is it possible to "join" 2 logical vectors ? i.e. x<-4 ind <- 1:19200 pin <- c(0, rep(400, 48) * (1:48)) ind1<-((pin[j] + 1) <= ind) & (ind <= pin[j + 2]) ind2<-((pin[j+x] + 1) <= ind) & (ind <= pin[j+x + 2]) ind2 and ind1 give the right TRUE index #but I would like something like that
2011 Dec 05
1
Subsetting a data frame
Hi R users, I really need help with subsetting data frames: I have a large database of medical records and I want to be able to match patterns from a list of search terms . I've used this simplified data frame in a previous example: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2, 1.3, 3), test2 = c(56L, 27L, 58L,
2011 Aug 10
2
choosing selective data with permutations
Hello, I am a R beginner and hoping to obtain some hints or suggestions about using permutations to sort a data set I have. Here is an example dataset: Ind1 11 00 12 15 28 Ind2 21 33 22 67 52 Ind3 22 45 21 22 56 Ind4 11 25 74 77 42 Ind5 41 32 67 45 22 This will be read into a variable using read.table. What I want to do is permute these individuals and every
2008 Apr 19
1
resampling from distributions
Hello All, Once again thanks for all of the help to date. I am climbing my R learning curve. I've got a few more questions that I hope I can get some guidance on though. I am not sure whether the etiquette is to break up multiple questions or not but I'll keep them together here for now as it may help put the questions in context despite the fact that the post may get a little long.
2011 Oct 05
2
Subsetting a data frame with multiple values and exclusions.
Hi all, I realise that the convention is to provide a working example of my problem but the data are of a sensitive nature so I'm not able to do that in this case. I need to query a database for multiple search terms: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 =
2006 Mar 09
1
HCLUST subroutine question -- FORTRAN DO loops
Shown below is most of the FORTRAN subroutine named HCLUST. My question concerns the DO loop labeled as '10'. What happened to its CONTINUE statement? I will assume that after FLAG(I)=.TRUE. is executed that control returns to DO 10 I=1,N. Am I correct? Dave ---------------------------- C Initializations C DO 10 I=1,N C We do not initialize MEMBR in order to be able to
2008 Oct 29
1
Subsetting data in a loop
I need some help with sub-setting my data.  I am trying to divide a data frame into multiple data frames based on the year collected, and stored in a list with each new data frame labeled with "year X" where X is the year the data was collected.  When I run my current code I get nine error messages stating "In one_year[name] <- myear :  number of items to replace is not a
2002 Jun 13
1
assign to data.frame
I have two large data.frames which I would like to combine. Merge works, but is slow and a "merge" is not really required. Rather a rbind will do the trick. However, there are a number of variables which need to be created in each data.frame to make the columns of the two data.frames similar. say, d1 <- data.frame(ind1=1:10,ind2=letters[1:10],c_rnorm(10)) d2 <-