search for: ind2

Displaying 20 results from an estimated 41 matches for "ind2".

Did you mean: ind
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 for-loop above i get ind1[3], ind1[2] and ind1[2]. any suggestions are quite welcome....
2009 Jul 09
1
Converting indices of a matrix subset
...] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 I want to get indicies from m2 such that they match indicies as though they came from the lower right of m1. Here's how things work: > ind1 <- which(m1 == 1) > ind1 [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 > ind2 <- which(m2 == 1) > ind2 [1] 1 5 9 I would like ind2 to be offset so they look like indicies from the lower right of m1: > ind2 [1] 6 11 16 I can be done with a simple offset when using arr.ind=TRUE: > ind2 <- which(m2 == 1, arr.ind=T) + 1 > ind2 row col [1,] 2 2 [2,]...
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 = structure(c(6468, 7063, 9981, 14186, 14372, 5129, 9767, 11168, 10243, 10647), class = "Date")), .Names = c("group", "date_obs...
2010 May 03
3
how to rewrite this for loops in matrix form without loop
x0=rnorm(100) y0=rpois(100,3)+1 ind=as.data.frame(table(y0)) ind1=ind[,1] ind2=ind[,2] phi=NULL for (i in 1:length(ind2)){ phi[i]=sum(x0[y0==ind1[i]])/ind2[i] } [[alternative HTML version deleted]]
2011 Dec 04
2
frequency table?
...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 ind3 etc. 1 0 1 2 2 3 0 1 3 1 1 1 And I want to go to this: ind1 ind2 ind3 ind1 0 4 2 ind2 4 0 4 ind3 2 4 1 is there a way to do this? Than...
2009 Sep 11
2
Accumulating results from "for" loop in a list/array
...uot;), c = c(rep("n",7),rep("y",3)), d = c("y", rep("n",4), rep("y",2), rep("n",3))) for (i in 1:(dim(x)[2])) { assign(paste("ind", i, sep = ""), which(x[ , i] == "y")) accum <- c(ind1, ind2, ind3, ind4) } > ind1 [1] 4 5 9 10 > ind2 [1] 1 2 7 8 9 > ind3 [1] 8 9 10 > ind4 [1] 1 6 7 > accum [1] 4 5 9 10 1 2 7 8 9 8 9 10 1 6 7 Are there any alternative method where the highlighted statement above can be represented without typing individual objects manu...
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 = c("prochi", "date_admission"),...
2006 Mar 09
1
HCLUST subroutine question -- FORTRAN DO loops
...DO 50 K=1,N IF (.NOT.FLAG(K)) GOTO 50 IF (K.EQ.I2) GOTO 50 IF (I2.LT.K) THEN IND1=IOFFST(N,I2,K) ELSE IND1=IOFFST(N,K,I2) ENDIF IF (J2.LT.K) THEN IND2=IOFFST(N,J2,K) ELSE IND2=IOFFST(N,K,J2) ENDIF IND3=IOFFST(N,I2,J2) D12=DISS(IND3) C C WARD'S MINIMUM VARIANCE METHOD - IOPT=1. C IF (IOPT.EQ.1) THEN DISS(IND1)=(MEMBR(I2)+MEMBR(K))*DISS(IND1)+...
2011 Dec 04
1
similarity matrix
...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 1 1 1 And I want to go to this: ind1 ind2 ind3 ind1 0 4 2 ind2 4 0 4 ind3 2 4 1 is there a way to do this? Than...
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 66...
2011 Dec 03
1
pivot table help
...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 table for each individual within each cluster. So I want to go from: Cluster Member1 Member2 etc. 1 ind1 ind2 2 ind3 ind1 3 ind2 ind1 to cluster ind1 ind2 ind3 1 1 1 0 2 1 0 1 3 1 1 0 Has anybody any idea how I can do this? I already tried alot...
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 ols(nareit ~ SnP500 + d3yrtr - 1) : length of dimnames [2] not equal to array extent same with +0 instead of -1. Is there a different way to create an ols object wit...
2015 Nov 20
1
Good practice for naming classes, builders, attributes, getters/setters for object composition
...upper case letters. My problem is that, when I build an object containing an other object (of an other class), at the end my getters can have the same name as my builders. Here is an example. Lets define a first class "bonds" to store atomic bonds information: bonds <- function(ind1, ind2, order){ obj <- data.frame(ind1 = ind1, ind2 = ind2, order = order) class(obj) <- c("bonds", class(obj)) return(obj) } Now I when to define an other class to store atomic properties. As atoms can be bonded to each other, I add a "bonds" attribute which is of class &...
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, 2L), test3 = c(1.1, 28, 9, 1.2)), .Names = c("ind", "test1", "test2", "test3"), class = "data.frame", row.names = c(NA, -4L)) terms_include <- c(&q...
2005 Sep 28
3
xyplots
Hi All, I have a four panel xyplot. I wish to plot each point as an open or filled circle depending on the value of an indicator variable. I assume I need to use panel.superpose(), but I can't figure out the syntax from lattice documentation. Running R 2.1 under Mac OS X 10.4.2. Any suggestions would be appreciated. Nathan Nathan Leon Pace, MD, MStat University of Utah Salt Lake
2010 Jan 20
7
Data Manipulation
Dear All, I would like to to group the Ticker by Industry and create file names from the Industry Factor and export to a txt file. I have tried the folowing ind=finvizAllexETF$Industry ind is then "Aluminum" "Business Services" "Regional Airlines" ind2=gsub(" " ,"",ind) ind3 [1] "Aluminum" "BusinessServices" "RegionalAirlines" > for (i in 1:3) ind3[i]<- AllexETF$Ticker[AllexETF$Industry==ind2[i]] Warning messages: 1: In ind3[i] <- finvizAllexETF$Ticker[AllexETF$Industry == ind2...
2009 Aug 09
1
problem adding columns to matrix
...cs 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 factor sex with individual 1 & 2 being Males and 3 & $ being Females. HERE IS HOW I PROCEDED, getting 2 problems 1) what are those warning messages i got when i generate the m matrix (the italian text stand for "the numerical expression h...
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 ind3<-((pin[j] + 1) <= ind) & (ind <= pin[j + 2]) & ((pin[j+x] + 1) <= ind) & (ind <= pin[j+x + 2]) #but it doesn't work !...
2009 Feb 08
0
recursive derivative a list of polynomials
...o evaluate the > polynomials at > > Pl <- as.polylist(legendre.polynomials(l)) > > Plm <- lapply(seq_along(Pl), function(ind) md(Pl[[ind]], ind-1)) > > Plm.theta <- lapply(seq_along(Plm), function(ind) # treat each order l > sapply(seq_along(Plm[[ind]]), function(ind2) # treat each order m > (-1)^ind2 *(1-cos(theta)^2)^(ind2/2) * as.function(Plm[[ind]] > [[ind2]])( cos(theta)) )) # evaluate the expression in theta I tried (unsuccessfully) to get inspiration from Recall() but since I want to store the intermediate derivatives it doesn't seem ve...
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 time pick 3 individuals and write them to a new variable. I want to do this 100 times s...