Displaying 20 results from an estimated 10000 matches similar to: "bind mean to a df"
2010 Jan 05
5
mean for subset
Hello, does anyone know how to take the mean for a subset of observations?
For example, suppose my data looks like this:
OBS NAME SCORE
1 Tom 92
2 Tom 88
3 Tom 56
4 James 85
5 James 75
6 James 32
7 Dawn 56
8 Dawn 91
9 Clara 95
10 Clara 84
Is there a way to get
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 Apr 02
2
panel data
Hello, I have an unbalanced panel data set that looks like:
ID,YEAR,HEIGHT
Tom,2007,65
Tom,2008,66
Mary,2007,45
Mary,2008,50
Harry,2007,62
Harry,2008,62
James,2007,68
Jack,2007,70
Jordan,2008,72
That is, James, Jack, and Jordan are missing a YEAR.
Is there any command that will "fill in" the missing YEAR such that the end
result will be balanced and look like:
ID,YEAR,HEIGHT
2013 Jan 20
3
strucchange breakpoints r-squared
Can anyone please tell me how to get the r-squared output from a piecewise
(segmented) regression using the strucchange package? Here is the R code I
have tried thus far.
library(lmtest)
library(strucchange)
data <- ts(c(rnorm(30), runif(30)), frequency = 12, start = c(2005, 01))
bpts <- breakpoints(data ~ 1)
print(bpts)
summary(bpts)
coeftest(bpts)
[[alternative HTML version
2010 May 02
3
percent by subset
Suppose my data looks like this:
Obs, Male, Female, Height
1, T, F, 66
2, F, T, 64
3, T, F, 59
4, T, F, 55
5, F, T, 62
6, T, F, 67
7, T, F, 58
8,
2010 Aug 12
1
normality tests
Hello, does anyone know how to compute the following two normality tests
using R:
(1) the Kiefer-Salmon (1983) statistic, Economics Letters 11, p. 123-127
(2) the modified Shapiro-Wilk statistic?
Thank you very much. Geoff
[[alternative HTML version deleted]]
2011 May 23
2
days between dates
Hello, I have some unbalanced panel data that is measured on weekdays only
(i.e., excluding Saturday and Sunday). I would like to get the number of
days between dates such that the number of days between a Friday and a
Monday is 1 (and not 3). Here is some code to illustrate my problem:
library('Hmisc');
DATE <-
2012 May 08
1
grouping function
Hello, I would like to write a function that makes a grouping variable for
some panel data . The grouping variable is made conditional on the begin
year and the end year. Here is the code I have written so far.
name <- c(rep('Frank',5), rep('Tony',5), rep('Edward',5));
begin <- c(seq(1990,1994), seq(1991,1995), seq(1992,1996));
end <- c(seq(1995,1999),
2007 Sep 05
5
RSpec for dummies screencast?
Does anyone know of any RSpec screencasts for dummies, like me :)
I have a Java background, but I have never written a java test in my
life. I''ve never learned about TDD or BDD so I''m totally blank on
everything that has anything to do with testing and stuff.
Where should I start?!? ;)
Christian...
--~--~---------~--~----~------------~-------~--~----~
You received this
2010 Jul 12
2
exercise in frustration: applying a function to subsamples
>From the documentation I have found, it seems that one of the functions from
package plyr, or a combination of functions like split and lapply would
allow me to have a really short R script to analyze all my data (I have
reduced it to a couple hundred thousand records with about half a dozen
records.
I get the same result from ddply and split/lapply:
>
2010 Mar 16
2
Conditional variable assignment
Hi everyone,
Once again I am stuck with a problem I can't seem to figure out. I suppose this learning curve levels off eventually, lol. I am learning on my own with absolutely no background in programming, so if I seem to request help a lot it's not because I am seeking others to do the work for me. I need to assign one of two arrival times to the 'ARRIVE' variable of my
2010 Mar 12
5
Vertical subtraction in dataframes
Hello all,
I have not been able to find an answer to this problem. I feel like it might
be so simple though that it might not get a response.
Suppose I have a dataframe like the one I have copied below (minus the
'calib' column). I wish to create a column like calib where I am subtracting
the 'Count' when 'stain' is 'none' from all other 'Count' data for
2024 Jul 03
1
tab_corr(df[,2:6], p.numeric = TRUE)
En R me sale bien la tabla en R studio no se muestra la tabla , poe favor
ayuda!
library(sjPlot)
tab_corr(df[,2:6], p.numeric = TRUE)
--
saludos
Jose
[[alternative HTML version deleted]]
2009 May 27
4
Sale, pop and product
Hi,
I couldn''t find a better word for pop, but let''s go:
There are 3 models: sale, pop and product
sale:
-total:integer
pop:
-quantity:integer
-discount:float
product:
-name:string
-price:float
A sale can have many different products, each one has a quantity and
discount associated.
So each sale has_many :products through => pops
And each product has_many :sales
2011 May 16
2
conditional rowsums in sapply
Hi all
I have a data frame with duplicate columns and i want to remove duplicates
by adding rows in each group of duplicates, but have lots of NA's.
Data:
dfrm <- data.frame(a = 1:4, b= 1:4, cc= 1:4, dd=1:10, ee=1:4)
names(dfrm) <- c("a", "a", "b", "b", "b")
dfrm[3,2:3]<-NA
dfrm
a a b b b
1 1 1 1 1 1
2 2 2 2 2 2
3
2010 Jul 20
2
Means from selected columns in a data frame
Hi all,
I have a dataframe with survey data. Now I want to calculate means from several but not all columns (e.g. a1, a2, a3) and save them in a new separate column (e.g. a).
Like: a = mean(a1, a2, a3)
Can someone help me or give me the right key word to look for?
Thanks
[[alternative HTML version deleted]]
2011 Jan 31
2
From data frame to list object
Dear all, let say I have following data frame:
> data.frame(x=rnorm(18), y=rep(c("a", "b", "c"), each=6))
x y
1 -1.072152537 a
2 0.382985265 a
3 0.058877377 a
4 -0.006911939 a
5 -2.355269051 a
6 -0.303095553 a
7 0.484038422 b
8 0.733928931 b
9 -1.136014346 b
10 0.503552090 b
11 1.708609658 b
12 -0.294599403 b
13
2004 Sep 11
3
SAS to R migration questions
Hi,
I'd like to get away from SAS, but I don't really know R well enough at
this point to know if it would be good for this project. I tried to
describe the essence of the project below without getting bogged down in
details.
It starts when I receive a data flat file. There's lots of columns, but
the relevant ones are:
custid (customer ID number)
saledt (date of sale)
2011 Jan 31
2
Missing at random
R users:
Thanks in advance
How to generate missing at random (MAR)?
assaedi76@yahoo.com
Thanks
[[alternative HTML version deleted]]
2010 Jul 14
16
For what reason the "official" Wine does not support USB ?
Hello
A lot of windows application need access to an USB port.
For Wine a library (or a patch) exists to manage that but it is not include in the "official" release.
If we want to work with this USB port, we have to compile a personal version of Wine, but this is not really obvious for every body.
Why this feature is not include in the release ?
Do you plan an official release with