similar to: which.max2()

Displaying 20 results from an estimated 700 matches similar to: "which.max2()"

2010 Aug 03
4
Need help on upper.tri()
HI, I am really messing up to make a symmetrical matrix using upper.tri() & lower.tri() function. Here is my code:   > set.seed(1) > mat = matrix(rnorm(25), 5, 5) > mat            [,1]       [,2]       [,3]        [,4]        [,5] [1,] -0.6264538 -0.8204684  1.5117812 -0.04493361  0.91897737 [2,]  0.1836433  0.4874291  0.3898432 -0.01619026  0.78213630 [3,] -0.8356286  0.7383247
2010 Dec 23
2
R-way to doing this?
Dear friends, hope I could be able to explain my problem through following example. Please consider this: > set.seed(1) > input <- rnorm(10) > input [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884 > tag <- vector(length=10) for(i in 1:10) # if there is any ****error**** in evaluating
2011 Jun 06
2
A Calculation on list object
Hello, I am into some calculation on a list object, therefore requesting the peers if there is any short cut way to so the same calculation. Let say I have following list object: > List <- vector('list', length = 3) > set.seed(1) > List[[1]] <- rnorm(5) > List[[2]] <- rnorm(2) > List[[3]] <- rnorm(7) > List [[1]] [1] -0.6264538 0.1836433 -0.8356286
2010 Sep 03
2
Matrix to list
Dear all, suppose I have following matrix:   > mat <- matrix(rnorm(25), 5) > > mat             [,1]       [,2]        [,3]       [,4]       [,5] [1,]  0.97056228 -1.3278509 -0.73511792  2.1650629 -0.4411997 [2,]  0.58613700 -0.2559899 -1.18334248 -1.4990907  1.8138846 [3,] -1.03333313  2.0227887  0.89622681  0.6483973 -1.5523283 [4,]  0.38968833  0.2490004 -0.02301061 -0.2705150
2005 Mar 04
11
R: simulation
hi all a simple question i want to run simulations in r. i however want the experiments to be repeated at a later time with exactly the same numbers by other users. can i set the random number seed for rnorm in some way? e.g. is there some arguement that goes with rnorm? please supply an example regards Allan
2009 Jun 11
2
How to force R to print 2 decimal places in column of a data.frame?
How to force R to print 2 decimal places in column of a data.frame? I tried to do so: x = inp(format(rounf(inp$Tamanho, 2), nsmall = 2),) where "INP" is data.frame and "Size" is the name of column. But has error: Error in eval.with.vis(expr, envir, enclos) : could not find function "inp" Lesandro Veja quais s?o os assuntos do momento no Yahoo! +Buscados
2011 Jul 16
2
(unclassified?) Help Question
Dear List, I'd appreciate you guidance for obtaining the desired result shown below, by combining tapply(x, g, mean) and g in the example. Basically, I'm trying to create a vector whose values are based on the result from tapply(x, g, mean) but that follow the pattern and length given by the factor g. Of course I'm looking for a generic solution (i.e, not something that just work
2011 Jan 25
1
NA printing
Hi. I'm writing a print method for an object that includes a numeric matrix for which the lower diagonal elements are not meaningful. So I make the lower diagonal of my matrix NA and print it. But my co-author does not like NA there and wants a dash. I have tried coercing the matrix to character, essentially by M[is.na(M)] <- "-" but this interferes with the pleasing column
2009 Jul 01
5
convert tabular time series into a matrix format
Hi, thanks everyone for any help in advance. I found myself dealing with a tabular time-series data formatted each row like [ time stamp, ID, values]. I made a small examples: X = data.frame(t=c(1,1,1,2,2,2,2,3,3,3,4,4,4,5,5),id =
2006 Oct 02
1
CCF and ACF
Dear all, given two numeric vectors x and y, the ACF(x) at lag k is cor(x(t),x(t+k)) while the CCF(x,y) at lag k is cor(x(t),y(t-k)). See below for a simple example. > set.seed(1) > x <- rnorm(10) > y <- rnorm(10) > x [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884 > y [1] 1.51178117 0.38984324
2005 Mar 01
6
Help : delete at random
Hello I would like to delete some values at random in a data frame. Does anyone know how I could do? With best regards Caroline
2009 Jun 22
2
Help on creating a sequence of vectors
I want to create a number of vectors like : vec1 <- rnorm(1) vec2 <- rnorm(2) vec3 <- rnorm(3) and so on........... Here I tried following : for (i in 1:10) paste("vec", i, sep="") <- rnorm(i) However obviously that is not working. Here vectors I need to be seperated i.e I do not want to create a "list". How to modify above code? -- View this
2004 Aug 13
1
How to use the whole dataset (including between events) in Cox model (time-varying covariates) ?
Hello, coxph does not use any information that are in the dataset between event times (or "death times") , since computation only occurs at event times. For instance, removing observations when there is no event at that time in the whole dataset does not change the results: > set.seed(1) > data <- as.data.frame(cbind(start=c(1:5,1:5,1:4),stop=c(2:6,2:6,2:5),status=c(rep(
2005 Sep 30
4
by() processing on a dataframe
I want to calculate a statistic on a number of subgroups of a dataframe, then put the results into a dataframe. (What SAS PROC MEANS does, I think, though it's been years since I used it.) This is possible using by(), but it seems cumbersome and fragile. Is there a more straightforward way than this? Here's a simple example showing my current strategy: > dataset <-
2008 Jun 12
3
Adding new columns to (output) data - e.g., read 5 cols write 8
Hello, I have the following task I'd like to accomplish: A file contains 5 columns of data (several hundred rows), let's call them a, b, c, d and e (ie these are their column headers) I also have a set of definitions, e.g., f = a + b g = a * 3 h = c + d etc. I would like to write out a new .rda file that contains columns a b c d e f g h etc. I.e. , the original data plus new columns
2008 May 06
2
building a formula string bit by bit ..
Hello, Still a newbie with R, though I have learned a lot from reading this list. I'm hoping someone can help with this question: I have two vectors, one for variables, and one for bits. I want to build a string (really a formula) based on the values in my vector of 1s and 0s in bits. If I have a one, I want to include the corresponding entry in the vars vector, otherwise ignore it. Of
2008 Jun 11
3
searching for specific row in matrix
Hi, I have matrix of bits and a target vector. Is there an efficient way to search the rows of the matrix for the target? I am interested in the first row index where target is found. Example: > source("lookup.R") [,1] [,2] [,3] [,4] [,5] [1,] 1 0 1 1 0 [2,] 1 1 0 1 0 [3,] 0 0 1 0 0 [4,] 1 0 0 1 1 [5,]
2008 May 07
1
Automatically generating new column names (and columns)
Once again I need to tap into the collective knowledge here. Let's say I have the following columns and data below Y X1 X2 X3 X4 I would like to generate additional new columns and column names (ie the data would be squared - and I'd like the column names to reflect this) like: Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2 I believe I can compute the values correctly with the code below, but I
2009 Feb 18
2
how to randomly eliminate half the entries in a vector?
(sorry if this is a duplicate-problems with posting at my end) ---- Hello all, I need some help with a nice R-idiomatic and efficient solution to a small problem. Essentially, I am trying to eliminate randomly half of the entries in a vector that contains index values into some other vectors. More details: I am working with two strings/vectors of 0s and 1s. These will contain about 200
2008 May 27
1
hash or other quick lookup function?
Hello all, I have a matrix of bit values. I compute certain values based on the bits in each row. There may be *duplicate* entries in the matrix, ie several rows may be identical. These rows change over time, and identical entries may not be next to each other. Computing these values is time consuming, so I would like a way to store a value once it's computed. That way I would be able to