Displaying 6 results from an estimated 6 matches for "somefactor".
2007 Oct 24
3
Partial aggregate on sorted data
Hi All,
I'm looking for ways to compute aggregate statistics (with the aggregate
function) but with an option for sorting and selecting a subset of the data
frame. For example, I have would like to turn this :
aggregate(myDataframe$TargetValue,list(SomeFactor =
myDataframe$SomeFactor),mean)
into something like
aggregate(myDataframe$TargetValue,list(SomeFactor =
myDataframe$SomeFactor),mean, sort=DESCENDING, subset=0.33)
where sort would sort TargetValue per factor level and subset would be (for
example) a value between 0 and 1. The example above wou...
2010 Apr 24
4
assign value between different type: Double vs Integer
Dear list,
just to put it in a simple way:
i read.csv from csv file to create a gdata
then, create array gdata34
however, when making a loop for assigning gdata34[1,m]<-gdata[m,4], this is what happen
gdata[1,4] 's real value is 10354, however, the gdata34[1,4] turns to be 883
then i checked the type: gdata[1,4] is integer, while gdata34[1,4] is double.
Can any one give me some help
2006 Jan 30
3
Date Not Staying in Date Format
I have a column in a data frame that has a class of "Date" and a mode of
"numeric". When I:
max(df$Date)
My output stays in Date format, i.e. "2006-01-03".
However, when I run the following statment:
tapply(df$Date, df$SomeFactor, max)
my output looks like this: 9129 9493 9861 10226 10591 10956 11320
11687 12052 12417
The returned object is of mode "numeric" and class "array". Each array
element is of mode "numeric" and class "numeric". I believe that this is
the in...
2009 May 27
3
Labeling barplot bars by multiple factors
I want to plot quantitative data as a function of three two-level factors.
How do I group the bars on a barplot by level through labeling and spacing?
Here <http://www.thomaslevine.org/sample_multiple-factor_barplot.png>'s what
I'm thinking of. Also, I'm pretty sure that I want a barplot, but there may
be something better.
Tom
[[alternative HTML version deleted]]
2009 Jun 24
1
"by" question
...ng
like:
result <- by(mydata, mydata$some_factor, function (x) {
# do something to create a vector v with length(v) == nrow(x)
return(v)
})
# now result has a big list, argh... how do I put it neatly back into the
mydata data frame?
for (i in unique(mydata$some_factor) {
mydata$newvar[mydata$somefactor ==i] <- result[[i]]
}
What should I be doing instead of this?
David Hugh-Jones
Post-doctoral Researcher
Max Planck Institute of Economics, Jena
http://davidhughjones.googlepages.com
[[alternative HTML version deleted]]
2011 Apr 18
2
Predicting with a principal component regression model: "non-conformable arguments" error
Hello all,
I have generated a principal components regression model using the pcr()
function from the PLS package (R version 2.12.0). I am getting a
"non-conformable arguments" error when I try to use the predict() function
on new data, but only when I try to read in the new data from a separate
file.
More specifically, when my data looks like this
#########training data