similar to: extracting rows of a dataframe

Displaying 20 results from an estimated 10000 matches similar to: "extracting rows of a dataframe"

2005 Jul 13
2
Kronecker matrix product
Hi I want to write a little function that takes a matrix X of size m-by-n, and a list L of length "m", whose elements are matrices all of which have the same number of columns but possibly a different number of rows. I then want to get a sort of dumbed-down kronecker product in which X[i,j] is replaced by X[i,j]*L[[j]] where L[[j]] is the j-th of the "m" matrices. For
2005 Dec 15
5
How to simulate correlated data
Hello there, I would like to simulate X --Normal (20, 5) Y-- Normal (40, 10) and the correlation between X and Y is 0.6. How do I do it in R? Thank you very much Lisa Wang Msc. Princess Margaret Hospital Toronto, Ca
2006 Feb 18
3
Bug in Sweave? -- scoping problem? (PR#8615)
I have found a strange scoping problem in Sweave. The following Rnw file doesn't produce the same output in Sweave as it does if I produce an R file using Stangle and execute that: \documentclass[12pt]{article} \begin{document} <<R>>= election <- data.frame(A=1:3, B=9:7, C=rep(0,3)) partytotal <- rep(0, ncol(election)) for (i in 1:ncol(election)) { partytotal[i] <-
2010 Apr 01
2
pdf files in loops
I need to make a bunch of PDF files of histograms. I tried gatelist = unique(mdf$ArrivalGate) for( gate in gatelist) { outfile = paste("../", airport, "/", airport, "taxiHistogram", gate, ".pdf", sep="") pdf(file = outfile, width = 10, height=8, par(lwd=1)) title=paste("Taxi time for Arrival Gate", gate, "by
2010 Jul 20
1
Call to rgamma using .C causes R to hang
Hi, I've been trying to get this working for ages, but it causes R to hang. Here is my C code saved as test1.c # include <R.h> # include <Rmath.h> void test1 (double *x, double *result) { result[0] = rgamma(*x, 2.0); } This was compiled using R CMD SHLIB test1.c & loaded in R using: dyn.load("test1.dll") out <-
2006 Mar 14
1
Internal codes of the factor
Hello! I am writing some functions and I repeatedly acces internal factor codes. I figured out that internal codes are 1:n where 1 represents 1st level, 2 2nd level etc. This is not documented and I wonder if this is on purpose and subject to change or would be a good idea to add this to documentation for factor? I can prepair a pacth if this is accepted. -- Lep pozdrav / With regards,
2006 Apr 17
3
bounding box in PostScript
When a graph is saved as PostScript, the bounding box is often too big. A consequence is that when the graph is included in a LaTeX document, the spacing does not look good. Is this a recognized problem? Is someone working on it? Could I help? David
2006 Nov 13
1
"stem" does not give a correct answer (PR#9359)
Full_Name: Myung Geun Kim Version: 2.4.0 OS: Window XP Submission from: (NULL) (210.110.8.105) For the data c1 of size 14, stem provides the following result. ************************************************************** >c1 [1] 14 39 70 11 38 20 37 15 41 74 74 34 48 51 ZZangi>stem(c1) The decimal point is 1 digit(s) to the right of the | 0 | 145 2 | 04789 4 | 181 6 | 044
2005 Dec 23
1
how to specify dev.print target by a variable?
I want to do the following: DEVw=500 DEVh=350 fname="my_plot" dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg="transparent") How do I do this such that I can specify FOO to be one of several choices? (GDD, PNG, postscript, etc.) If I make FOO a character variable, then "dev.print" complains. I tried a simpled "substitute" but
2006 Jun 01
1
"predict" function does not provide SE estimates for multivariate timeseries VAR models?
What can I do? Thanks a lot! [[alternative HTML version deleted]]
2006 Jul 23
1
How to pass eval.max from lme() to nlminb?
Dear R community, I'm fitting a complex mixed-effects model that requires numerous iterations and function evaluations. I note that nlminb accepts a list of control parameters, including eval.max. Is there a way to change the default eval.max value for nlminb when it is being called from lme? Thanks for any thoughts, Andrew -- Andrew Robinson Department of Mathematics and Statistics
2006 Jul 28
1
order() 'decreasing =' argument must be typed in full
## While in R v. 2.3.1 (the mid-July patch for Windows) ## on a Windows XP machine, this call to order() works fine... order(1:10,decreasing = TRUE) ## [1] 10 9 8 7 6 5 4 3 2 1 ## ...however, the argument name 'decreasing' ## must be typed in toto (note the missing 'g' ## in the following): > order(1:10,decreasin = TRUE) ## Error in order(na.last, decreasing, ...) :
2006 Oct 26
1
A faster way to calculate Trace?
I want to know how to get trace of product of matrices **faster** when the matrices are really big. Unfortunately the matrices are not symmetric. If anybody know how to get the trace of it, please help me. An example is as below. n <- 2500 a <- matrix(rnorm(n*n),n,n) b <- matrix(rnorm(n*n),n,n) tr1 <- sum(diag(a %*% b)) tr2 <- sum(diag(a %*% b %*% a %*% b)) Thanks, Yongwan Chun
2010 Sep 07
4
minor diagonal in R
Dear all, seems that easy question but cannot find the function for that. How to get the elements of the minor diagonal of the matrix? Thanks a lot. [[alternative HTML version deleted]]
2010 Oct 15
1
creating 'all' sum contrasts
OK, my last question didn't get any replies so I am going to try and ask a different way. When I generate contrasts with contr.sum() for a 3 level categorical variable I get the 2 orthogonal contrasts: > contr.sum( c(1,2,3) ) [,1] [,2] 1 1 0 2 0 1 3 -1 -1 This provides the contrasts <1-3> and <2-3> as expected. But I also want it to create <1-2> (i.e.
2010 Oct 29
2
R version 2-12.0 - running as 32 or as 64 bit?
Question: I installed R verison 2-12.0 on my Windows 7 (64 bit) PC. When I was installing it, it did not ask me anything about 32 vs. 64 bit. So, if I run R now - is it running as a 32-bit or a 64-bit? thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2011 Aug 03
1
expand.gird with constraints?
Hi, R users, Here is an example. k <- c(1,2,3,4,5) i <- c(0,1,3,2,1) if k=1, then j=0 from i if k=2, then j=0, 1 from i if k=3, then j=0, 1, 2, 3 from i if k=4, then j=0, 1, 2 from i if k=5, then j=0, 1 from i so i'd like to create a list like below. > list k j 1 1 0 2 2 0 3 2 1 4 3 0 5 3 1 6 3 2 7 3 3 8 4 0 9 4 1 10 4 2 11 5 0 12 5 1 I tried expand.grid, but I
2006 May 20
1
intervals from cut() as numerics?
Hi, Given some example data: dat <- seq(4, 7, by = 0.05) x <- sample(dat, 30) y <- sample(dat, 30) error <- x - y I have broken the rage of x into 10 groups and I can calculate the bias (mean(error)) for each of these 10 groups: groups <- cut(x, breaks = 10) max.bias <- aggregate(error, list(group = groups), mean) max.bias group x 1 (4,4.3] -0.7750000 2
2009 Nov 15
2
Relase positive with log and zero of negative with 0
This is a very simple question but I couldn't form a site search quesry that would return a reasonable result set. Say I have a vector: x <- c(0,2,3,4,5,-1,-2) I want to replace all of the values in 'x' with the log of x. Naturally this runs into problems since some of the values are negative or zero. So how can I replace all of the positive elements of x with the log(x) and the
2005 Nov 29
3
floor()
Dear All, Is this right? > floor((5.05-floor(5))*100) [1] 4 I would expect 5, or am I wrong? Thanks and regards, W --------------------------------- [[alternative HTML version deleted]]