>Thanks!
>Why have to add “x” at the end of function, which was what I missed.
You can see for yourself with some tests:
f1 <- function(x) { x[1] <- 10 }
f2 <- function(x) { x[1] <- 10 ; x }
print(f1(1:3)) # 10
print(f2(1:3)) # 10 2 3
An assignment returns the value of its right hand side but
Thanks!
Why have to add “x” at the end of function, which was what I missed.
> On Jun 18, 2018, at 2:53 PM, Bert Gunter wrote:
>
> It depends on whether you wish to refer to the column to be logged by name or
> index.
>
> Reprex:
>
> set.seed(1234)
> dat <- lapply(1:3, function(i)data.frame(
search:
"Default function return R"
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Jun 18, 2018 at 2:58 PM, Honkit Wong wrote:
> Thanks!
> Wh
It depends on whether you wish to refer to the column to be logged by name
or index.
Reprex:
set.seed(1234)
dat <- lapply(1:3, function(i)data.frame(a = runif(5), b =
sample(letters,5)))
## by numerical index of column
d <- lapply(dat,function(x){x[,"logged"]<- log10(x[,1]); x})
## by name of c
Do you want it to run quickly or be quick to write?
Why have you specified that you want a solution that uses lapply? (Such
constraints often arise in the context of homework, whereas someone interested
in getting the job done does not usually care about which function is used.)
On June 18, 201
5 matches
Mail list logo