Displaying 20 results from an estimated 500 matches similar to: "Samba PDC and User Management with Perl scripts"
2017 Nov 09
1
weighted average grouped by variables
Dear Massimo,
It seems straightforward to use weighted.mean() in a dplyr context
library(dplyr)
mydf %>%
group_by(date_time, type) %>%
summarise(vel = weighted.mean(speed, n_vehicles))
Best regards,
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
FOREST
Team
2017 Nov 09
0
weighted average grouped by variables
Hello
an update about my question: I worked out the following solution (with the package "dplyr")
library(dplyr)
mydf%>%
mutate(speed_vehicles=n_vehicles*mydf$speed) %>%
group_by(date_time,type) %>%
summarise(
sum_n_times_speed=sum(speed_vehicles),
n_vehicles=sum(n_vehicles),
vel=sum(speed_vehicles)/sum(n_vehicles)
)
In fact I was hoping to manage everything in a
2017 Nov 23
1
assign NA to rows by test on multiple columns of a data frame
yes, it works, even if I do not really get how and why it's working the combination of logical results (could you provide some insights for that?)
moreover, and most of all, I was hoping for a compact solution because I need to deal with MANY columns (more than 40) in data frame with the same basic structure as the simplified example I posted
thanks
m
----- Messaggio originale -----
Da:
2017 Nov 22
1
assign NA to rows by test on multiple columns of a data frame
...well, I don't think this is exactly the expected result (see my post)
to be noted that the columns affected should be "A" and "B"
thanks for the help
max
----- Messaggio originale -----
Da: "Rui Barradas" <ruipbarradas at sapo.pt>
A: "Massimo Bressan" <massimo.bressan at arpa.veneto.it>, "r-help" <r-help at
2017 Nov 22
0
assign NA to rows by test on multiple columns of a data frame
Do you mean like this:
mydf <- within(mydf, {
is.na(A)<- !A_flag
is.na(B)<- !B_flag
}
)
> mydf
A A_flag B B_flag
1 8 10 5 12
2 NA 0 6 9
3 10 1 NA 0
4 NA 0 1 5
5 5 2 NA 0
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into
2007 Feb 07
2
Finding not-matching rows in tables
I have these two dataframes in which 'id' is the key field
> tabella
id nome
1 1 PIEMONTE
2 2 VALLED'AOSTA
3 3
LOMBARDIA
4 4 TRENTINO
5 5 VENETO
6 6 FRIULI
AND
> tab
id nome
1 1 PIEMONTE
2 2 VALLED'AOSTA
3 3 LOMBARDIA
4 4 TRENTINO
5 25 CAMPANIA
6 28
LAZIO
Is there any
2017 Nov 09
2
weighted average grouped by variables
Hi
Thanks for working example.
you could use split/ lapply approach, however it is probably not much better than dplyr method.
sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles))
gives you averages
aggregate(mydf$n_vehicles, list(mydf$type), sum)$x
gives you sums
Cheers
Petr
> -----Original Message-----
> From: R-help
2017 Nov 11
0
weighted average grouped by variables
> On 9 Nov 2017, at 14:58, PIKAL Petr <petr.pikal at precheza.cz> wrote:
>
> Hi
>
> Thanks for working example.
>
> you could use split/ lapply approach, however it is probably not much better than dplyr method.
>
> sapply(split(mydf, mydf$type), function(speed, n_vehicles) sum(mydf$speed*mydf$n_vehicles)/sum(mydf$n_vehicles))
> gives you averages
>
The
2018 Apr 20
3
Add Virtlyst to the list of libvirt users
Hi,
I've just released v1.0.0 of Virtlyst[1]
a web tool to manage VMs using Qt/C++/Cutelyst
https://dantti.wordpress.com/2018/04/19/announcing-virtlyst-a-web-interface-to-manage-virtual-machines/
Thanks.
1 - https://github.com/cutelyst/Virtlyst
--
Daniel Nicoletti
KDE Developer - http://dantti.wordpress.com
2003 Dec 10
1
ext3 from whithin W2K
hello everyone,
in the past I used an utility to gain access to my ext3 filesystem from
whithin W2K, I recall that the access was very restricted in terms of modes.
Now I'm looking for that tool (of which I cannot remember the name at all)
or, better, an unlimited one.
Does anyone help me in this seeking without finding? In particular, does
anyone know of a driver which present me the ext3
2007 Feb 19
2
ntlogon.conf
Hey Everyone...
I'm hoping this is an easy one. I am using the ntlogon scripts that
come with the samba examples (ntlogon.py and ntlogon.conf). It's working
fine, except for one thing. I'm trying to set entries up for the groups
"Domain Admins" or other groups with spaces in the name.
The example that comes with it shows ...
[Group-admins]
I tried the following...
2017 Nov 22
0
assign NA to rows by test on multiple columns of a data frame
Hi *Massimo,*
*Try this.*
*a <- mydf==0mydf[a] <- NAHTHEK*
On Wed, Nov 22, 2017 at 5:34 AM, Massimo Bressan <
massimo.bressan at arpa.veneto.it> wrote:
>
>
> Given this data frame (a simplified, essential reproducible example)
>
>
>
>
> A<-c(8,7,10,1,5)
>
> A_flag<-c(10,0,1,0,2)
>
> B<-c(5,6,2,1,0)
>
> B_flag<-c(12,9,0,5,0)
>
2017 Nov 22
1
assign NA to rows by test on multiple columns of a data frame
OPS,
Sorry i did not read the post carfully. Mine will not work if you have
zeros on columns A and B.. But you could modify it to work for specific
columns i believe.
EK
On Wed, Nov 22, 2017 at 8:37 AM, Ek Esawi <esawiek at gmail.com> wrote:
> Hi *Massimo,*
>
> *Try this.*
>
> *a <- mydf==0mydf[a] <- NAHTHEK*
>
> On Wed, Nov 22, 2017 at 5:34 AM, Massimo Bressan
2004 Sep 22
3
loops: pasting indexes in variables names
I cannot figure out how, using R, I can paste indexes or characters to the
variable
names which are used within loops. I will explain this with a simple
example:
Immagine I have a huge series of variables, each one taken two times, say
x1 x2 y1 y2 z1 z2.....
Now, immagine that I want to compute a variable from the difference of
each couple, say dx=x1-x2, dy=y1-y2, dz=z1-z2...
In Stata, for
2004 Feb 05
2
xyplot (lattice): colours of lines
using either one of the following codes:
xyplot(X ~ time | center, type="l", panel=panel.superpose, groups=subject,
col = treatment)
xyplot(X ~ time | center, groups = subject,
panel = function(x, y, ...){
panel.superpose(x, y, col = treatment, type = "l", ...)
})
I get two different colours for the lines by these colours do not match the
corresponding
treatment
2017 Nov 09
1
weighted average grouped by variables
Hello,
Using base R only, the following seems to do what you want.
with(mydf, ave(speed, date_time, type, FUN = weighted.mean, w = n_vehicles))
Hope this helps,
Rui Barradas
Em 09-11-2017 13:16, Massimo Bressan escreveu:
> Hello
>
> an update about my question: I worked out the following solution (with the package "dplyr")
>
> library(dplyr)
>
> mydf%>%
>
2012 May 17
8
[Bug 50043] New: GT240 (nv40) doesn't show anything at boot up, nor X starts
https://bugs.freedesktop.org/show_bug.cgi?id=50043
Bug #: 50043
Summary: GT240 (nv40) doesn't show anything at boot up, nor X
starts
Classification: Unclassified
Product: xorg
Version: unspecified
Platform: x86-64 (AMD64)
OS/Version: Linux (All)
Status: NEW
Severity: blocker
2003 Jan 17
1
Logon Scripts for Mandrake 9.0
<TEXTAREA NAME="Signature" ROWS="4" COLS="60">
I was wondering if some one could help me make some basic
login scripts and tell me where to place them. I know
nothing about them. I am trying to get my windows based
mechines to login to my Mandrake 9.0 server I have windows
ME and XP i got ME to login but XP won't. Can some one
help
Thanks
David
2017 Nov 09
4
weighted average grouped by variables
hi all
I have this dataframe (created as a reproducible example)
mydf<-structure(list(date_time = structure(c(1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000, 1508238000), class = c("POSIXct", "POSIXt"), tzone = ""),
direction = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L), .Label = c("A", "B"), class =
2017 Nov 22
6
assign NA to rows by test on multiple columns of a data frame
Given this data frame (a simplified, essential reproducible example)
A<-c(8,7,10,1,5)
A_flag<-c(10,0,1,0,2)
B<-c(5,6,2,1,0)
B_flag<-c(12,9,0,5,0)
mydf<-data.frame(A, A_flag, B, B_flag)
# this is my initial df
mydf
I want to get to this final situation
i<-which(mydf$A_flag==0)
mydf$A[i]<-NA
ii<-which(mydf$B_flag==0)
mydf$B[ii]<-NA