Displaying 7 results from an estimated 7 matches for "by2".
Did you mean:
by
2013 Mar 15
5
Data manipulation
...ello all,
I would appreciate your thoughts on a seemingly simple problem. I have a
database, where each row represent a single record. I want to aggregate this
database so I use the aggregate command :
D<-read.csv("C:\\Users\\test.csv")
attach(D)
by1<-factor(Class)
by2<-factor(X)
W<-aggregate(x=Count,by=list(by1,by2),FUN="sum")
The results I get following the form:
>W
Group.1 Group.2 x
1 1 0.1 4
2 2 0.1 7
3 3 0.1 1
4 1 0.2 3
5 3 0.2 4
6 3 0.3 4
However, what I...
2004 Aug 15
3
Stacking Vectors/Dataframes
...king/merging two dataframes in R? I want to
stack them piece-wise, not simply add one whole dataframe to the bottom of
the other. I want to create as follows:
x.frame:
aX1 bX1 cX1 ... zX1
aX2 bX2 cX2 ... zX2
... ... ... ... ...
aX99 bX99 cX99 ... zX99
y.frame:
aY1 bY1 cY1 ... zY1
aY2 bY2 cY2 ... zY2
... ... ... ... ...
aY99 bY99 cY99 ... zY99
new.frame:
aX1 bX1 cX1 ... zX1
aY1 bY1 cY1 ... zY1
aX2 bX2 cX2 ... zX2
aY2 bY2 cY2 ... tY2
... ... ... ... ...
aX99 bX99 cX99 ... tX99
aY99 bY99 cY99 ... tY99
I have tried to use a for loop (simply assigning and also with...
2011 Aug 02
1
Need to compute density as done by panel.histogram
...code suggests that the hist.constructor function
(which does not seem to be easily accessible).
Any suggestion for computing the density values of foo$x in the following
example will be welcome.
require(lattice)
set.seed(12345)
foo1 <-
data.frame(x=rnorm(100,0,0.1),grp=1,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo2 <-
data.frame(x=rnorm(100,2,1),grp=2,by=rep(1:2,each=50),by2=rep(1:2,times=50))
foo <- rbind(foo1,foo2)
xplot <- histogram(~x,data=foo, type='density')
PS: the present question relates to a workaround for another problem
previously submitted to the list (...
2014 Mar 19
2
Posible error en la documentación de "aggregate"
Hola compañeros, estaba utilizando la función "aggregate" y quería que
tuviese en cuenta los NAs. He leido la documentación de dicha función y
aparece esto:
# and if you want to treat NAs as a group
fby1 <- factor(by1, exclude = "")
fby2 <- factor(by2, exclude = "")
aggregate(x = testDF, by = list(fby1, fby2), FUN = "mean")
(http://stat.ethz.ch/R-manual/R-patched/library/stats/html/aggregate.html)
Pero el argumento exclude de la función factor, para que tenga en cuenta
NAs (según la documentación de factor,...
2001 Aug 09
1
bug (and fix) in seq.POSIXt (PR#1046)
...nd space only works for
months and years.
The solution (or my solution at any rate) is to change
if (valid <= 5)
by <- c(1, 60, 3600, 86400, 7 * 86400)[valid]
to
if (valid <= 5) {
by <- c(1, 60, 3600, 86400, 7 * 86400)[valid]
if (length(by2) == 2) by <- by * as.integer(by2[1])
}
in the seq.POSIXt code.
Thanks to those who worked to add the DateTimeClasses. I have only
started making use of these recently, but am finding them very useful.
David Middleton
Dr David A. J. Middleton, Stock Assessment Scientist
Fisheries Department...
2007 Sep 27
3
Aggregate factor names
Hi all,
A suggestion derived from discussions amongst a number of R users in
my research group: set the default column names produced by aggregate
() equal to the names of the objects in the list passed to the 'by'
object.
ex. it is annoying to type
with(
my.data
,aggregate(
my.dv
,list(
one.iv = one.iv
,another.iv = another.iv
,yet.another.iv = yet.another.iv
)
2009 Jul 23
0
panel.lmline - are m, b, and r^2 accessible somehow?
...returns invisibly (which makes sense
as one doesn¹t assign panel.abline to a variable) so my guess is the answer
is no.
The only thing I could find in the archives had the calculations done
manually within panel.groups (
http://www.nabble.com/add-trend-line-to-each-group-of-data-in%3A-xyplot(y1%2
By2-~-x-|-grp...-td3344023.html#a3382909) but that was a few versions back.
Other suggestions?
Thanks, Bryan
*************
Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA
[[alternative HTML version deleted]]