Displaying 20 results from an estimated 30000 matches similar to: "problem with lapply(x, subset, ...) and variable select argument"
2006 Mar 08
3
bug in map('world') ?
hi,
did'nt see anything in the archive:
map('world',pro='rectangular',para=0)
yields a strange artifact (horizontal bar) extending over the whole map
at a certain latitude range (approx 65 deg. north), whereas
map('world',pro='rectangular',para=180)
(which should be the same) does not show the artifact.
the artifact shows up in other projections as well,
2006 Dec 14
3
sapply problem
I have encountered the following problem: I need to extract from
a list of lists equally named compenents who happen to be 'one row'
data frames. a trivial example would be:
a <- list(list(
df = data.frame(A = 1, B = 2, C = 3)), list(df = data.frame(A = 4,B = 5,C = 6)))
I want the extracted compenents to fill up a matrix or data frame row by row.
the obvious thing to do seems:
b
2004 Aug 13
2
bus error /segmentation fault from 'approx' (PR#7166)
Full_Name: joerg van den hoff
Version: 1.9.0 and 1.7.1
OS: MacOS (1.9.0), SunOS (1.7.1)
Submission from: (NULL) (149.220.4.88)
something like (sure not the originally intended input, but something like this
can happen...):
approx(c(1,2),c(NA,NA),1.5)
crashes R (bus error under MacOS, segmentation fault under SunOS).
search of the bug archive did not work. I hope this bug was not reported
2004 Jun 08
2
Is there an R-version of rayplot
I need to make plots similar to those produced by the s-plus rayplot function but can't seem to find it in R. These 'vector maps' plot a ray or vector at each specified location. Is there something similar in R ?
--Rich
Richard Kittler
AMD TDG
408-749-4099
2006 Aug 24
4
extremely slow recursion in R?
I recently coded a recursion algorithm in R and ir ran a few days
without returning any result. So I decided to try a simple case of
computing binomial coefficient using recusrive relationship
choose(n,k) = choose(n-1, k)+choose(n-1,k-1)
I implemented in R and Fortran 90 the same algorithm (code follows).
The R code finishes 31 minutes and the Fortran 90 program finishes in 6
seconds. So the
2006 Jun 29
1
inconsistent matplot behaviour?
I raised this question quite some time ago but it quitly went down the
river. I'll give it a second try (before keeping my modified version of
matplot for ever...):
matplot supports vectors (and/or character strings) for a number of
arguments namely `type', `lty', `lwd', `pch', `col', `cex'. all of them
act consistently in such a way that the first entries are used
2005 Jul 13
1
unexpected par('pin') behaviour
hi everybody,
I noticed the following: in one of my scripts 'layout' is used to
generate a (approx. square) grid of variable dimensions (depending on
no. of input files). if the no. of subplots (grid cells) becomes
moderately large (say > 9) I use a construct like
###layout grid computation and set up occurs here###
...
opar <- par(no.readonly = T);
2004 Aug 16
3
bus error /segmentation fault from 'approx' (PR#7177)
Full_Name: joerg van den hoff
Version: 1.9.1
OS: MacOS and SunOS
Submission from: (NULL) (149.220.4.88)
follow up to ID 7166. something like
approx(c(1,2),c(NA,NA),1.5,rule=2)
crashes 1.9.1 on both systems (MacOS 10.3.5.: bus error, SunOS 5.9:
segmentation fault) even if xout is within given x range (as in example above)
where rule=2 seems not be relevant anyway.
2006 Jun 20
2
$
If object is user defined is:
object$df.residual
the same thing as
df.residual(object)
This is my first time to encounter the $ sign in R, I'm new. I'm
reviewing "summary.glm" and in most cases it looks as though the $ is
used to extract some characteristic/property of the object, but I'm not
positive.
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2012 Jul 03
1
nls problem
hi list,
used versions: 2.12.1 and 2.14.0 under ubuntu and macosx.
I recently stumbled over a problem with `nls', which occurs if the model
is not specified explicitly but via an evaluation of a 'call' object.
simple example:
8<--------------------------------------------------------------------------------------
nlsProblem <- function (len = 5) {
2010 Sep 21
2
lapply version with [ subseting - a suggestion
Dear R developers,
Reviewing my code, I have realized that about 80% of the time in the lapply I
need to access the names of the objects inside the loop.
In such cases I iterate over indexes or names:
lapply(names(x), ... [i]),
lapply(seq_along(x), ... x[[i]] ... names(x)[i] ), or
for(i in seq_along(x)) ...
which is rather inconvenient.
How about an argument to lapply which would specify the
2009 Aug 17
1
how to pass more than one argument to the function called by lapply?
Dear R helpers:
I wonder how to pass more than one argument to the function called by
lapply.
For example,
#R code below ---------------------------
indf <- data.frame(id=I(c('a','b')),y=c(1,10))
#I want to add an addition argument cutoff into the function called by
lapply.
outside.fun <- function(indf, cutoff)
{
unlist(lapply(split(indf, indf[,'id']),
2013 Mar 13
2
holding argument(s) fixed within lapply
|Hello,
Given a function with several arguments, I would like to perform an
lapply (or equivalent) while holding one or more arguments fixed to some
common value, and I would like to do it in as elegant a fashion as
possible, without resorting to wrapping a separate wrapper for the
function if possible. Moreover I would also like it to work in cases
where one or more arguments to the original
2011 Jun 13
4
How to calculate the product of every two elements in two lists?
u<-c(0.1,0.2,0.3)
v<-c(0.2,0.3,0.5)
outer1<-outer(u,u,">=")
outer2<-outer(v,v,">=")
m<-nrow(outer1)
j<-nrow(outer2)
zz<-lapply(1:m, function(m) as.numeric(outer1[m,]))
tt<-lapply(1:m, function(m) as.numeric(outer2[m,]))
zz[[1]]*tt[[3]], e.g., is possible, but I want every products between two
lists.
Is there a way to do that?
--
View this
2004 Oct 06
3
lapply with argument "X"
Hi,
I am probably making a simple mistake but I can't see it
> X
Error: Object "X" not found
> exists("X")
[1] FALSE
> lapply("X", exists)
[[1]]
[1] TRUE
Why is lapply producing true?
Is it something to do with the first
argument of lapply also being called 'X'?
> version
_
platform i386-pc-mingw32
arch i386
2004 Jan 21
2
subset select within a function
Dear all,
I'd like to subset a df within a function, and use select for choosing
the variable. Something like (simplified example):
mydf <- data.frame(a= 0:9, b= 10:19)
ttt <- function(vv) {
tmpdf <- subset(mydf, select= vv)
mean(tmpdf$vv)
}
ttt(mydf$b)
But this is not the correct way. Any help?
Thanks in advance
Juli
2014 Jun 23
1
Curious behavior of $ and lapply
There seems to be a funny interaction between lapply and "$" -- also, "$"
doesn't signal an error in some cases where "[[" does.
The $ operator accepts a string second argument in functional form:
> `$`(list(a=3,b=4),"b")
[1] 4
lapply(list(list(a=3,b=4)),function(x) `$`(x,"b"))
[[1]]
[1] 4
... but using an lapply "..."
2008 Sep 09
2
make methods work in lapply - remove lapply's environment
I've defined my own version of summary.default,
that gives a better summary for highly skewed vectors.
If I call
summary(x)
the method is used.
If I call
summary(data.frame(x))
the method is not used.
I've traced this to lapply; this uses the new method:
lapply(list(x), function(x) summary(x))
and this does not:
lapply(list(x), summary)
If I make a copy of lapply, WITHOUT the
2013 Apr 26
3
converting character matrix to POSIXct matrix
I thought this is a common question but rseek/google searches don't yield
any relevant hit.
I have a matrix of character strings, which are time stamps,
> time.m[1:5,1:5]
[,1] [,2] [,3] [,4] [,5]
[1,] "08:00:20.799" "08:00:20.799" "08:00:20.799" "08:00:20.799"
"08:00:20.799"
[2,]
2017 Nov 15
0
lapply and runif issue?
Hi Bert,
On Tue, Nov 14, 2017 at 8:11 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> Could someone please explain the following? I did check bug reports, but
> did not recognize the issue there. I am reluctant to call it a bug, as it
> is much more likely my misunderstanding. Ergo my request for clarification:
>
> ## As expected:
>
>> lapply(1:3, rnorm, n = 3)