similar to: levels values of cut()

Displaying 20 results from an estimated 9000 matches similar to: "levels values of cut()"

2009 Mar 25
2
"[.data.frame" and lapply
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, > d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) > str(d) > > lapply(d, "[", i= c(1)) # fine, this extracts the first columns > lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?! > > library(plyr)
2009 Mar 25
2
"[.data.frame" and lapply
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, > d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) > str(d) > > lapply(d, "[", i= c(1)) # fine, this extracts the first columns > lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?! > > library(plyr)
2008 Nov 09
1
[Rd] Re Bessel functions of complex argument
Dear all, I'm writing a code that requires Bessel functions with complex argument. Searching the list, I found the continuation of a thread I initiated a few months ago: http://tolstoy.newcastle.edu.au/R/e4/devel/08/03/0746.html As I understand, the most promising option would be to use the fortran or C implementation of Amos,
2008 Dec 10
4
tapply within a data.frame: a simpler alternative?
Dear list, I have a data.frame with x, y values and a 3-level factor "group", say. I want to create a new column in this data.frame with the values of y scaled to 1 by group. Perhaps the example below describes it best: > x <- seq(0, 10, len=100) > my.df <- data.frame(x = rep(x, 3), y=c(3*sin(x), 2*cos(x), > cos(2*x)), # note how the y values have a different
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
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
2009 Jan 09
2
recursive relevel
Dear list, I'm having second thoughts after solving a very trivial problem: I want to extend the relevel() function to reorder an arbitrary number of levels of a factor in one go. I could not find a trivial way of using the code obtained by getS3method("relevel","factor"). Instead, I thought of solving the problem in a recursive manner (possibly after reading
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
2008 Apr 03
1
data.frame or list
Dear R list, I'm having difficulties in choosing between a list or a data.frame, or an array for the storage and manipulation of my data (example follows). I've been using the three for different purposes but I would rather like to know which is more adapted to what task. Here is the data I'm currently working on: 200 observations, each observation being a vector of length
2008 Feb 03
1
distances between points in R^3
Dear R helpers, I'm trying to write a numerical scheme for a boundary integral method to solve an electromagnetic problem. This requires the computation of the distance between points at the surface of an object (a sphere, in my example). Here is my code, > require(rgl) > r<-1 > size<-10 > theta<-seq(0,2*pi,length=size*2) > phi<-seq(0,pi,length=size) > pc
2008 Feb 18
2
question on function arguments
Hi, I have two small issues with my R code, no big deal but curiosity really. Here is a sample code, > > x <- rnorm(1:10) > > foo <- function(a = 1, b = list(x = c(1:10), y = c(1:10))){ > > for (ii in seq(along=b$y)){ > > print(x[ii] + b$x[ii]) > } > > > } > > foo() # default OK > > foo(b=list(x=1, y=c(1:10))) # only the first
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 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) > >
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
2009 Jun 25
3
grid.polygon() + color gradient
Hi, I wonder whether there is a way to generate a polygon (a triangle in my case) with color gradient using grid.polygon() in package grid? I tried something like library(grid) grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(col=NA, fill=colorRampPalette(c("green", "lightgray"), space="Lab")(200))) But am only
2009 May 27
3
Axis label spanning multiple plots
Hello I need to plot 3 graphs in a single column; the top two plots have the same title, and I would like it to be written only once, centered horizontally and spanning the two plots. Something like t +------------+ | | i | | | | t +------------+ l +------------+ | | e | | | | 1 +------------+ t
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, >
2009 Jan 14
1
publication statistics from Web of Science
Dear list, This is a bit of an off-topic question, but I'm hoping to get some advice from more experienced people. I've used the website "Web of Science" to manually collect publication counts responding to several keywords as a function of date, since the 1960s. http://apps.isiknowledge.com/RAMore.do?product=UA&search_mode=&SID=P1g9lFJp9 at
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 Aug 07
1
recursive root finding
Dear list, I've had this problem for a while and I'm looking for a more general and robust technique than I've been able to imagine myself. I need to find N (typically N= 3 to 5) zeros in a function that is not a polynomial in a specified interval. The code below illustrates this, by creating a noisy curve with three peaks of different position, magnitude, width and