Displaying 8 results from an estimated 8 matches for "naresh_gurbuxani".
2023 Jan 27
3
implicit loop for nested list
>
> I am looking for a more elegant way to write below code.
>
> #Simulation results have different dimensions
> mysim <- lapply(1:10, function(y) {
> two.mat <- matrix(rnorm(4), nrow = 2)
> four.mat <- matrix(rnorm(16), nrow = 4)
> list(two.mat = two.mat, four.mat = four.mat) #results with different dimensions
> })
>
> #Collect different
2023 Jan 27
1
implicit loop for nested list
...a matrix-list. You can slice this matrix-list
just like normal, then cbind it in one step:
```
two.mat <- do.call("cbind", mysim["two.mat", ])
four.mat <- do.call("cbind", mysim["four.mat", ])
```
On Thu, Jan 26, 2023 at 10:33 PM Naresh Gurbuxani
<naresh_gurbuxani at hotmail.com> wrote:
>
> >
> > I am looking for a more elegant way to write below code.
> >
> > #Simulation results have different dimensions
> > mysim <- lapply(1:10, function(y) {
> > two.mat <- matrix(rnorm(4), nrow = 2)
> > four.mat...
2024 Sep 22
2
store list objects in data.table
...e 2 polynomial
> ## is the same as
> result[[c(2,2)]] ## this is a bit easier for me to groc.
>
> Again, feel free to ignore without replying if my gratuitous remarks
> are unhelpful.
>
> Cheers,
> Bert
>
>
> On Sat, Sep 21, 2024 at 2:25?PM Naresh Gurbuxani
> <naresh_gurbuxani at hotmail.com> wrote:
>> I am trying to store regression objects in a data.table
>>
>> df <- data.frame(x = rnorm(20))
>> df[, "y"] <- with(df, x + 0.1 * x^2 + 0.2 * rnorm(20))
>>
>> mydt <- data.table(mypower = c(1, 2), myreg = list(lm(y ~...
2023 Nov 18
1
combine barchart and xyplot in lattice
On Sat, 18 Nov 2023 at 06:44, Naresh Gurbuxani
<naresh_gurbuxani at hotmail.com> wrote:
>
> In below graph, I would like to add two vertical lines using
> panel.abline(). Is this possible?
I assume you want the 'v' variable in panel.abline() to be interpreted
in the context of your x-axis, which here represents a factor
variable. Unless two...
2024 Sep 22
1
store list objects in data.table
...ple:
result[[2]][[2]] ## the reg component of the degree 2 polynomial
## is the same as
result[[c(2,2)]] ## this is a bit easier for me to groc.
Again, feel free to ignore without replying if my gratuitous remarks
are unhelpful.
Cheers,
Bert
On Sat, Sep 21, 2024 at 2:25?PM Naresh Gurbuxani
<naresh_gurbuxani at hotmail.com> wrote:
>
> I am trying to store regression objects in a data.table
>
> df <- data.frame(x = rnorm(20))
> df[, "y"] <- with(df, x + 0.1 * x^2 + 0.2 * rnorm(20))
>
> mydt <- data.table(mypower = c(1, 2), myreg = list(lm(y ~ x, data = df),
>...
2024 Sep 21
3
store list objects in data.table
I am trying to store regression objects in a data.table
df <- data.frame(x = rnorm(20))
df[, "y"] <- with(df, x + 0.1 * x^2 + 0.2 * rnorm(20))
mydt <- data.table(mypower = c(1, 2), myreg = list(lm(y ~ x, data = df),
lm(y ~ x + I(x^2), data = df)))
mydt
#?? mypower??? myreg
#???? <num>?? <list>
#1:?????? 1 <lm[12]>
#2:?????? 2 <lm[12]>
But mydt[1, 2]
2024 Sep 28
1
lattice xyplot with cumsum() function inside
This code gives unexpected result.
library(data.table)
library(lattice)
set.seed(123)
mydt <- data.table(date = seq.Date(as.IDate("2024-01-01"), by = 1,
length.out = 50), xgroup = "A", x = runif(50, 0, 1))
mydt <- rbindlist(list(mydt, data.table(date = mydt$date, xgroup = "B", x = runif(50, 0, 3))))
mydt[, `:=`(xcumsum = cumsum(x)), by = .(xgroup)]
mydt[,
2023 Nov 18
1
combine barchart and xyplot in lattice
In below graph, I would like to add two vertical lines using
panel.abline(). ?Is this possible?
Thanks,
Naresh
mydf <- data.frame(hour = rep(6:20, 2),
traffic = c(round(dnorm(6:20, 9, 3) * 10000), round(dnorm(6:20, 17, 4) *
10000)),
direction = rep(c("inbound", "outbound"), c(15, 15)))
vehicles <- data.frame(hour = 6:20,
count = c(100, 120, 140, 125, 105, 80, 70, 75,