Displaying 20 results from an estimated 10000 matches similar to: "Bug in by() with dates as levels?"
2008 Nov 13
1
R crashes on sprintf with bad format specification (PR#13283)
Full_Name: Oren Cheyette
Version: 2.7.2
OS: Win XP
Submission from: (NULL) (64.161.123.194)
Enter the following at the R command prompt:
> sprintf("A %S %S %S XYZ", 1, 1, 1);
Note the erroneous capitalized %S instead of %s and the numeric inputs instead
of strings. With strings there's no crash - R reports bad format
specifications.
2009 Jul 21
1
strange dlply behavior
I'm running R 2.9.1 on winXP, using the library plyr.
Can anyone explain to me what is going wrong in this code? (in particular
see lines marked with ******************) Trying to modify objects in a list
created using dlply seems to corrupt the objects in the list.
> library(plyr)
> d=as.data.frame(cbind(c(1,1,1,2,2,2),c(1,2,3,4,5,6)))
> d
V1 V2
1 1 1
2 1 2
3 1 3
4 2 4
5
2013 Aug 27
1
[plyr] Moving average filter with plyr
Dear all,
I'm stuck with a problem using plyr to process a rather large junk of data. What I'm trying to do is applying a moving average to all the subparts of the dataframe (the example data can be found here https://dl.dropboxusercontent.com/u/2414056/testData.Rdata).
require(plyr)
load("testData.Rdata")
applyfilter<-function(x){
return(filter(x,rep(1/5, times=5)))
}
2012 Mar 18
1
Help with dlply, loop and column names
Hi,
I have a dataframe basically like this:
> head(asturias.gen2011[,c(1,4,9:14)])
municipio total upyd psoe pp iu fac tipo
440 Allande 2031 1.44 31.10 39.75 4.01 21.62 1000-10000
443 Aller 12582 1.37 33.30 37.09 15.53 10.35 10000-50000
567 Amieva 805 1.48 32.69 37.36 6.15 20.16 <1000
849
2010 Nov 25
1
Help on running regression by grouping firms
Hi there,
I have a huge data set with multiple firms years and other firm characteristics. I want to run a regression on the dependent variable and other explanatory variables and calculate the residual terms by grouping the firms in same year and same industry.
What I want to do is to divide my obseravtion into sub sample that contains the observation with same fiscal year(FYEAR=1990) and same
2013 Jan 08
2
plot residuals per factor
Dear R-users,
I want to plot residuals vs fitted for multiple groups with ggplot2.
I try this code, but unsuccessful.
library("plyr")
models<-dlply(dat1,"d",function(df)
mod<-lm(y~x,data=df)
ggplot(models,aes(.fitted,.resid), color=factor(d))+
geom_hline(yintercept=0,col="white",size=2)+
geom_point()+
geom_smooth(se=F)
--
---
Catalin-Constantin ROIBU
2011 Oct 25
1
regression using GMM for mulltiple groups
Inthe code below I was trying to to obtain the GMM estimates for CAPM
(REGRESSION) for 36 stocks each have 180 observations,however it only gives
me one output rather than 36.
In SAS i would just put in a *By statement*. I have a variable TICKER that
categorize them into 36 groups.
*How can I obtain all 36 output instead of just one.*
**
2012 Sep 12
6
How to append the random no.s for different variables in the same data.frame
Dear R helpers,
(At the outset I sincerely apologize if I have not put forward my following query properly, though I have tried to do so.)
Following is a curtailed part of my R - code where I am trying to generate say 100 random no.s for each of the products under consideration.
library(plyr)
n = 100
my_code = function(product, output_avg, output_stdev)
{
BUR_mc = rnorm(n, output_avg,
2009 Sep 28
4
Running an ANOVA with a BY
I have a simple 1 way anova coded like
summary(ANOVA1way <- aov(Value ~ WellID, data = welldata))
How can I use the BY function to do this ANOVA for each group using another
variable in the dataset?? I tried coding it like this, but it doesn't seem
to work.
summary(ANOVA1way <- by(welldata, Analyte, function(x) aov(Value ~ WellID,
data = welldata)))
In SAS I would code it like this:
2011 Mar 11
1
Generation of random numbers in a function - (Return command)
Dear R helpers
I have following data.frame and for each product_name, I have associated mean and standard deviation. I need to generate 1000 random no.s for each of these products and find the respective mean and standard deviation.
My R code is as follows.
library(plyr)
library(reshape2)
filtered_new <- data.frame(product_name = c("P1", "P2", "P3",
2011 Feb 08
1
Grouping by factors in R
I'm having a hard time figuring out how to group results by certain
factors in R. I have data with the following headings:
[1] "Time" "Plot" "LatCat" "Elevation" "ElevCat"
"Aspect" "AspCat" "Slope"
[9] "SlopeCat" "Species" "SizeClass" "Stems"
and
2008 Oct 03
1
question on xyplot
Hi List,
I have the following problem: I am using the multilevel package and make.univ function for available in the package and then xyplot from lattice and I want to know how could I be able to use the ?coefficient? for the straight line that passes the data ?
Example from help:
library(multilevel)
data(univbct) #a data set already in univariate or stacked form for job satisfaction
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All
Sorry for this simple question, I could not solve it by spending days.
My data looks like this:
# data
set.seed(1234)
clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100
level for this factor var;
yvar <- rnorm(40, 10,6);
var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2);
var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15,
2008 Nov 14
0
R crashes on sprintf with bad format specification (PR#13285)
* On 2008-11-13 at 18:51 -0500 Duncan Murdoch wrote:
> On 12/11/2008 8:30 PM, ocheyett at bonddesk.com wrote:
>> Full_Name: Oren Cheyette
>> Version: 2.7.2
>> OS: Win XP
>> Submission from: (NULL) (64.161.123.194)
>>
>>
>> Enter the following at the R command prompt:
>>> sprintf("A %S %S %S XYZ", 1, 1, 1);
>>
>> Note the
2011 Nov 03
2
Take variables in data.frame and create list of matrices
Hi,
I have this sample data below and would like to create a list of matricies.
setseed(1254)
id <- c(1,1,1,1 ,2,2,2)
o <- as.factor(c(1:4, 1, 3, 4))
r <- rep(.5, 7)
v <- rnorm(7)
s <- rnorm(7)
dat <-data.frame(id, o, r, v, s)
dat
#> dat
# id o r v s
# 1 1 0.5 0.7024631 2.0813672
# 1 2 0.5 -0.5541955 0.1095156
# 1 3 0.5 -1.0418167 0.4164930
# 1
2012 Aug 28
1
don't print object attributes
Dear all
Suppose the object below:
> require(Hmisc)
> require(plyr)
> x <- dlply(iris, .(Species), describe)
How can I print the object without displaying the attributes? I
inspected ?print and ?print.default with no luck.
> x
$setosa
x[, "Sepal.Length"]
n missing unique Mean .05 .10 .25 .50 .75
50 0 15 5.006 4.40 4.59
2012 Sep 26
1
Change in order of names after applying "plyr" package
Dear R helpers
I have following two data.frames viz. equity_data and param.
equity_data = data.frame(security_id = c("Air", "Air", "Air", "Air", "Air", "Air", "Air", "Air", "Air", "Air", "Air", "Air", "AB", "AB", "AB", "AB",
2011 Mar 11
1
dataframe to a timeseries object
I?m wondering which is the most efficient (time, than memory usage) way to obtain a multivariate time series object from a data frame (the easiest data structure to get data from a database trough RODBC).
I have a starting point using timeSeries or xts library (these libraries can handle time zones), below you can find code to test.
Merging parallelization (cbind) is something I?m thinking at
2011 Apr 04
3
How to speed up grouping time series, help please
I retrieve for a few hundred times a group of time series (10-15 ts
with 10000 values each), on every group I do some calculation, graphs
etc. I wonder if there is a faster method than what presented below to
get an appropriate timeseries object.
Making a query with RODBC for every group I get a data frame like this:
> X
ID DATE VALUE
14 3 2000-01-01 00:00:03 0.5726334
2013 Oct 12
2
Order of factors with facets in ggplot2
Hello,
I'd like to produce a ggplot where the order of factors within facets is
based on the average of another variable.
Here's a reproducible example. My problem is that the factors are ordered
similarly in both facets. I would like to have, within each facet of `f1',
boxplots for 'x' within each factor `f2', where the boxplots are ordered
based on the average of x