similar to: help on extracting values from a matrix

Displaying 20 results from an estimated 1000 matches similar to: "help on extracting values from a matrix"

2013 Jan 31
1
Using eigen() for extracting only few major eigenpairs
Hi everyone, I am using eigen() to extract the 2 major eigenpairs from a large real square symmetric matrix. The procedure is already rather efficient, but becomes somehow slow for real time needs with moderately large matrices (few thousand lines). The R implementation statically extracts all eigenvalues (and optionally associated eigenvectors). I heard about optimizations of the eigen
2012 Sep 27
1
Problem with grid.rect
I have a stupid problem that is currently driving me crazy... Let us suppose that I want to draw a big red square in the middle of my current device (say X11) I tried the following code : pushViewport(viewport(xscale=c(0,1), yscale=c(0,1)), just=c("center", "center")) vp1 <- viewport(x=unit(0.5, "native"), y=unit(0.5, "native"), width=unit(0.4,
2012 Nov 04
1
Rd2pdf freeze
Hi everyone, >From the currently available version of the package VBmix, I would like to retrieve the intermediate .tex file that generates the VBmix-manual.pdf file. Formerly, running R CMD check with --no-clean allowed to get this tex source from a hidden directory : this feature was removed, but can apparently still be accessed through R CMD Rd2pdf --no-clean. Surprisingly, while the
2012 Oct 10
1
Filling points in a trellis object
With the following code : I would like to plot 4 points, and have the circle and diamond shapes filled with grey. What am I missing ? Thanks by advance for your help, Pierrick Bruneau Research Fellow CRP Gabriel Lippmann -- View this message in context: http://r.789695.n4.nabble.com/Filling-points-in-a-trellis-object-tp4645679.html Sent from the R help mailing list archive at Nabble.com.
2013 Mar 20
2
problem subsetting data.frame in R version 2.15.2 for Windows
Good day. I create a data frame like this: > data <- data.frame(a=1:10,b=11:20,c=21:30) I can subset this data.frame by saying: > data[data$a>7,] and I get this result a b c 8 8 18 28 9 9 19 29 10 10 20 30 I understand I should get the same result by saying
2013 Mar 20
3
highlight overlapping region of two densities
Hi all. I would like to highlight overlapping regions of two densities and I could not find a way to do it. Here is the sample code: myd <- c(2,4,5, 4,3,2,2,3,3,3,2,3,3,4,2,4,3,3,3,2,2.5, 2, 3,3, 2.3, 3, 3, 2, 3) myd1 <- myd-2 plot(range(density(myd)$x, density(myd1)$x), range(density(myd)$y, density(myd1)$y), type = "n") lines(density(myd), col=1, lwd=4)
2013 Mar 08
2
Unexpected behaviour of apply()
Hello everyone, Considering the following code sample : ---- indexes <- function(vec) { vec <- which(vec==TRUE) return(vec) } mat <- matrix(FALSE, nrow=10, ncol=10) mat[1,3] <- mat[3,1] <- TRUE ---- Issuing apply(mat, 1, indexes) returns a 10-cell list, as expected. Now if I do: ---- mat[1,3] <- mat[3,1] <- FALSE apply(mat, 1, indexes) ---- I would expect a
2013 Jun 18
2
find closest value in a vector based on another vector values
Dear All, would you please provide your thoughts on the following: let us say I have: a <-c(1,5,8,15,32,69) b <-c(8.5,33) and I would like to extract from "a" the two values that are closest to the values in "b", where the length of this vectors may change but b will allways be shorter than "a". So at the end based on this example I should have the result
2014 Dec 18
2
segfault when trying to allocate a large vector
Dear R contributors, I'm running into trouble when trying to allocate some large (but in theory viable) vector in the context of C code bound to R through .Call(). Here is some sample code summarizing the problem: SEXP test() { int size = 10000000; double largevec[size]; memset(largevec, 0, size*sizeof(double)); return(R_NilValue); } If size if small enough (up to 10^6), everything is
2014 Dec 11
2
Fwd: No source view when using gdb
Dear R contributors, Say I want to debug some C code invoked through .Call() - say "varbayes" in the VBmix package. following the instructions in "Writing R Extensions", I perform the following actions : R -d gdb run library(VBmix) CTRL+C break varbayes signal 0 mod <- varbayes(as.matrix(iris)[,1:4], 2) The breakpoint is indeed activated, seemingly at the correct position
2014 Dec 20
2
Unexplained difference between results of dppsv and dpotri LAPACK routines
Dear R contributors, Considering the following sample C code, that illustrates two possible uses of a Cholesky decomp for inverting a matrix, equally valid at least in theory: SEXP test() { int d = 2; int info = 0; double mat[4] = {2.5, 0.4, 0.4, 1.7}; double id[4] = {1.0, 0.0, 0.0, 1.0}; double lmat[3]; F77_CALL(dpotrf)("L", &d, mat, &d, &info); lmat[0] = mat[0]; lmat[1]
2013 Jan 25
5
Loop question?
Dear All   I have the following data (somewhat simplyfied):   TINF <-1 a <-c(500,750,1000,1250,1500,1750,2000) b <-c(8,12,18,24,36,48,60,72,96)   following function:   infcprodessa <-function (D, tin, tau, ts)   (D * (1 - exp(-0.048 * tin))/(tin * (0.048*79) * (1 - exp(-0.048 * tau)))) * exp(-0.048 * (ts - tin)) z <-sapply(1:1, function(n) infcprodessa(1000,TINF,12,12-TINF))   is
2012 Jun 07
4
"Re-creating" distributions
Dear All,   I often have to work with certain models in which I try to "reproduce" a distribution the best I can with very little known information avaible. Is there a package or function in R that could best reproduce a probability distribution using only the mean, median and SD values availble without knowing the actual distribution type to begin with and/or the covariance matrix (for
2012 Sep 02
3
Help on finding specific columns in matrix
Dear All,   I have a matrix with 33 columns and 5000 rows. I would like to find 2 specific columns in the set: the one that holds the highest values and the one that holds the lowest values. In this case the column's mean would be apropriate to use to try to find those specific columns because each columns mean is different and they all change together based on the same "change of rate
2012 Sep 08
3
Apply a function to columns of a matrix
Dear All,   as a follow up to my previous e-mail (I think I am getting closer...):   I am trying to apply the trapezoidal functions to a matric column by column. I have the following code:   a <-matrix(c(1:100),ncol=10) b <-matrix(c(2,4,6,8,10,12,14,16,18,20))   apply(a,2,function(b,a) sum(diff(b)*(a[-1]+a[-length(a)]))/2)   for some reason i get an error message: Error in FUN(newX[[, i],
2012 Sep 12
2
Help on converting a Sweave document to PDF
Dear All,   I am working with a Sweave document to be converted into PDF using Rstudio. It seems to me that my R code will also show up after conversion, which I would like not to happen. Is there a way to specify a command that I could place on the beggining and at the end of the R code that would allow R to recognize the area where my R code is and would ignor it when the data is converted?  
2012 Aug 31
3
Help on numerical object and ifelse function
Dear All,   this is probably an easy one but I can not get a handle on it:   x <-c(1,2,3,4,5) y <-c(6,7,8,9,10) z <-15 w <-ifelse(z>14,x,y)   this will give me a value of 1 for w. What I would like to get is the whole string of x, so that w would become a numeric object of 5 characters exactly the same as x.   Apreciate the help,   Sincerely,   Andras [[alternative HTML version
2013 Mar 20
2
remove specific number of rows from a matrix
Dear All,   sorry, got stuck again on the following: let us say we have:   a <-c(1:5) b <-c(6:10) d <-cbind(a,b)     from d I would like to remove total number of rows based on the length of f. So if:   f <-c(1)   my result is working great with the following solution:   d[-length(f),]   so I get: a b [1,] 2 7 [2,] 3 8 [3,] 4 9 [4,] 5 10 but if I do: f <-c(1,2) then I get: 
2012 Dec 01
3
screen if a value is within range
Dear all,   could you please give me some pointers on how I could make R screen for a value if it falls within a certain range? I looked at the subset function, but is not doing it, perhaps because I only have 1 value to screen?   aptreciate the input   ex: a <-16.5 I would like to screen to see if a is within the range of 15 to 20, (which it is:-)), and I would like the code to return a value
2012 Aug 30
2
Help on Plot Title where text is "mixed" with numerical carachters
Dear All,   I have the following code set up:   x <-2000 y <-8 z <-3   I would need to use these numbers to show up in my plot title "mixed" with text. The x,y,z numbers would need to change, the text would not. So my title should look like this   "x txt1 y txt2 z txt3"   so if: txt1=hours txt2=minutes txt3=seconds   then my title of the plot should read:   2000 hours