similar to: sequence of vectors

Displaying 20 results from an estimated 10000 matches similar to: "sequence of vectors"

2005 Nov 23
2
vector of permutated products
Given an x-vector with, say, 3 elements, I would like to compute the following vector of permutated products (1-x1)*(1-x2)*(1-x3) (1-x1)*(1-x2)*x3 (1-x1)*x2*(1-x3) x1*(1-x2)*(1-x3) (1-x1)*x2*x3 x1*(1-x2)*x3 x1*x2*(1-x3) x1*x2*x3 Now, I already have the correctly sorted matrix of permutations! So, the input looks something like: #input x<-c(0.3,0.1,0.2) Nx<-length(x) Ncomb<-2^Nx
2005 Sep 16
3
Replicate
Dear All, I have a vector x = (1,1,1,2,2,2,3,3,3,3) I am looking for a function to return a vector containing the distinct elements of x i,e y = (1,2,3) The following code gives the desired results: as.numeric(levels(as.factor(x))) Is there any other elegant way? Thanks, B --------------------------------- [[alternative HTML version deleted]]
2005 Oct 06
3
Singular matrix
Dear All, I have written the following programs to find a non-singular (10*10) covariance matrix. Here is the program: nitems <- 10 x <- array(rnorm(5*nitems,3,3), c(5,nitems)) sigma <- t(x)%*%x inverse <- try(solve(sigma), TRUE) while(inherits(inverse, "try-error")) { x <- array(rnorm(5*nitems,3,3), c(5,nitems)) sigma <- t(x)%*%x inverse <-
2005 Sep 21
3
Sort a data frame with respect to more than one variable
Dear All, How can I sort a data frame with respect to more than one variable? I know that for one variable X one may use: df[order(df$X), ] where df is the data frame containing X. Many thanks, Bernard --------------------------------- [[alternative HTML version deleted]]
2005 Sep 08
5
data manipulation
Dear All, I would be grateful if you can help me. My problem is the following: I have a data set like: ID time X1 X2 1 1 x111 x211 1 2 x112 x212 2 1 x121 x221 2 2 x122 x222 2 3 x123 x223 where X1 and X2 are 2 covariates and "time" is the time of observation and ID indicates the
2008 Jan 30
4
boxplot and number of observations per box
Dear all, How can I plot the number of observations per box in a boxplot. Many thanks, Bernard --------------------------------- [[alternative HTML version deleted]]
2005 Nov 10
3
Remove levels
Daer All, I have a factor variable, X with 5 levels. When I type tables(X) it gives me: table(X) 1 2 3 4 5 10 5 0 0 0 How to drop the levels with zeros such that when I will type: table(X) it will give me: table(X) 1 2 10 5 Thank a lot, Bernard --------------------------------- [[alternative HTML version deleted]]
2005 Dec 20
2
Time data
Dear All, I wonder how to compute the age from the date of birth and the date of examination. Suppose that have the following data: df <- as.data.frame(rbind(c(1,"10/08/1950","15/03/1998"), c(1,"10/08/1950","20/07/1998"), c(1,"10/08/1950","23/10/1998"))) names(df) <- c("ID", "date_birth",
2006 Feb 21
3
Compute a correlation matrix from an existing covariance matrix
Dear All, I am wondering if there is an R function to convert a covariance matrix to a correlation matrix. I have a covariance matrix sigma and I want to compute the corresponding correlation matrix R from sigma. Thank you very much, Bernard --------------------------------- [[alternative HTML version deleted]]
2007 Feb 07
3
generate Binomial (not Binary) data
Dear All, I am looking for an R function or any other reference to generate a series of correlated Binomial (not a Bernoulli) data. The "bindata" library can do this for the binary not the binomial case. Thank you, Bernard --------------------------------- [[alternative HTML version deleted]]
2010 Sep 02
2
lower triangle of the correlation matrix with xtable
Dear all, mydata<-data.frame(x1=c(1,4,6),x2=c(3,1,2),x3=c(2,1,3)) cor(mydata) x1 x2 x3 x1 1.0000000 -0.5960396 0.3973597 x2 -0.5960396 1.0000000 0.5000000 x3 0.3973597 0.5000000 1.0000000 I wonder if it is possible to fill only lower triangle of this correlation matrix? Using 'dist' doesn't seem to be useful as it doesnt allow to convert this table
2010 Mar 26
2
R loop help
Hi, I am tring to write a loop to compute this, ========================== x1=c( rep(-1,4), rep(1,4) ) x2=c( rep(c(-1,-1,1,1),2) ) x3=c( rep(c(-1,1),4) ) x1*x2 x1*x3 x2*x3 ======================== suppose i have x1,x2,x3 i want to compute their ' two factor interactions', x1x2,x1x3 and x2x3, I wrote ======================== for(i in 1:2){ for( j in i+1:3){ xij=c()
2006 Feb 02
2
re-coding variables
Dear All, I wonder how to re-code a categorical variable without using the ifelse loops. For example: Let X be a categorical variable with 6 levels, levels(X) = c(1,2,3,4,5,6) How to create a new categorical variable Y with levels, 10,11,12, say , such that: Y = 10 if X =1 or X=2 Y = 11 if X =3 or 4 Y =11 if X = 5 or 6 many thanks, Bernard
2012 Sep 12
3
how to create a substraction matrix (subtract a row of every column from the same row in other columns)
Hello I have data like this x1 x2 x3 x4 x5 I want to create a matrix similar to a correlation matrix, but with the difference between the two values, like this x1 x2 x3 x4 x5 x1 x2-x1 x3-x1 x4-x1 x5-x1 x2 x3-x2 x4-x2 x5-x2 x3 x4-x3 x5-x3 x4 x5-x4 x5 Then I
2005 Sep 21
1
Identical data frames
Dear All, Is there any R function to test if two data frames, say df1 and df2, having the same row names and the same column names are identiques? Thanks in advance, Bernard --------------------------------- [[alternative HTML version deleted]]
2006 Jun 29
1
specify y axis values
Dear All, I am looking how to specify the values on the y axis and x axis for a curve function. example: curve(2*x + 3, 0,10) gives me a range of x axis in (0,2,4,6,8,10) amd for yaxis (5,10,15,20). How to do in order to have the x axis in (0,1,2,3,4,5,6,7,8,9,10) and y axis in (5,6,7,8,......, 10). Thanks a lot, Bernard ---------------------------------
2007 Apr 27
1
bootstrap
Dear All, I would like to use a nonparametric bootstrap to calculate the confidence intervals for the 5% and 95% quantiles using boot.ci. As you know, boot.ci requires the use of boot to generate bootstrap replicates for my statistic. However this last function doesn't work in my case because I am missing something. Here is an example y <- rnorm(100) Quantile <-
2011 Sep 26
3
Nearest neighbour in a matrix
Hello all, I am brand new to R and doing an exercise for a class. I need to find the nearest neighbour for points in the following matrix: > DistanceMatrix x1 x2 x3 x4 x5 [1,] 0.000000 2.828427 1.581139 2.236068 2.000000 [2,] 2.828427 0.000000 1.581139 4.123106 2.000000 [3,] 1.581139 1.581139 0.000000 2.549510 2.121320 [4,] 2.236068 4.123106 2.549510
2006 Jun 15
1
xyplot problem
Dear all, I have created the following data (that you can run) in order to explain my problem: y <- rep(c(1,2), 8) id <- rep(1:8,each=2) x1 <- rep(c("-a","+a"), each = 8) x2 <- rep(c("-b","+b"), each = 2, times = 4) x3 <- rep(c("-c", "+c"), each = 4,2) df <- data.frame(cbind(id,y,x1,x2,x3)) If I do:
2006 Sep 27
1
Testing the equality of correlations
Dear All, I wonder if there is any implemented statistical test in R to test the equality between many correlations. As an example, let X1, X2, X3 X4 be four random variables. let Phi(X1,X2) , Phi(X1,X3) and Phi(X1,X4) be the corresponding correlations. How to test Phi(X1,X2) = Phi(X1,X3) = P(X1,X4)? Many thanks in advance, Bernard