similar to: implicit loop for nested list

Displaying 20 results from an estimated 900 matches similar to: "implicit loop for nested list"

2023 Jan 27
1
implicit loop for nested list
I would use replicate() to do an operation with random numbers repeatedly: ``` mysim <- replicate(10, { two.mat <- matrix(rnorm(4), 2, 2) four.mat <- matrix(rnorm(16), 4, 4) list(two.mat = two.mat, four.mat = four.mat) }) ``` which should give you a matrix-list. You can slice this matrix-list just like normal, then cbind it in one step: ``` two.mat <-
2013 Feb 01
2
Nested loop and output help
Hello Everyone, My name is Thomas and I have been using R for one week. I recently found your site and have been able to search the archives of posts. This has given me some great information that has allowed me to craft an initial design to an inquiry I would like to make into the breakdown of McNemar's test. I have read an intro to R manual and the posting guides and hope I am not violating
2023 Nov 18
1
combine barchart and xyplot in lattice
On Sat, 18 Nov 2023 at 06:44, Naresh Gurbuxani <naresh_gurbuxani at hotmail.com> wrote: > > In below graph, I would like to add two vertical lines using > panel.abline(). Is this possible? I assume you want the 'v' variable in panel.abline() to be interpreted in the context of your x-axis, which here represents a factor variable. Unless two factor variables have the same
2023 Nov 18
1
combine barchart and xyplot in lattice
In below graph, I would like to add two vertical lines using panel.abline(). ?Is this possible? Thanks, Naresh mydf <- data.frame(hour = rep(6:20, 2), traffic = c(round(dnorm(6:20, 9, 3) * 10000), round(dnorm(6:20, 17, 4) * 10000)), direction = rep(c("inbound", "outbound"), c(15, 15))) vehicles <- data.frame(hour = 6:20, count = c(100, 120, 140, 125, 105, 80, 70, 75,
2012 Jun 14
0
fixed trimmed mean for j-group
Hello...i want to find the empirical rate for type 1 error using fixed trimmed mean. To make it easy, i'm referring to journal given by this website http://www.academicjournals.org/ajmcsr/PDF/pdf2011/Yusof%20et%20al.pdf. I already run the programme and there is no error in it but i got zero for the empirical rate of type 1 error. The empirical rate for the type 1 error given in the journal
2012 Jul 07
0
fixed trimmed mean for group
Hello, I haven't found errors in your code. I implemented the test in the paper (the first, fixed symetric mean) and it also gives me zero Type I errors, when alpha = 0.05. Try to see the value of min(pv) or to plot the histogram of 'pv', hist(pv) and you'll see that there are no significant p-values, at that level. Anyway I'll continue to look at it, but my first
2013 Apr 24
2
Distance matrices Combinations
Dear UseRs, MY PROBLEM IS A SMALL PIECE OF A REAL BIG AND A COMPLICATED PROBLEM. IF I DELIBERATE IN A VERY SIMPLE WAY THEN ALL I WANT IS TO PUT ALL THE POSSIBLE COMBINATIONS OF 75 DISTANCE MATRICES (BY TAKING 4 MATRICES, MORE COMMONLY 75C4), in the following equation. t<-as.matrix((MAT1)^2+(MAT2)^2+(MAT3)^2+(MAT4)^2+,upper=T,diag=T)) Then "1215450" values of "t"(one for
2012 Nov 12
5
Matrix to data frame conversion
I have a matrix which I wanted to convert to a data frame. As I could not succeed and resorted to export to csv and reimport it again. Why did I fail in the attempt and how can I achieve what I wanted without this roundabouts? The original matrix: > str(comb_model0) num [1:90, 1:4] 3.5938 0.0274 0.0342 0.0135 0.0207 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:90]
2004 Sep 27
8
cannot assign dimnames
Dear list, If anyone knows how to assign dimnames to matrices or arrays I would be most grateful for help. I've tried various permutations of likely-looking code but get error messages every time. I could find no example in the documentation. Many thanks, Dan Bebber Department of Plant Sciences University of Oxford South Parks Road Oxford OX1 3RB UK Tel. 01865 275000
2001 Sep 27
1
cuts and breaks
Hi I'm using the "image" function to produce a plot and I want to define the breaks using "cut" and the colors using "heat.colors". > image(interp(mat2[,2],mat2[,1],mat2[,3]),breaks=cut(mat2[,3],30),col=heat.colors(29)) Error in image.default(interp(mat2[, 2], mat2[, 1], mat2[, 3]), breaks = cut(mat2[, : must have one more break than colour The
2013 Feb 13
3
date and matrices
Hi Elisa, Try this: date1<-format(seq.Date(as.Date("1991.1.1",format="%Y.%m.%d"),as.Date("1996.12.31",format="%Y.%m.%d"),by="day"),"%Y.%m.%d") ?length(date1) #[1] 2192 mat1<-matrix(c(.314,.314,.273,.273,.236,.236,.236,.236,.273,.314,.403,.314),ncol=1) res1<-
2010 Feb 12
3
Code working but too slow, any idea for how to speed it up ?(no loop in it)
Hello my friends, here is a code I wrote with no loops on matrix that is taking too long (2 seconds and I call him 720 times --> 12 minutes): mat1 and mat2 are both matrix with 103 columns and 164 rows. sequence <- matrix(seq(1 : ncol(mat1))) returns <- apply(sequence, 1, function, mat1= mat1, mat2 = mat2, day = 1) function<- function(mat1, mat2, colNb, day){
2005 Nov 03
4
merging dataframes
Dear List, I often have to merge two or more data frames containing unique row names but with some columns (names) common to the two data frames and some columns not common. This toy example will explain the kind of setup I am talking about: mat1 <- as.data.frame(matrix(rnorm(20), nrow = 5)) mat2 <- as.data.frame(matrix(rnorm(20), nrow = 4)) rownames(mat1) <- paste("site",
2007 Nov 12
1
update matrix with subset of it where only row names match
I guess this has a simple solution: I have matrix 'mat1' which has row and column names, e.g.: A B C row1 0 0 0 row2 0 0 0 .... rown 0 0 0 I have a another matrix 'mat2', essentially a subset of 'mat1' where the rownames are all in 'mat1' e.g.: B row3 5 row8 6 row54 7 I want to insert the values of matrix mat2 for column B (in reality it could be some or
2012 Mar 12
1
2 images on one plot
Dear all with image I can plot only one set of values in one plot. Do somebody have any insight how to put those 2 matrices into one picture so that in one cell in image picture are both values from mat[1,1] and mat2[1,1]. mat<-matrix(1:4, 2,2) mat2<-matrix(4:1,2,2) x <-1:2 y <-1:2 image(x, y, mat) image(x, y, mat2) The only way I found is to mix x or y for both matrices let
2005 Sep 09
3
how to do something like " subset(mat, ("col1">4 & "col2">4)) "
Dear all, I have a problem with the "subset()" function. I spent all day yesterday with a collegue to solve it and we did not find a satisfying solution (even in the archived mails), so I ask for your help. Let's say (for a simple example) a matrix mat: R> mat cola colb colc [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 My goal is to select the lines of the matrix on the basis of the
2007 Apr 20
2
R: Appending the files
Hello R-Experts, I am a beginner to R. Can someone please look at my problem I am trying to append the files in R but couldn't get the answer properly. My code is mat1<-matrix(0,2,3) mat2<-matrix(1,2,3) write.table(mat1,"foo.csv",sep=",",col.names=NA) write.table(mat2,"foo.csv", sep=",", col.names=NA, append = TRUE) I am getting a warning
2010 Jan 29
7
Simple question on replace a matrix row
Hello, I have a matrix mat1 of dim [1,8] and mat2 of dim[30,8], I want to replace the first row of mat2 with mat1, this is what I do: mat2[1,]<-mat1 but it transforms mat2 in a list I don't understand, I want it to stay a matrix... ----- Anna Lippel -- View this message in context: http://n4.nabble.com/Simple-question-on-replace-a-matrix-row-tp1427857p1427857.html Sent from the R help
2007 Jul 24
1
cor inside/outside a function has different output
I'm calculating correlations between two matrices mat1 <- matrix(sample(1:500,25), ncol = 5, dimnames=list(paste("mat1row", 1:5, sep=""), paste("mat1col", 1:5, sep=""))) mat2 <- matrix(sample(501:1000,25), ncol = 5, dimnames=list(paste("mat2row", 1:5, sep=""), paste("mat2col", 1:5, sep="")))
2011 May 04
1
hurdle, simulated power
Hi all-- We are planning an intervention study for adolescent alcohol use, and I am planning to use simulations based on a hurdle model (using the hurdle() function in package pscl) for sample size estimation. The simulation code and power code are below -- note that at the moment the "power" code is just returning the coefficients, as something isn't working quite right. The