Displaying 20 results from an estimated 20000 matches similar to: "Data manipulation with aggregate"
2010 Apr 16
4
score counts in an aggregate function
Dear R-Users,
I have a big data set "mydata" with repeated observation and some missing
values. It looks like the format below:
userid sex item score1 score2
1 0 1 1 1
1 0 2 0 1
1 0 3 NA 1
1 0 4 1 0
2 1 1 0 1
2 1 2 NA 1
2 1 3 1
2011 Oct 05
2
aggregate function with a dataframe for both "x" and "by"
I have 2 dataframes. "mydata" contains numerical data. "mybys" contains
information on the "group" each row of the data is in. I wish to aggregate
each column in mydata using the corresponding column in mybys.
Please see the example below. What is a more elegant or "better" way to
accomplish this task?
Thanks!
mydata =
2012 Mar 14
2
aggregate
Dear all I am having a vector with large length and I would like to ask you if I can aggregate the values by constant sized windows. For example for the following vector, I would like to take 30 points until the end
and find their mean.
> myData<-seq(1:100000)
>
> c(mean(myData[1:30]),mean(myData[31:60])) #...and so one until the end
[1] 15.5 45.5
I have searched in the R
2011 Nov 29
2
aggregate syntax for grouped column means
I am calculating the mean of each column grouped by the variable 'id'.
I do this using aggregate, data.table, and plyr. My aggregate results
do not match the other two, and I am trying to figure out what is
incorrect with my syntax. Any suggestions? Thanks.
Here is the data.
myData <- structure(list(var1 = c(31.59, 32.21, 31.78, 31.34, 31.61, 31.61,
30.59, 30.84, 30.98, 30.79, 30.79,
2011 Feb 07
2
Using Aggregate for Date
Hi,
I am trying to find the min of day for each student in each year.
Here is the dataset:
date studentid year
1/1/05 6:07 AM 236 20082009
3/27/09 9:45 AM 236 20082009
4/29/09 8:44 AM 236 20082009
3/27/09 11:36 AM 310 20082009
4/1/09 10:43 AM 310 20082009
10/15/09 8:54 AM 310
2007 Mar 07
5
how to "apply" functions to unbalanced data in long format by factors......cant get "by" or "aggregate" to work
Hello R users,
Problem.......I do not understand how to use "aggregate","by", or the
appropriate "apply" to perform a function on data with more than one
factor on unbalanced data...
I have a data frame in the long format that does not contain balanced
data. The ID is a unique identifier corresponding to the experimental
unit that will later be examined by ANOVA,
2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
Hello!
I am aggregating using a formula in aggregate - of the type:
aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata)
However, I actually have an object (vector of my variables to be aggregated):
myvars<-c("var1","var2","var3")
I'd like my aggregate formula (its "cbind" part) to be able to use my
"myvars" object. Is it
2011 Nov 01
3
Greek letter
Hi everyone.
I'm trying to use small letter phi in a graph produced in R. However, the
small letter phi does not look as it should.
In fact, it looks like this:
http://r.789695.n4.nabble.com/file/n3963311/Untitled.png
instead of what is here http://en.wikipedia.org/wiki/Phi
Here's the code I use:
expression(phi [1])
Anyone has an idea?
With regards,
Phil
--
View this message
2012 Nov 29
2
googleVis plot and knitr/sweave
Dear R users.
I'm currently making a report with knitr (RStudio) where I would like to
plot a googleVis map. However, the map generated is an HTML file which I
don't know how to integrate it in my report.
So my question is how to include a map generated with googleVis in a PDF
created with knitr/sweave.
Regards,
Phil
--
View this message in context:
2006 Dec 28
2
Aggregation using list with Hmisc summarize function
Hi All,
I'm using the Hmisc summarize function and used list instead of llist to
provide the by variables. It generated an error message. Is this a bug,
or do I misunderstand how Hmisc works with lists? The program below
demonstrates the error message.
Thanks,
Bob
x<-1:8
group <- c(1,1,1,1,2,2,2,2)
gender<- c(1,2,1,2,1,2,1,2)
mydata<-data.frame(x,group,gender)
2010 Jan 02
1
xyplot: several plots in one creates y-scale problem
Hello,
I've been looking for a solution to this problem for some time now but
I seem unable to solve it.. so this is the case: I want to plot 4 time
series in the same graph using xyplot(). When I do this with
xyplot(mydata[,2]+mydata[,3]+mydata[,4]+mydata[,5] ~ mydata[,1], data
= mydata,
type = "l",
auto.key = list(space="right", lines = T, points = F),
2012 Jan 01
1
How to pass in a list of variables as an argument to a function?
Hello,
I have some code that currently works fine and I am endeavoring to
convert the major pieces of it into functions.
This involves taking "hard coded" names of variables that are used in
various places and figuring out how to
abstract them out into functions where the arguments (i.e. a list of
variables)?can be passed to the parent function
and used within that function for various
2008 Oct 21
3
code works in R desktop but not iin RWeb - How do I modify to get it working in RWeb, please?
Hi,
How are you? I have a quick question.... I have code that works perfectly
with R desktop, but does not work with RWeb. Could you please tell me how
to modify the code below so it will work with RWeb?
#Read in txt file
happyguys<-read.table("c:/test8.txt", header=TRUE, row.names=1)
#Subset the txt file to only include certain values
test<-subset(happyguys, GRADE == 7
2011 Jan 22
2
meaning of formula in aggregate function
Dear R community
Recently, dear Henrique Dallazuanna literally saved me solving one
problem on data transformation which follows:
(n_, _n, j_, k_ signify numbers)
SOURCE DATA:
id cycle1 cycle2 cycle3 ? cycle_n
1 c c c c
1 m m m m
1 f f f f
2 m m m NA
2
2009 Nov 08
2
Counting non-empty levels of a factor
Hi everyone,
I'm struggling with a little problem for a while, and I'm wondering if
anyone could help...
I have a dataset (from retailing industry) that indicates which brands
are present in a panel of 500 stores,
store , brand
1 , B1
1 , B2
1 , B3
2 , B1
2 , B3
3 , B2
3 , B3
3 , B4
I would like to know how many brands are present in each store,
I tried:
result <-
2010 Oct 06
3
tapply output
Hello, I am having trouble getting the output from the tapply function
formatted so that it can be made into a nice table. Below is my question
written in R code. Does anyone have any suggestions? Thank you. Geoff
#Input the data;
name <- c('Tom', 'Tom', 'Jane', 'Jane', 'Enzo', 'Enzo', 'Mary', 'Mary');
year <- c(2008, 2009,
2010 Jan 29
1
apply function with grouped columns
I have a data set of many rows and many columns in which both the rows and
the columns have associated grouping factors.
Is there a way to do what 'aggregate' does but in the other dimension?
The way I have been doing this is to use 'aggregate' on the data in the
usual way and then rotate the result and apply 'aggregate' again. This
works but is a little messy and I was
2010 Oct 12
6
List or matrix of object
Hi everyone.
Is it possible in R to create a matrix or a list (vector) or R object. For
instance, I have
f1 <- function(x) sqrt(x%*%x);
f2 <- function(x) (2x+1);
I would like to do something like
L <- List();
L[1] = f1;
L[2] = f2;
So, is there a way to create matrix or vector that can contains R object.
With regards,
Phil
--
View this message in context:
2010 Sep 21
2
group means of multi-way table?
hello, can someone tell me how to generate the means for a data frame
that looks like this? My data frame has many more variables, but I
won't bother you with those; these are the one's that I'm interested in.
Needless to say, z is the variable in which I'm interested. I'd like
to find out the mean score of z for NDP managers, Conservative
managers and Liberal managers
2018 May 24
2
Manipulation of data.frame into an array
Hello everyone,
Thank you for this. Nonetheless it is not exactly want i need.
I need mydata[[1]] to provide the values for all 3 variables (Y, X1 and X2) of the first imputation only. As it stands it returns the whole database.
Any ideas?
Best,
ioanna
________________________________
From: Bert Gunter <bgunter.4567 at gmail.com>
Sent: 24 May 2018 16:04
To: Ioanna Ioannou
Cc: