similar to: Help : delete at random

Displaying 20 results from an estimated 5000 matches similar to: "Help : delete at random"

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
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
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 =
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
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
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
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
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(
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
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
2008 May 09
2
which.max2()
Hello, which.max() only returns one index value, the one for the maximum value. If I want the two index values for the two largest values, is this a decent solution, or is there a nicer/better R'ish way? max2 <-function(v) { m=which.max(v) v[m] = -v[m] m2=which.max(v) result=c(m, m2) result } Seems to work ok. Thanks, Esmail
2010 May 13
3
select subset based on another variable
Hi, dear R-helpers, I have a simple question regarding selecting subset of a variable based on another variable. Here is the example: xx=rnorm(10) id=sample(1:10, 10) temp=c(6, 1, 8, 2) Now, all I want is xx's that their id are 6, 1, 8, 2, instead of the position. Any suggestions ? Thank you all your help !! Carrie [[alternative HTML version deleted]]
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 <-
2011 Feb 02
0
How column names/row names are preserved in matrix calculation?
Can somebody tell me that, if I do some arithmetic calculation over 2 matrices then how the column names and row names are preserved? It seems that, for multiplication, column names and row names of the 2nd matrix are preserved and for additional, there seems not having any explicit rule: > set.seed(1) > dat1 <- matrix(rnorm(25), 5); colnames(dat1) = rownames(dat1) =
2005 Jun 17
1
About simulations
Hello I would like to generate covariance matrix with autoregressive structure. I saw some functions in nlme such as corAR1 for example but I don't know how to use it for my goal. Could someone help me or advise me another function? Thank you in advance Caroline
2006 Oct 11
1
About fitdistr
Dear all, I would like to estimate the parameters of a mixture of two beta binomial distributions. I saw the function fitdistr from the MASS library could be a solution but I have some difficulties. Does anyone know how to specify to fitdistr another function as these which are predefined? Or is there any other solution to estimate the parameters? Thank you in advance Caroline
2007 Apr 27
1
Issues with Sweave and inclusion of graphics from nlme
Dear all, I'm using the nlme package. I would like to introduce the plot of my groupedData object in my latex report using Sweave but it doesn't work. I have no error message in R (Sweave(my.file_Rnw)) and the plot is generated in R, but when I want to see the pdf (I'm using TexnicCenter) of my report, there is an error message and no pdf file is generated. It seems that the plot
2006 Feb 20
2
formatting results from a function argument
Hello all, I have a simple function which calculates summary statistics of a dataset in terms of a factor (say area). > x = data.frame(Area = c(rep("cleanup", 5), rep("ref", 5)), TcCB = c(rnorm(5)+2, rnorm(5)));x Area TcCB 1 cleanup 2.5829747 2 cleanup 2.6796868 3 cleanup 2.5437094 4 cleanup 2.8453616 5 cleanup 1.1789683 6 ref 1.0140391 7