Displaying 20 results from an estimated 20000 matches similar to: "How to count number of year per firm in panel data?"
2009 Mar 20
4
how to make aggregation in R ?
Hi,
I am trying to aggregate the sum of my test data.frame as follow:
testDF <- data.frame(v1 = c("a", "a", "a", "a", "a", "b", "b", "b", "b",
"b", "c", "c", "c", "c", "c", "d", "d", "d", "d",
2005 Jun 03
2
rearrange data
Dear all:
I have this:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
And I want this
A1 E1
B1 E1
C1 E1
D1 E1
A2 E2
B2 E2
C2 E2
D2 E2
A3 E3
B3 E3
C3 E3
D3 E3
Example:
m<- matrix(1:15,nrow=3,byrow=T)
m
v<- unlist(list(t(m[,1:4])))
u<- rep(c(5,10,15),c(4,4,4))
data.frame(v,u)
This is the result I want but I would like to learn a simpler way to do it.
Any clue?
2012 Apr 19
3
How to "flatten" a multidimensional array into a dataframe?
Hi,
I have a three dimensional array, e.g.,
my.array = array(0, dim=c(2,3,4), dimnames=list( d1=c("A1","A2"),
d2=c("B1","B2","B3"), d3=c("C1","C2","C3","C4")) )
what I would like to get is then a dataframe:
d1 d2 d3 value
A1 B1 C1 0
A2 B1 C1 0
.
.
.
A2 B3 C4 0
I'm sure there is one function to do
2013 Apr 03
1
linear model coefficients by year and industry, fitted values, residuals, panel data
Hi R-helpers,
My real data is a panel (unbalanced and with gaps in years) of thousands of firms, by year and industry, and with financial information (variables X, Y, Z, for example), the number of firms by year and industry is not always equal, the number of years by industry is not always equal.
#reproducible example
firm1<-sort(rep(1:10,5),decreasing=F)
year1<-rep(2000:2004,10)
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
Hi,
Suppose, if I create 15 files in my working directory.
set.seed(48)
lapply(1:15,function(i) {m1 <- matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)})
?D <-dir()
D1 <- D[order(as.numeric(gsub("\\D+","",D)))]
D1
?res <- t(sapply(D1,function(x) {x1<-
2007 Mar 09
1
Applying some equations over all unique combinations of 4 variables
#I have a data set that looks like this. A bit more
complicated actually with
# three factor levels but these calculations need to
be done on one factor at a
#I then have a set of different rates that are applied
#to it.
#dataset
cata <- c( 1,1,6,1,1,2)
catb <- c( 1,2,3,4,5,6)
doga <- c(3,5,3,6,4, 0)
data1 <- data.frame(cata, catb, doga)
rm(cata,catb,doga)
data1
# start rates
#
2013 Apr 07
4
Same boxplot colors by panels in lattice (bwplot)
Dear all,
I would like to have the same color for the all boxplots from the same
panel, but my code below shows the two colors alternating. Thanks!
set.seed(42)
D1 <- rnorm(200)
D2 <- factor(sample(letters[1:2],200,TRUE))
D3 <- factor(sample(letters[3:5],200,TRUE))
DF <- data.frame(x=D1,a=D2,b=D3)
print(bwplot(b~x|a,data=DF,col=c("black","black"),
2014 Feb 02
5
[LLVMdev] [RFC] BlockFrequency is the wrong metric; we need a new one
Right now, all profile information is funneled through two analysis passes
prior to any part of the optimizer using it.
First, we have BranchProbabilityInfo, which provides a simple interface to
the simplest form of profile information: local and relative branch
probabilities. These merely express the likelihood of taking one of a
mutually exclusive set of exit paths from a basic block. They are
2009 Feb 22
2
how to recover a list structure
I am experiencing some problems at working with lists at high level.
In the following "coef" contains the original DWT coefficients organized in a list.
Thorugh applying the following two commands:
coef.abs <- lapply(unlist(coef,recursive=FALSE,use.names =TRUE),abs)
coef.abs.sorted <- sort(unlist(coef.abs),decreasing=TRUE)
I get vector "coef.abs.sorted" containing
2008 Jun 03
3
How to solve a non-linear system of equations using R
Dear R-list members,
I've had a hard time trying to solve a non-linear system (nls) of equations
which structure for the equation i, i=1,...,4, is as follows:
f_i(d_1,d_2,d_3,d_4)-k_i(l,m,s) = 0 (1)
In the expression above, both f_i and k_i are known functions and l, m and s
are known constants. I would like to estimate the vector d=(d_1,d_2,d_3,d_4)
which is solution
2010 Jul 22
4
Drop firms in unbalanced panel if not more than 5 observations in consecutive years for all variables
Dear R-user,
a few weeks ago I consulted the list-serve with a similar question.
However, my task changed a little but sufficiently to get lost again. So
I would appreciate any help on the following issue.
I use the plm package and work with firm-level data in a panel. I would
like to eliminate all firms that do not fulfill the requirement of
having an observation in every variable used for at
2015 Oct 27
3
pregunta
Estimados
Cuando existia epicalc, había una manera muy fácil de determinar la media de una variable (en esta caso Gain) por grupos, en este caso (Diet). ?Como se puede hacer ahora?
Diet Gain
1 d1 270
2 d1 300
3 d1 280
4 d1 280
5 d1 270
6 d2 290
7 d2 250
8 d2 280
9 d2 290
10 d2 280
11 d3 290
12 d3 340
13 d3 330
14 d3 300
15 d3 300
2017 Oct 30
2
Problems in communication with Mustek PowerMust 1060 LCD
System: Cenots Linux 6.9
Application: nut-2.7.5-0.20170613gitb1314c6 [with usb 0.1 from distro]
Device: Mustek PowerMust 1060 LCD
Comunication log file: dump.txt
We are looking at the possibility of successful communicating with this
device UPS Mustek PowerMust 1060 LCD.
PS: wolfy on the list gives me assistance and i can install any new
compiled nut version from sources.
Thanks,
Catalin.
2019 Apr 02
2
samba 4.10.0 - problem with samba-tool domain provision
Hi,
I am currently installing Samba 4.10.0 on a CentOS7 test system facing problems with the provisioning of AD.
I built samba from source; configure/make/make install finished successfully. When running the "samba-tool domain provision" command I get the following error messages:
[root at geo22 ~]# samba-tool domain provision --use-rfc2307 --interactive
WARNING: Ignoring invalid value
2015 Oct 27
2
pregunta
Otras variantes con y sin paquetes adicionales...
> sapply(split(datIn$Gain, as.factor(datIn$Diet)), mean)
d1 d2 d3
280 278 312
> by(datIn$Gain, datIn$Diet, mean)
datIn$Diet: d1
[1] 280
--------------------------------------------------------------
datIn$Diet: d2
[1] 278
--------------------------------------------------------------
datIn$Diet: d3
[1] 312
>
> library(dplyr)
>
2017 Jun 23
4
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
For certain reason, the content was not visible in the last mail, so posting it again.
Dear Members,
I have two different dataframes with a different number of rows. I need to apply a set of functions to each possible combination of rows with one row coming from 1st dataframe and other from 2nd dataframe. Though I am able to perform this task using for loops, I feel that there must be a more
2005 May 31
2
help
Dear all:
I have this:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
And I want this
A1 E1
B1 E1
C1 E1
D1 E1
A2 E2
B2 E2
C2 E2
D2 E2
A3 E3
B3 E3
C3 E3
D3 E3
Example:
m<- matrix(1:15,nrow=3,byrow=T)
m
v<- unlist(list(t(m[,1:4])))
u<-
2015 Oct 28
2
pregunta
Me gusta la respuesta uqe has dado, pero si por ejemplo, alguno de los datos tiene datos faltantes, entonces devuelve NA.
He probado con:
sapply(split(datos$uno, as.factor(datos$dos)), mean(na.rm=TRUE))
pero da fallo.
¿Cómo se podría hacer para que devolviera además la media obviando los NA y que contara el numero de NA por categoria?
> Date: Wed, 28 Oct 2015 00:13:45 +0100
> From: cof
2006 Apr 12
2
Lattice, panel.grid and groups
Hello,
Given the following plot, which shows following data:
a <- c(8.976000, 8.976000, 8.856000, 8.856000, 8.756000, 8.756000,
8.771000, 8.751000, 8.856000, 8.856000, 16.812000, 16.800000, 8.845000,
9.032000, 8.706000, 9.636000, 9.032000, 16.802000, 8.726000, 8.779000,
8.779000, 8.856000, 8.856000, 8.534000, 8.534000, 8.764000, 8.646000,
8.856000, 8.856000, 13.081000, 10.760000, 8.600000,
2006 Nov 29
2
Dummies multiplied with other variable
Hi,
I would like to estimate something like y = a + b*d2*y + c*d3*y where
the dummies are created from some vector d with three (actually many
more) levels using factor(). But either there is included the variable
y or d1*y. How could I get rid of these?
Example:
x = c(1,2,3,4,5,6,7,8)
y = c(3,6,2,8,7,6,2,4)
d = c(1,1,1,2,3,2,3,3)
fd = factor(d)
lm(x ~ fd*y)
gives:
Coefficients:
(Intercept)