Displaying 20 results from an estimated 200 matches similar to: "summarise subsets of a vector"
2013 Jan 24
3
From table to data.frame
Hello,
I have a dataframe (test.df) with intervals that were generated by table
(see below). I would prefer a dataframe labeled like this:
> test.tab <- table(cut(skn.test$density, seq (0,1, by=0.05)))
> test.tab
(0,0.05] (0.05,0.1] (0.1,0.15] (0.15,0.2] (0.2,0.25] (0.25,0.3]
(0.3,0.35]
68 87 85 72 65 73
74
(0.35,0.4] (0.4,0.45]
2013 Feb 04
3
Transform every integer to 1 or 0
Hello,
I have a dataframe with positive integers and
for every value > 0
I would like to have 1 and the rest should be zero.
For instance
1 0 1
0 1 1
with df as reference.
> df
V1 V2 V3
yes 23 0 5
no 0 5 7
> dput (df)
structure(list(V1 = c(23, 0), V2 = c(0, 5), V3 = c(5, 7)), .Names = c("V1",
"V2", "V3"), row.names = c("yes",
2013 Jan 31
2
glm poisson and quasipoisson
Hello,
I have a question about modelling via glm. I have a dataset (see dput)
that looks like as if it where poisson distributed (actually I would
appreciate that) but it isnt because mean unequals var.
> mean (x)
[1] 901.7827
> var (x)
[1] 132439.3
Anyway, I tried to model it via poisson and quasipoisson. Actually, just to
get an impression how glm works. But I dont know how to
2009 Mar 15
0
How to summarise several models in a single table
Dear R-helpers,
I have produced several models, named model1, model2, model3, etc...
I would like to extract several elements from each model's object, e.g. at
minimum the estimates, SEs, and P values of each model's intercept and
slopes, model R-squared, and AIC...
...and then produce a new object (a table) that summarises all of my models,
with M\models in rows and extractd model
2004 Apr 06
1
Ignorant lack of bliss : summarise table by column attribute
Having read the list posting guidelines I fear my first post is about to
break the rules. Apologies in advance.
We have been asked to produce some graphs of relative performance of 3
groups of people in relation to the trend of their previous performance.
I am neither a mathematician or a statistician, but wondered if R (which
I have been using as a desktop calculator!) and some knowledge from
2006 May 05
1
trouble with step() and stepAIC() selecting the best model
Hello,
I have some trouble using step() and stepAIC() functions.
I'm predicting recruitment against several factors for different plant
species using a negative binomial glm.
Sometimes, summary(step(model)) or summary(stepAIC(model) does not
select the best model (lowest AIC) but just stops before.
For some species, step() works and stepAIC don't and in others, it's the
opposite.
2017 Sep 09
0
Avoid duplication in dplyr::summarise
Hi Lars
I am not very sure what you really want. However, I am suggesting the
following code that enables (1) to obtain the full summary of your data and
(2) retrieve only mean of X values as function of factors f1 and f2.
library(tidyverse)
library(psych)
df <- data.frame(matrix(rnorm(40), 10, 4),
f1 = gl(3, 10, labels = letters[1:3]),
f2 = gl(3, 10, labels
2017 Sep 09
2
Avoid duplication in dplyr::summarise
Dear group,
Is there a way I could avoid the sort of duplication illustrated below?
i.e., I have the same dplyr::summarise function on different group_by
arguments. So I'd like to create a single summarise function that could be
applied to both. My attempt below fails.
df <- data.frame(matrix(rnorm(40), 10, 4),
f1 = gl(3, 10, labels = letters[1:3]),
f2 =
2017 Sep 09
1
Avoid duplication in dplyr::summarise
Hi Lars,
Two comments:
1. You can achieve what you want with a slight modification of your
definition of s(), using the hint from the error message that you need an
argument '.':
s <- function(.) {
dplyr::summarise(., x1m = mean(X1),
x2m = mean(X2),
x3m = mean(X3),
x4m = mean(X4))
}
2. You have not given a great test case in
2007 Aug 01
1
constrOptim
Hi,
I'm having trouble using the constrOptim function to generate the
9-component vector argmin of the function ELfsds:
ELfsds <- function(pvechat){
LG=0
for(i in 1:9){
LG=LG+log(pvechat[i])
}
return(-LG)
}
with accompanying gradient function:
gradfunc <- function(thetavec){
g=1/(9*thetavec)
return(g)
}
The constraints on the optimization problem are:
1 - components of
2004 Oct 15
1
power in a specific frequency band
Dear R users
I have a really simple question (hoping for a really simple answer :-):
Having estimated the spectral density of a time series "x" (heart rate
data) with:
x.pgram <- spectrum(x,method="pgram")
I would like to compute the power in a specific energy band.
Assuming that frequency(x)=4 (Hz), and that I am interested in the band
between f1 and f2, is the
2006 Dec 30
2
Error: cannot take a sample larger than the population
Hi,
In Splus7 this statement
xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
worked fine, but in R the interpreter reports that the length of the
vector to chose c(0,1,2) is shorter than the size of many times I want
to be selected from the vector c(0,1,2).
Any good reason?
See below the error.
> xlrmN1 <- sample(c(0,1,2),400 ,prob=c(0.02 ,0.93 ,0.05 ))
Error in
2012 Nov 23
2
[LLVMdev] [cfe-dev] costing optimisations
On 23.11.2012, at 15:12, john skaller <skaller at users.sourceforge.net> wrote:
>
> On 23/11/2012, at 5:46 PM, Sean Silva wrote:
>
>> Adding LLVMdev, since this is intimately related to the optimization passes.
>>
>>> I think this is roughly because some function level optimisations are
>>> worse than O(N) in the number of instructions.
>>
2010 Apr 19
2
Overlay of barchart and xyplot
Hello R Folks,
I am new to R. I have been struggling to overlay a barchart with a
xyplot together on one plot but did not get this worked out. Any help
and idea are greatly appreciated.
I attached R scripts for barchart and xyplot below and also data I used.
What I am trying to do is just to put the barchart and xyplot together
on one plot.
Huapeng
<<dispersal_infestation.csv>>
2007 Aug 16
0
summarising systemfit with saveMemory
Hi all -
I'm on R 2.5.1 for XP.
in the systemfit package, the summary is set to print the McElroy's
measure of fit unless it's NULL. When the option saveMemory = TRUE,
the McElroy isn't included, instead it defaults to NA. Thus I am
unable to use summary.systemfit.
> library(systemfit)
> example(systemfit)
> surfit2 <-
2011 Apr 11
1
read in summarised data as table()
I have some summarised data from a 2D pivot table which I want to visualise
in R. How can I read in the data as a R table so I can use mosaicplot()?
Dirk
--
View this message in context: http://r.789695.n4.nabble.com/read-in-summarised-data-as-table-tp3442283p3442283.html
Sent from the R help mailing list archive at Nabble.com.
2009 Jul 28
5
Summarising Data for Forrest Plots
I tried to post this a few times last week and it seems to have got stuck somehow so I'm trying from a different email in the hope that works. If somehow this has appeared on the list 20 tiems and I never saw any of them I apologize ;-)
I'm basically an R-newbie. But I am VERY computer literate. But this has me stumped...
All the examples for using the rmeta package to create a
2008 Sep 11
1
how to calcaulate matrices for two subsets
I am an R beginner and trying to run a market model using event study in
R framework.
First, I run a market model, that is lm(stock security~SP500 index,
subset=Obs[197, 396]) ->result1
Then I get predict results for a new dataset using predict (result1,
newdata=Obs[397,399]) ->pred1
Pred1 should have three numbers.
Now I need to calculate abnormal return by the formula stock
2001 Apr 19
0
All subsets weighted regression in R ?
To everyone,
I am currently doing analysis through Splus but am
having severe problems. I am trying to fit all subset
weighted regression to a multivariate data set and get
PRESS statistics, along with Rsquare, Rsquare adjusted
and Mallows Cp for all possible models. Splus, will
give me these statistics but the leaps procedure is
highly sensitive to nearly singular data matrices
(which mine is)
2011 Sep 30
0
All subsets vector autoregression with exogenous variables
Hi,
I am trying to fit all subsets for a vector autoregression with exogenous
variables. I have been looking at the 'leaps' function but I not sure how
to get it to work when lags for each variable are included in the model. I
would be really appreciative if someone could provide some links to
examples. Thanks in advance!
--
View this message in context: