Displaying 19 results from an estimated 19 matches for "setdt".
2018 May 01
4
Merging dataframes
...Sorry - this may be trivial,
but I am struggling here for this.
For two dataframes (A and B), I wish to identify (based on a primary
key-column present in both A & B) -
1. Which records (rows) of A did not match with B, and
2. Which records of B did not match with A ?
I came across a setdt function while browsing, but when I tried it, it says
- Could not find function "setdt".
Overall, if there is any way of doing it (preferably in some simplified
way), please advise.
Many thanks in advance.
regards,
Tito
[[alternative HTML version deleted]]
2018 May 01
0
Merging dataframes
...>
> For two dataframes (A and B), I wish to identify (based on a primary
> key-column present in both A & B) -
>
> 1. Which records (rows) of A did not match with B, and
>
>
>
> 2. Which records of B did not match with A ?
>
>
>
> I came across a setdt function while browsing, but when I tried it, it says
> - Could not find function "setdt".
>
>
>
> Overall, if there is any way of doing it (preferably in some simplified
> way), please advise.
>
>
> Many thanks in advance.
>
>
> regards,
>
&...
2018 May 02
2
Merging dataframes
...d B), I wish to identify (based on a primary
>> key-column present in both A & B) -
>>
>> 1. Which records (rows) of A did not match with B, and
>>
>>
>>
>> 2. Which records of B did not match with A ?
>>
>>
>>
>> I came across a setdt function while browsing, but when I tried it, it
>> says
>> - Could not find function "setdt".
>>
>>
>>
>> Overall, if there is any way of doing it (preferably in some simplified
>> way), please advise.
>>
>>
>> Many thanks in ad...
2018 Jun 25
2
Transformar muchas variables factor en variables binarias de acuerdo a niveles
...stackoverflow.com/questions/33990760/converting-factors-to-binary-in-r
df <-data.frame(a = c(1,2,3), b = c(1,1,2), c =
c("Rose","Pink","Red"), d = c(2,3,4))
cbind(df[1:2], sapply(levels(df$c), function(x) as.integer(x == df$c)), df[4])
o así
library(data.table)
setDT(df)[, c(levels(df$c), "c") :=
c(lapply(levels(c), function(x) as.integer(x == c)), .(NULL))]
Pero no me resuelve el tener que hacerlo algunos cientos de veces, que es
lo que querría evitar. Sé que es evidente cómo se tiene que hacer, pero soy
ciego a esa evidencia :-(
Muchas gracia...
2018 May 02
0
Merging dataframes
...>>> key-column present in both A & B) -
>>>
>>> 1. Which records (rows) of A did not match with B, and
>>>
>>>
>>>
>>> 2. Which records of B did not match with A ?
>>>
>>>
>>>
>>> I came across a setdt function while browsing, but when I tried it, it
>>> says
>>> - Could not find function "setdt".
>>>
>>>
>>>
>>> Overall, if there is any way of doing it (preferably in some simplified
>>> way), please advise.
>>>
>...
2025 Jan 28
2
R CMD check says no visible binding for global variable
Data.frame is returned by SQL query. It does have column names. In the function, I make small changes to some columns.
Something like:
Myquery <- ?SELECT date, price, stock FROM stocktab WHERE stock = ?ABC? AND date > ?2025-01-01?;?
Prices <- dbGetQuery(con, myquery)
SetDT(Prices)
Prices[, date = as.Date(date)]
R CMD check say ?no visible binding for global variable ?date??
Sent from my iPhone
On Jan 28, 2025, at 1:24?AM, Sorkin, John <jsorkin at som.umaryland.edu> wrote:
?
There you go, once again helping strengthen ;)
John
Get Outlook for iOS<https:...
2018 Jun 25
2
Transformar muchas variables factor en variables binarias de acuerdo a niveles
...rame(a = c(1,2,3), b = c(1,1,2), c =
> > c("Rose","Pink","Red"), d = c(2,3,4))
> >
> > cbind(df[1:2], sapply(levels(df$c), function(x) as.integer(x == df$c)),
> > df[4])
> >
> > o así
> >
> > library(data.table)
> > setDT(df)[, c(levels(df$c), "c") :=
> > c(lapply(levels(c), function(x) as.integer(x == c)), .(NULL))]
> >
> >
> > Pero no me resuelve el tener que hacerlo algunos cientos de veces, que es
> > lo que querría evitar. Sé que es evidente cómo se tiene que hacer, p...
2018 May 02
0
Merging dataframes
...am struggling here for this.
>> For two dataframes (A and B), I wish to identify (based on a primary
>> key-column present in both A & B) -
>> 1. Which records (rows) of A did not match with B, and
>> 2. Which records of B did not match with A ?
>> I came across a setdt function while browsing, but when I tried it, it says
>> - Could not find function "setdt".
>> Overall, if there is any way of doing it (preferably in some simplified
>> way), please advise.
>> Many thanks in advance.
>> regards,
>> Tito
>> [...
2024 Dec 12
1
Cores hang when calling mcapply
...`data.frame`. When it detects a `tbl_df`, it tries to redirect to `reshape2::dcast()`, but since that appears to be deprecated, it will fail in future versions at some point.
To avoid this, consider converting?`keeptabs` into a `data.table` directly before calling `dcast()`. For example:
>?setDT(keeptabs)
> out1 <- dcast(keeptabs, ID_Key ~ column1, fun.aggregate = length, value.var = "column1")
> out2 <- dcast(keeptabs, ID_Key ~ column2, fun.aggregate = length, value.var = "column2")
If?`keeptabs` is a `data.table` at the time of calling `dcas...
2024 Dec 12
1
Cores hang when calling mcapply
...t;,"column2")))
}
keeptabs <- bind_rows(keeptabs)
out1 <- dcast(keeptabs, ID_Key ~ column1, fun.aggregate = length, value.var = "column1")
out2 <- dcast(keeptabs, ID_Key ~ column2, fun.aggregate = length, value.var = "column2")
out1 <- setDT(out1 |> rename_with(~ paste0("column1_name_", .x, recycle0 = TRUE), -ID_Key))
out2 <- setDT(out1 |> rename_with(~ paste0("column2_name_", .x, recycle0 = TRUE), -ID_Key))
all_cols <- unique(c(names(out1), names(out2)))
out1_missing <- setdiff(all_cols,...
2018 Jun 25
2
Transformar muchas variables factor en variables binarias de acuerdo a niveles
...; > c("Rose","Pink","Red"), d = c(2,3,4))
> > >
> > > cbind(df[1:2], sapply(levels(df$c), function(x) as.integer(x == df$c)),
> > > df[4])
> > >
> > > o as?
> > >
> > > library(data.table)
> > > setDT(df)[, c(levels(df$c), "c") :=
> > > c(lapply(levels(c), function(x) as.integer(x == c)), .(NULL))]
> > >
> > >
> > > Pero no me resuelve el tener que hacerlo algunos cientos de veces, que
> es
> > > lo que querr?a evitar. S? que es evide...
2024 Sep 22
2
store list objects in data.table
...ses.
My data is organized in a data.table.? My goal is to perform analyses
according to some groups.? The results of analysis are objects.? If
these objects could be stored as elements of a data.table, this would
help downstream summarizing of results.
Let me try another example.
carsdt <- setDT(copy(mtcars))
carsdt[, unique(cyl) |> length()]
#[1] 3
carsreg <- carsdt[, .(fit = lm(mpg ~ disp + hp + wt)), by = .(cyl)]
#I would like a data.table with three rows, one each for "lm" object
corresponding to cyl value
carsreg[, .N]
#[1] 36
#Here each component of "lm&quo...
2025 Jan 28
1
R CMD check says no visible binding for global variable
...urned by SQL query. It does have column names. In the function, I make small changes to some columns.
>
> Something like:
>
> Myquery <- ?SELECT date, price, stock FROM stocktab WHERE stock = ?ABC? AND date > ?2025-01-01?;?
>
> Prices <- dbGetQuery(con, myquery)
> SetDT(Prices)
> Prices[, date = as.Date(date)]
If Prices were a regular dataframe at this point, then the message would
be correct. You can't calculate `as.Date(date)` without telling R where
to look for the `date` variable.
However, you have set it to be a data.table instead. They use
nonst...
2025 Jan 28
1
R CMD check says no visible binding for global variable
...eturned by SQL query. It does have column names. In the function, I make small changes to some columns.
>> Something like:
>> Myquery <- ?SELECT date, price, stock FROM stocktab WHERE stock = ?ABC? AND date > ?2025-01-01?;?
>> Prices <- dbGetQuery(con, myquery)
>> SetDT(Prices)
>> Prices[, date = as.Date(date)]
>
> If Prices were a regular dataframe at this point, then the message would be correct. You can't calculate `as.Date(date)` without telling R where to look for the `date` variable.
>
> However, you have set it to be a data.table ins...
2025 Jan 28
2
R CMD check says no visible binding for global variable
...eturned by SQL query. It does have column names. In the function, I make small changes to some columns.
>> Something like:
>> Myquery <- ?SELECT date, price, stock FROM stocktab WHERE stock = ?ABC? AND date > ?2025-01-01?;?
>> Prices <- dbGetQuery(con, myquery)
>> SetDT(Prices)
>> Prices[, date = as.Date(date)]
>
> If Prices were a regular dataframe at this point, then the message would be correct. You can't calculate `as.Date(date)` without telling R where to look for the `date` variable.
>
> However, you have set it to be a data.table ins...
2024 Sep 22
1
store list objects in data.table
Well, you may have good reasons to do things this way -- and you
certainly do not have to explain them here.
But you might wish to consider using R's poly() function and a basic
nested list structure to do something quite similar that seems much
simpler to me, anyway:
x <- rnorm(20)
df <- data.frame(x = x, y = x + .1*x^2 + rnorm(20, sd = .2))
result <-
with(df,
2024 Dec 11
1
Cores hang when calling mcapply
How is the server configured to handle memory distribution for individual users. I see it has over 700GB of total system memory, but how much can be assigned it each individual user?
AAgain - just curious, and wondering how much memory was assigned to your instance when you were running R.
regards,
Gregg
On Wednesday, December 11th, 2024 at 9:49 AM, Deramus, Thomas Patrick <tderamus at
2025 Jan 28
1
R CMD check says no visible binding for global variable
There you go, once again helping strengthen ;)
John
Get Outlook for iOS<https://aka.ms/o0ukef>
________________________________
From: R-help <r-help-bounces at r-project.org> on behalf of avi.e.gross at gmail.com <avi.e.gross at gmail.com>
Sent: Tuesday, January 28, 2025 12:01:25 AM
To: 'Naresh Gurbuxani' <naresh_gurbuxani at hotmail.com>; r-help at r-project.org
2024 Nov 27
7
R Processing dataframe by group - equivalent to SAS by group processing with a first. and retain statments
I am an old, long time SAS programmer. I need to produce R code that processes a dataframe in a manner that is equivalent to that produced by using a by statement in SAS and an if first.day statement and a retain statement:
I want to take data (olddata) that looks like this
ID Day
1 1
1 1
1 2
1 2
1 3
1 3
1 4
1 4
1 5
1 5
2 5
2 5
2 5
2 6
2 6
2 6
3 10
3 10
and make it look like this:
(withing each