search for: ba208

Displaying 20 results from an estimated 63 matches for "ba208".

2009 Apr 03
3
plyr and table question
Dear all, I'm puzzled by the following example inspired by a recent question on R-help, cc <- textConnection("user_id website time 20 google 0930 21 yahoo 0935 20 facebook 1000 25 facebook 1015 61 google 0940") d <- read.table(cc, head=T) ; close(cc) table(d$user_id) # count the
2008 Jul 25
3
melting a list: basic question
Dear list, I'm trying to use the reshape package to perform a merging operation on a list of data.frames as illustrated below, > a <- 1:10 > example <- list( data.frame(a=a, b=sin(a)), data.frame(a=a, > b=cos(a)) ) > > melt(example, id = a) this produces the desired result, where the data.frames have been coerced into one with a common identifier variable
2008 May 23
2
[slightly off topic] Sweave with markdown
DeaR list, Has anyone tried to mix the Sweave paradigm with the Markdown[*] (and co.) syntax? Would this be hard to implement? My tiny understanding of Sweave is that one can define new drivers for the text part, while some functions that deal with the R code would not require any modification. Here's the reason I'm interested in Mardown for a driver. I've been orbiting
2008 Jun 18
2
highest eigenvalues of a matrix
DeaR list, I happily use eigen() to compute the eigenvalues and eigenvectors of a fairly large matrix (200x200, say), but it seems over-killed as its rank is limited to typically 2 or 3. I sort of remember being taught that numerical techniques can find iteratively decreasing eigenvalues and corresponding orthogonal eigenvectors, which would provide a nice alternative (once I have the
2007 Jul 20
1
custom point shapes
Hi, I'm new to R, but a search through the list didn't quite solve this problem: I want to draw a few ellipses (or any custom shape for that matter) at given locations in a graph. I know how to plot points from my data, set the point type "pch" to any built in value, but I do not know how to specify a custom shape. A search for drawing ellipses gave me functions to plot
2008 Apr 12
1
lm() of one matrix against another
Hello R list, I have two matrices of identical dimensions, and I want to fit a straight line for each pair of columns and plot the resulting lines. I got it to work with a for loop, but there must be a better way, > n<-5 > N<-10 > > data.x<-matrix(1:(n*N),ncol=n) > data.y<-matrix(1:(n*N) + rnorm(n*N,sd=1),ncol=n) > >
2008 Oct 05
1
plyr package: passing further arguments fail
Dear list and Hadley, The new plyr package seems to provide a clean and consistent way to apply a function on several arguments. However, I don't understand why the following example does not work like the standard mapply, library(plyr) df <- data.frame(a=1:10 , b=1:10) foo1 <- function(a, b, cc=0, d=0){ a + b + cc + d } mdply(df, foo1, cc=1) # fine mdply(df, foo1, d=1) #
2008 Jul 03
1
ggplot2 legend for vertical lines
Dear all, The following example code produces a graph with ggplot2, to which I add several vertical lines of arbitrary colors. I am not satisfied with the legend: it automatically adds some vertical lines which I'd rather not see (they confuse the reader rather than add information in this case). > library(ggplot2) > dfr <- data.frame(values = sin(1:50/10), > fact =
2008 Oct 21
3
R command line
Hi! Is there a Gui for R with improvements in the command line? I'm not looking for buttons, menus and etc, but (more) colored syntax, auto-complete commands and etc? Best regards, Raphael Saldanha saldanha.plangeo@gmail.com [[alternative HTML version deleted]]
2007 Jul 22
3
create an array with rep
Hi, I want to make the following array of numbers: -3 -3 -3 -3 -3 -3 -3 -2 -2 -2 -2 -2 -2 -2 ... 3 3 3 3 3 3 3 -3 -2 -1 0 1 2 3 -3 -2 -1 0 1 2 3 ... -3 -2 -1 0 1 2 3 (3 would be N, a painful example to type number). Here is my dirty attempt to do it, > N<-3 > > x<-c(-N:N) > > rj<-rbind(matrix(outer(matrix(1,1,2*N+1),x),nrow=1),rep(x,2*N+1)) > It
2008 Feb 14
1
write output in a custom format
Hi, I need to create a text file in the following format, > 1 100.0 0 > 0 0 > 1 1 > 0 0 > 1 1 > # > 1 100.0 0 > 0 0 > 0 1 > 1 0 > 1 1 ... where # is part of the format and not a R comment. Each block (delimited by #) consists of a first line with three values, call it dose, and a list of (x,y) coordinates which are a matrix or data.frame, >
2007 Jul 23
1
code optimization tips
Hi, Being new to R I'm asking for some advice on how to optimize the performance of the following piece of code: > alpha_c <- function(lambda=600e-9,alpha_s=1e-14,N=400,spacing=1e-7){ > > k<-2*pi/lambda > ri<-c(0,0) # particle at the origin > x<-c(-N:N) > positions <- function(N) { > reps <- 2*N+1 > matrix(c(rep(-N:N, each = reps), rep(-N:N,
2008 Aug 09
2
levels values of cut()
Dear list, I have the following example, from which I am hoping to retrieve numeric values of the factor levels (that is, without the brackets): > > x <- seq(1, 15, length=100) > y <- sin(x) > > my.cuts <- cut(which(abs(y) < 1e-1), 3) > levels(my.cuts) hist() does not suit me for this, as it does not necessarily respect the number of breaks. getAnywhere
2007 Oct 21
2
image 256 x 920 data points too slow
Dear R gurus, I'm trying to visualize a matrix 256 x 920 using image(), but i find the display too slow (~ 1 minute ?? admittedly, my iBook G4 isn't very fast). The aim is not to get a good resolution image, but rather have a quick look at the matrix. I couldn't find a way to plot a smaller set of points from my data in a sensible manner (basically, i want to decrease the
2008 Aug 07
2
lattice: add vertical lines in xyplot
Hi list, This is a very basic question about lattice: I wish to add some vertical lines in each panel of a xyplot as demonstrated in this example: > library(lattice) > > xx <- seq(1, 10, length=100) > x <- rep(xx, 4) > y <- c(cos(xx), sin(xx), xx, xx^2/10) > fact <- factor(rep(c("cos", "sin", "id", "square"), each=100))
2007 Dec 28
1
unit attribute to list elements
Hi, I've started my own (first) package, part of which consists in listing common physical constants (Planck's constant, the speed of light in vacuum, etc). I'm wondering what would be a good way of dealing with pairs of value/unit. > constants <- list( cel = 2.99792458e8 , #m/s > Z0 = 376.730313461, #ohm > eps0 = 8.854187817e-12,#F/m > mu0 = 4*pi*1e-7,#N/A^2
2008 Dec 02
1
legend idea for latticeExtra
Dear list, I've written a small utility function to add arbitrary legend(s) to a lattice graph (or a combination of them), much like the legend function of base graphics. I though perhaps it could be useful to someone else, or improved by suggestions. I understand this goes against the lattice paradigm somewhat, in that you short-cut the link between group variables and the
2007 Dec 30
1
adding a function after package.skeleton()
Dear R helpers, I've successfully created a package 'constants' using package.skeleton () with one dataframe and a few functions. However, now that I want to add some functions and data to the package, I run into a problem. I ran prompt(...) and moved + edited the resulting .Rd files as appropriate (I believe). The log file from RCMD check constants does indicate a few
2008 Dec 01
2
align two lattice plots with grid
Dear list, I need to align two plots on top of each other for comparison (they only have the x-axis in common). When the y-labels have a different extent, I cannot find a way to align the x-axes, as illustrated below, > library(grid) > library(lattice) > x <- seq(0, 10, length=100) > y <- sin(x) > y2 <- 10*sin(x) > f <- rep(c("1", "2"),
2008 Jun 25
1
expression, strsplit, ...
DeaR list, I'm a bit lost in the behavior of substitute and co. I often use fairly long axis labels in my graphs (long to write, that is). Typically, they would contain some greek letters and units with exponents, as in: > xlab=expression(paste("text ", alpha, " / ", V,".", m^{-3}, ".", > kg^{-2}, ".", l^{4})) To make this a