similar to: replaces a matrix of "NA"s in an array with the previous matrix with numbers

Displaying 20 results from an estimated 1000 matches similar to: "replaces a matrix of "NA"s in an array with the previous matrix with numbers"

2009 Dec 03
4
Replace values in a vector
Hi all, I have a vector like this: x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8) I would like to replace the zero values with the first previous non zero value. my returning vector should look like this: y<-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8) How can I do this in R without using for loop? Thank you
2010 Jul 14
1
Entropy of a Markov chain
Does anyone have any "R" code for computing the entropy of a simple first or second order Markov chain, given a transition matrix something like the following (or the symbol vector from which it is computed)? AGRe ARIe CSRe DIRe DSCe eos HRMe SPTe TOBe AGRe 0.0000000 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000
2013 Mar 14
1
ggplot2 problem
Hello all! I have a problem with ggplot2 library. I want to do an heat map and the y variables are the year months. If I use the following code, he y values are in alphabetical order, but I want it in month order. The code is: library(reshape) library(ggplot2) library(scales) p <- ggplot(data.m, aes(variable, Month)) + geom_tile(aes(fill = value),
2011 Oct 31
3
Plot two matrices and keeping the record of row names
Dear all, I have two data frames- x1 and y1 with same row names and column names(actually the names of the patients). x1 a b c d e a 1.0000000 0.4730679 0.6226994 0.6036036 0.6433333 b 0.4730679 1.0000000 0.6227273 0.6303855 0.5730858 c 0.6226994 0.6227273 1.0000000 0.7290503 0.6900585 d 0.6036036 0.6303855 0.7290503 1.0000000
2009 Jun 10
1
R: Best way to plot a Matrix of all possible pair combinations
Hallo R Users, Please help I have some distance matrix data like > M[1:10,] [,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.8750000 0.5000000 0.5000000 0.3750000 0.6250000 0.00000000 [2,] 0.8928571 1.0000000 0.0000000 0.8928571 0.1071429 0.00000000 [3,] 0.8928571 1.0000000 0.0000000 0.8928571 0.1071429 0.00000000 [4,] 0.8928571 1.0000000 0.0000000 0.8928571
2017 Jun 26
3
Jagged ROC curves?
Hi, I was trying to draw some ROC curves (prediction of case/control status), but seem to be getting a somewhat jagged plot. Can I do something that would 'smooth' it somewhat? Most roc curves seem to have many incremental changes (in x and y directions), but my plot only has 4 or 5 steps even though there are 22 data points. Should I be doing something differently? How can I provide a
2017 Jun 26
0
Jagged ROC curves?
> On Jun 26, 2017, at 11:40 AM, Brian Smith <bsmith030465 at gmail.com> wrote: > > Hi, > > I was trying to draw some ROC curves (prediction of case/control status), > but seem to be getting a somewhat jagged plot. Can I do something that > would 'smooth' it somewhat? Most roc curves seem to have many incremental > changes (in x and y directions), but my plot
2010 Apr 29
1
R Anova Analysis
Dear all, I have a quite basic questions about anova analysis in R, sorry for this, but I have no clue how to explain this result. I have two datasets which are named: nmda123, nmda456. Each dataset has three samples which were measured three times. And I would like to compare means of them with Posthoc test using R, following please see the output: (CREB, mCREB and No virus are the name of
2010 Dec 13
2
rpart.object help
Hi, Suppose i have generated an object using the following : fit <- rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) And when i print fit, i get the following : n= 81 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 81 17 absent (0.7901235 0.2098765) 2) Start>=8.5 62 6 absent (0.9032258 0.0967742) 4) Start>=14.5 29 0 absent (1.0000000
2007 Jul 03
1
loop causes syntax error in print()
I am having trouble printing a table out to the GUI display when the table is created and printed within a loop. I get a "Error: syntax error message" If I comment out the print statement, the loop runs fine and I can print out the last iteration of the table. ...[multiple loops and calculations ending with.....]... +
2005 Dec 29
2
loop
Dear All, I have to use loop over an array so I am using following procedure count<-1 repeat{ count<-count + 1 c(g[count],1:i[count]) ->qw if(count>5)break } as a result qw is [1] 0.9643836 1.0000000 2.0000000 3.0000000 4.0000000 5.0000000 [7] 6.0000000 7.0000000 8.0000000 9.0000000 10.0000000 11.0000000 [13] 12.0000000 13.0000000 14.0000000 15.0000000 16.0000000
2009 Jun 07
2
Need some help in R : value more than equals to a row.
Hallo, I was trying some code, but couldn't make one step of the code properly. Can anybody please help me? I have one matrix like this > values [,1] [,2] [,3] [,4] [,5] [1,] 0.7777778 0.36111111 0.22222222 0.1388889 0.0000000 [2,] 1.0000000 0.00000000 0.53846154 0.0000000 0.5384615 [3,] 0.5200000 0.48000000 0.64000000 0.0000000 0.8800000 [4,] 0.8928571
2007 Mar 09
1
lpSolve space problem in R 2.4.1 on Windows XP
Hi. I am trying to use the linear optimizer from package lpSolve in R 2.4.1 on Windows XP (Version 5.1). The problem I am trying to solve has 2843 variables (2841 integer, 2 continuous) and 8524 constraints, and I have 2 Gb of memory. After I load the input data into R, I have at most 1.5 Gb of memory available. If I start the lp with significantly less memory available (say 1 Gb), I get
2010 Oct 01
1
Question about Reduce
Hello! In the example below the Reduce() function by default assigns "a" to be the last accumulated value and "b" to be the current value in "x". I could not find this documented anywhere as the default settings for the Reduce() function. Does any sort of documentation for this behavior exist? x <- c(0,0,0,0,0,1,0,0,0,5,0,0,0,7,0,0,0,8,5,10)
2019 Nov 19
2
Why is matrix product slower when matrix has very small values?
Hi, I experience surprisingly large timing differences for the multiplication of matrices of the same dimension. An example is given below. How can this be explained? I posted the question on Stackoverflow: https://stackoverflow.com/questions/58886111/r-why-is-matrix-product-slower-when-matrix-has-very-small-values Somebody could reproduce the behavior but I did not get any useful explanations
2012 Sep 19
1
Wilcoxon Test and Mean Ratios
Hello All, I am writing to ask your opinion on how to interpret this case. I have two vectors "a" and "b" that I am trying to compare. The wilcoxon test is giving me a pvalue of 5.139217e-303 of a over b with the alternative "greater". Now if I make a summary on each of them I have the following > summary(a) Min. 1st Qu. Median Mean 3rd Qu.
2010 Jun 29
1
Model validation and penalization with rms package
I?ve been using Frank Harrell?s rms package to do bootstrap model validation. Is it the case that the optimum penalization may still give a model which is substantially overfitted? I calculated corrected R^2, optimism in R^2, and corrected slope for various penalties for a simple example: x1 <- rnorm(45) x2 <- rnorm(45) x3 <- rnorm(45) y <- x1 + 2*x2 + rnorm(45,0,3) ols0 <- ols(y
2006 Feb 06
2
novice questions about programming in "R"
folks, I have been struggling with the "R" documentation for too long now and I need a simple answer on two questions. The documentation does not have adequate examples. Please help. given two equal vector lists: A <- c(0,1,2,3) B <- c(5,6,7,8) [Question #1] how do I dump them to a text file with the following format:
2010 Jun 06
1
I need help in analyzing
I'm sory for my weak english. I need to analyze this subject : x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 y 0 0 1 0 0 1 0 0 1 0 czarne 1 1 0 0 0 0 1 0 0 0 rude 0 0 1 0 0 1 1 0 0 0 braz 0 0 1 0 1 0 1 0 0 0 blond 1 0 0 0 0 1 0 0 0 1 rude 1 1 0 0 0 0 0 0 0 1 blond 0 0 1 1 0 0 0 0 1 0 czarne 1 0 0 1 0 0 1 0 0 0 blond 0 0 1 0 0 1 1 0 0 0 blond 1 0 0 0 0 1 1 0 0 0 czarne 0 0 1 0 0 1 0 0 0 1 czarne 1 0 1 0 0 0
2009 Dec 30
1
Removing replicated rows
Dear All, I have a matrix like X and need to create a new matrix based on the vector m which gives the number of replicates for each unique row. The resulting matrix should look like y. > x x1 x2 [1,] 2 0.5 [2,] 2 0.5 [3,] 2 0.5 [4,] 6 1.0 [5,] 6 1.0 [6,] 6 1.0 [7,] 1 1.5 [8,] 1 1.5 [9,] 1 1.5 [10,] 4 2.0 [11,] 4 2.0 [12,] 3 2.5 [13,] 3 2.5 [14,] 3 2.5 m<-c(1,1,3,1,2) > y y1 y2