similar to: "[.data.frame" and lapply

Displaying 20 results from an estimated 1000 matches similar to: ""[.data.frame" and lapply"

2009 Feb 27
2
accessing and preserving list names in lapply
Sometimes I'm iterating over a list where names are keys into another data structure, e.g. a related list. Then I can't use lapply as it does [[]] and loses the name. Then I do something like this: do.one <- function(ldf) { # list-dataframe item key <- names(ldf) meat <- ldf[[1]] mydf <- some.df[[key]] # related data structure r.df <-
2008 Nov 20
3
Error with lapply
I have written following codes, with intention to get a list with values 1,2,9,16 : fn <- function(i) return(i^2) lapply(1:4, fn, i) However I got following error : Error in FUN(1:4[[1L]], ...) : unused argument(s) (1) Can anyone please tell me what will be the correct code here? Regards, -- View this message in context: http://www.nabble.com/Error-with-lapply-tp20605066p20605066.html
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
2008 Aug 02
2
lapply, sapply
Hello everybody, I have problem with a lapply command, which rather proves that I don't fully understand it. I want to extract from a list that consists of dataframes, the length of the first sequences from a given variable (its part of a simulation exercises). Below is code which does the job, but I think it should be possible to make it more compact. ### Example Data dat <-list()
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
2009 Apr 14
2
subset dataframe by rows using character vector?
Dear List, I'm stuck on what seems like a simple indexing problem, I'd be very grateful to anyone willing to help me out. I queried a dataframe which returns a character vector called "plot". I have another dataframe from which I want to subset or select only those rows that match "plot". I've tried subset, and also the "which" command. plot
2012 May 18
3
colocar subscripts y cursiva
Hola He estado tratando varias formas de colocar el subíndice para los grados de libertad del F test y la expresión adj; y sencillamente no funciona. legend("topright",legend=c(expression('r[adj]=0.40'),expression('F[3,23]=15.43'),expression('P < 0.001')),col=black, bty='n',cex=0.9) Luego al tratar de colocar las cusriva utilizando par(font=3)
2012 Jun 28
3
Sobre survival analysis
Hola Estoy tratando de correr un survival analysis usando un Cox regression model. Tengo una duda respecto a la organizacion del script. Tengo una variable que es -tamano del individuo- y quiero ver si hay diferencia en sobrevivencia respecto a tamano. Como diseno de campo los tamanos fueron ubicados de forma aleatoria en bloques al azar. Cuado planteo el script tengo algo como:
2009 Apr 16
3
segment between points on different plots
Hi, I need to draw a line segment between two points on different plots in the same multigraph.I've tried looking at the zoominplot function in plotrix but havent understood much.any help is appreciated ~Aks [[alternative HTML version deleted]]
2009 Mar 09
3
How to write a function that accepts unlimited number of input arguments?
Dear R-helpers: I am an R newbie and have a question related to writing functions that accept unlimited number of input arguments. (I tried to peek into functions such as paste and cbind, but failed, I cannot see their codes..) Can someone kindly show me through a summation example? Say, we have input scalar, 1 2 3 4 5 then the ideal function, say sum.test, can do
2007 May 25
2
Interactive plots?
Hi there. I have a matrix that provides place names and the distances between them: Chelt Exeter London Birm Chelt 0 118 96 50 Exeter 118 0 118 163 London 96 118 0 118 Birm 50 163 118 0 After performing multidimensional scaling I get the following points plotted as follows
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
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 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
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 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 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 =
2001 Nov 30
1
passwd chat problem
I could not find any reference to this in the list archive. I am setting up SAMBA on an IRIX system. The passwd command does not say "Password changed" or similar at the end, it just ends. However, if the command fails for any reason (unable to get a lock on the passwd file, for example) it does report that. My problem is that I cannot see any way to get the passwd chat string to
2006 Aug 10
1
help with structuring random factors using lmer()
Hi, I am an R beginner and having problems structuring my REML models. I have a model with y=weight x1=time x2=timesquared id=individual identity I need to structure the model such that in the random effects there is a constant intercept for all individuals but a separate individual slope for both x1 and x2 (a coefficient score for every individual).