Hi there,
I am attempting to assess whether there is a trend in a
observations of a population that was observed on 7 consecutive days in July
for 6 years (2000, 2001, 2002, 2004, 2006, 2008). I have count data of
the number of observations per day for each of the seven days for each of the 6
ye
I need help with replacing NaN with zero (the value '0') in my dataset.
The reason is that I can't get it to graph because of the NaN in the
dataset. I have tried:
data[is.nan(data)] <- 0
that others have suggested in the help archives but this does nothing so
I am not sure what I am doing wrong.
G. Jay Kerns wrote:
> Dear R-help,
>
> I first thought that the empty set (for a vector) would be NULL.
>
> x <- c()
> x
>
> However, the documentation seems to make clear that there _many_ empty
> sets depending on the vector's mode, namely, numeric(0), character(0),
> logical(0), etc. This is
Hi:
Is there a function that counts the number of days of any given or current year
based on the date?
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
__
R-help@r-project.
I would like to try the Continuous Wavelet Transform to extract the features of
non-linear and non stationary 1D signals.
I can remove the noise and the trend so make them easier to analyze.
I am not sure the CWT will work.
To the purpose of trying it out I have downloaded the Rwave package. To
It looks to me like what I want to do isn't possible. I've been
reading the "R Language Definition" manual more, and have realized
that the "for" function is a .Primitive, not an enclosure. This
means that its arguments are passed by value, so I don't think it is
possible to access them from wit
Hi everyone,
I'm trying to import .sps (SPSS portable file) file.
the read.spss function (library foreign) doesn't allow to import such files.
should I import in spss and then save as sav file? there is not other
solutions available?
what I mostly like from spss file is that they have variable labe
On Mon, Nov 24, 2008 at 11:35:37PM -0800, Kinoko wrote:
> Can somebody tell me how to invoke user-defined functions from script
> files during run-time?
> Basically I have (almost) one function per script file.
>
> I am thinking of something like
>
> #include in C++
> import in Java/Python
Felipe Carrillo wrote:
Hi:
Is there a function that counts the number of days of any given or current year based on the date?
See ?Date and ?strptime and try the following:
y <- as.numeric(format(as.Date("2008-11-25"), "%Y"))
as.numeric(format(as.Date(paste(y, "12", "31", sep="-")), "%j"))
Michael Styer wrote:
I did some more research and I think I've answered my own question.
So my next question is, does anyone have any thoughts about how
significant a project it would be to compile R for 64-bit windows
(using, e.g., the Portland Group compiler)?
How much of the code would ne
See ?help and its argument "offline"
Uwe Ligges
Faheem Mitha wrote:
Hi,
Does anyone know how to print help files from R's prompt?
One can read the help text for read.table by doing
?read.table
on the R prompt. In a similar fashion, can I print the help read.table
without having to res
Philipp,
thanks for the tip.
source("path-to-my-script")
did the trick.
On Nov 25, 5:25 pm, Philipp Pagel <[EMAIL PROTECTED]> wrote:
> On Mon, Nov 24, 2008 at 11:35:37PM -0800, Kinoko wrote:
> > Can somebody tell me how to invoke user-defined functions from script
> > files during run-time?
Spilak,Jacqueline [Edm] wrote:
I need help with replacing NaN with zero (the value '0') in my dataset.
The reason is that I can't get it to graph because of the NaN in the
dataset. I have tried:
data[is.nan(data)] <- 0
Since data is a data.frame and not a matrix, you might want to loop over
Whatever wtd.table is (probably in some package you have not told us
about). The ordinary function table shows 0-frequency, though.
Uwe Ligges
Kunzler, Andreas wrote:
Dear List,
I ran into some problems with weighted observations. I am looking for a frequency table listing the frequencies
Dear Jake,
Have a look at glmer in the lme4 package. The will allow you to model
the trend with repeated measurements.
The easiest way to do some power analysis for repeated measurement will
probably be by simulation.
HTH,
Thierry
--
Erik Porfeli wrote:
Hi,
I am using the following syntax to enter data and perform a cluster analysis:
x <- read.table ("clstrdbt.csv", header=TRUE, sep = ",",fill = TRUE)
cl<-cclust(x,4,20,verbose=TRUE,method="kmeans")
This is the result I receive:
Error in cclust(x, 4, 20, verbose = TRUE,
Hi Livio,
On Monday 24 November 2008 (21:44:45), livio finos wrote:
> Hi everyone,
> I'm trying to import .sps (SPSS portable file) file.
> the read.spss function (library foreign) doesn't allow to import such
> files.
Is this really a 'portable' file (usually these files have the
extension '.por
CE.KA wrote:
Hi R users
I used the function line(x,y) and line(lowess(x,y)) to see the correlation
between 2 variables (x,y).
Here is my question:
is there a way to ask R to tell me the equation of
-this line : line(x,y)
The equation if line(x,y)? It is given by the n data points directly and
Hi Livio,
I think you mixed something up. The .sps - files are the syntax files of
SPSS, and I think there is no automated way (but I would like to be
corrected there) of converting SPSS syntax to R-code. The usual data
files of spss have the extension .sav. Such files can easily read by
read
Dear R Users,
I have a function foo in a script with default values for some of the
parameters as follows:
testparams=list(a=1,b=2,c=3)
foo<-function(x,y,testparams=testparams)
x+y+testparams$a+testparams$b+testparams$c
When I try to run foo(1,2), I get the following error:
> testpara
Dear Ben,
Your questions suite better in R-SIG-Mixed-Models which I am cc'ing.
Have checked the mailing list? Try RSiteSearch("lme4 false convergence")
HTH,
Thierry
ir. Thierry Onkelinx
Instituut voor natuur- en boso
Hi,
I'm developing a C++ software and I would like to connect R (sometimes
on another computer). In my project I'm using a MySQL client with GPL
license and FOSS exception, meaning that I can't use any other GPL
licensed components in the project. It seems that all portable (must
work on Wind
Hello,
I would like to use Concorde from R to solve TSP instances with
solve_TSP(tsp, method="Concorde")
Concorde is installed properly but the result is the following error:
found: concorde.exe
N\Users\jeszy\AppData: No such file or directory
Couldn't open N\U
Dear list,
This is not a question but a rather short note how to save a plot
if it was created in batch mode.
It took me like 2 hours to figure it out, I hope it can save time
for those who - like me - are not really fast in picking up
diosyncrasies of R. (as far as I remember I had no problems wh
Uwe Ligges wrote:
>
>
> CE.KA wrote:
>> Hi R users
>> I used the function line(x,y) and line(lowess(x,y)) to see the
>> correlation
>> between 2 variables (x,y).
>> Here is my question:
>> is there a way to ask R to tell me the equation of
>> -this line : line(x,y)
>
> The equation if line(x,y)?
Hi all,
i am looking from some insights to define own R functions. so far i
found most basics in documentations that are around on the web. except
for one thing:
I´d like to define some function, say:
#assume my data matrix contains vectors like data$myColumn1,data
$myColumn2 etc.
getMy
[EMAIL PROTECTED] wrote:
> Dear R Users,
>
> I have a function foo in a script with default values for some of the
> parameters as follows:
>
> testparams=list(a=1,b=2,c=3)
> foo<-function(x,y,testparams=testparams)
> x+y+testparams$a+testparams$b+testparams$c
>
>
> When I try to run foo(1
Peter Dalgaard wrote:
Uwe Ligges wrote:
CE.KA wrote:
Hi R users
I used the function line(x,y) and line(lowess(x,y)) to see the
correlation
between 2 variables (x,y).
Here is my question:
is there a way to ask R to tell me the equation of
-this line : line(x,y)
The equation if line(x,y)? It
> i am looking from some insights to define own R functions. so far i
> found most basics in documentations that are around on the web. except
> for one thing:
>
> I´d like to define some function, say:
>
> #assume my data matrix contains vectors like data$myColumn1,data
> $myColumn2 etc.
Do
Many thanks Wacek, that is very helpful. Appreciate it.
Regards,
Tolga
Wacek Kusnierczyk <[EMAIL PROTECTED]>
25/11/2008 10:51
To
[EMAIL PROTECTED]
cc
R help <[EMAIL PROTECTED]>
Subject
Re: [R] "recursive default argument" error
[EMAIL PROTECTED] wrote:
> Dear R Users,
>
> I have a funct
Sara,
look carefully at the acf again and increase the lag.
Lags outside the envelope indicate differencing may be necessary.
If the data are "seasonal" you could be seeing a cycle with period 8 -
you'll see alias peaks at 16 and 24; ideally plot the periodiogram which
will show spikes at these fr
If its a date you should ensure its of "Date" class prior to
performing this analysis rather than representing it as something
else. See R News 4/1.
On Tue, Nov 25, 2008 at 2:28 AM, Harsh <[EMAIL PROTECTED]> wrote:
> Thank you Gabor for your prompt reply.
>
> I had tried checking for class, but i
Please do provide the output of sessionInfo(). Without this, any further
advice will be
guesswork. In addition, a few questions:
Are you trying to install the source package?
Are the external dependencies satisfied?
Have you read the package README file - in inst/ in the source?
Which CRAN mi
How can I compute the pearson correlation p-values for all combinations of
columns of 2 matrices ?
> m <- matrix(rnorm(20), nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
> m1 <- matrix(rnorm(20), nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
> cor(m,m1)
a b
Dear R-users,
I'm using lmer to fit two-level logistic models and I'm interested in
predicted probabilities that I get in this way (using "fitted"):
glm1 = lmer(XY$T1~X1 + X2 + X3 + (1|Cind), family=binomial) #estimation of a
two-level logit model
fit1=fitted(glm1) # I get the fitted line
Hi! I'm a new R user and I have a question about estimating VAR on a panel
data. What I'm trying to do is to explain stock's volume on it's lagged
volume, it's lagged returns and lagged market return's (and vice versa). In
addition I have generated an exogenous variable controlling for stock's
vol
I forgot the reshape equivalent for converting from wide to long format. Can
someone help as my matrix is very big. The followin is just an example.
> m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
> m
a b c d e
A 1 5 9 13 17
B 2 6 10 14 18
C 3 7 11 15 19
D 4 8 12
Hello all
I've been using the hclust and as.dendrogram objects for hierarchical
clustering. The problem I have is that my sample set is now so large (circa
500 points) that it isn't possible to view the leaf nodes.
I'd like to be able to zoom in on specific areas of the graph by selecting
a
Try this:
> as.data.frame.table(m)
Var1 Var2 Freq
1 Aa1
2 Ba2
3 Ca3
4 Da4
5 Ab5
6 Bb6
7 Cb7
8 Db8
9 Ac9
10Bc 10
11Cc 11
12Dc 12
13Ad 13
14B
you will get more help if you provide code that can be copied and
pasted into an R session.
?dput
#untested to say the least
foo[unique(foo),]
On Mon, Nov 24, 2008 at 5:36 PM, Rajasekaramya <[EMAIL PROTECTED]> wrote:
>
> hi there
>
> I have a dataframe
>
> abc 123 345
> abc 345 456
> lmn 567 34
#handy if you like ggplot2 as this is required
#I think this is what you want
library(reshape)
m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
melt(m)
On Tue, Nov 25, 2008 at 8:01 AM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> Try this:
>
>> as.data.frame.table(m)
> Var
Dear list:
Before posting this message, I read the posting guide, examined the manuals,
searched the R help files, and examined in detail the books that I have
available on R.
I am using R version 2.8.0 and WinXP.
I want to pause the R Graphics window to permit the use of the File,
Hist
Does this do it for you:
> x <- read.table(textConnection("abc 123 345
+ abc 345 456
+ lmn 567 345
+ hkl 568 535
+ lmn 096 456
+ lmn 768 094"))
>
> x
V1 V2 V3
1 abc 123 345
2 abc 345 456
3 lmn 567 345
4 hkl 568 535
5 lmn 96 456
6 lmn 768 94
> x[!duplicated(x$V1),]
V1 V2 V3
1 abc 123
As yearmon represents year/month as year + fraction of year
adding 1 gives next year. The first output below
gives an answer of class "difftime" whereas the the second
solution is "numeric":
> library(zoo)
> year <- 2000:2010
> d <- as.Date(as.yearmon(year)+1) - as.Date(as.yearmon(year))
> d
Time
Not tested since you did not provide any data:
results <- lapply(split(df, df$id), function(.data){
.which <- which(.data$censor == 1)[1] # get first one
if (length(.which) > 0) return(.data[.which,])
else return(.data[nrow(.data),])
})
On Tue, Nov 25, 2008 at 2:45 AM, gallon li <[EM
Daren Tan wrote:
>
>
> I forgot the reshape equivalent for converting from wide to long format.
> Can someone help as my matrix is very big. The following is just an
> example.
>
>> m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
>
Gabor's solution is uses more basic f
Given the fact that the mailserver appeared to be down for 12 hours
yesterday , I wouldn't be surprised if some major work needed to be
done at ETH. Try again. I do not get the same error message..
--
David Winsemius
Heritage Labs
On Nov 24, 2008, at 1:07 PM, Faheem Mitha wrote:
Hi,
I'm
Does anyone know how to weight cases in a data frame using a frequency
vector?
I'm trying to run tabulations on R , on a data set that first needs to have
weighted cases before i run the tabulations.
In SPSS & SAS its quite simple, but i'm unable to do it in R.
[[alternative HTML version
I am having difficulty thinking that you cannot find general material
by doing a Google search, but can tell you from memory that the US
National Center for Health Statistics publishes on the WWW quite a bit
of information about their survey methods.
For an R-centric answer: Have you looked
sharon Wandia wrote:
> Does anyone know how to weight cases in a data frame using a frequency
> vector?
> I'm trying to run tabulations on R , on a data set that first needs to have
> weighted cases before i run the tabulations.
>
> In SPSS & SAS its quite simple, but i'm unable to do it in R.
x
Jim,
I learned how to use textConnection today
thanks
On Tue, Nov 25, 2008 at 8:17 AM, jim holtman <[EMAIL PROTECTED]> wrote:
> Does this do it for you:
>
>> x <- read.table(textConnection("abc 123 345
> + abc 345 456
> + lmn 567 345
> + hkl 568 535
> + lmn 096 456
> + lmn 768 094"))
>>
>> x
>
David Winsemius wrote:
> I am having difficulty thinking that you cannot find general material by
> doing a Google search, but can tell you from memory that the US National
> Center for Health Statistics publishes on the WWW quite a bit of
> information about their survey methods.
>
> For an R-cen
Not sure that solution properly focuses the unique function on the
first column, and even when I tried to do so, my code using did not
produce what I expected. The unique function does not return a logical
vector.
Try:
ships[!duplicated(ships$type), ]
And Rajasekaramya, please include code
Rainer M Krug gmail.com> writes:
>
> Hi
>
> I want to du a sensitivity analysis using Latin Hypercubes. But my
> parameters have to fulfill two conditions:
>
> 1) ranging from 0 to 1
> 2) have to sum up to 1
>
> So far I am using the lhs package and am doing the following:
>
> library(lhs)
>
Hi all,
I have relatively big data frames (> 1 rows by 80 columns) that need to be
exposed to "merge". Works marvelously well in general, but some fields of the
data frames actually contain multiple ";"-separated values encoded as a
character string without defined order, which makes the fi
Why not write it yourself?
days_in_year <- function(year) {
365 + (year %% 4 == 0) - (year %% 100 == 0) + (year %% 400 == 0)
}
This should work for any year in the Gregorian calendar.
Hadley
On Mon, Nov 24, 2008 at 1:25 PM, Felipe Carrillo
<[EMAIL PROTECTED]> wrote:
> Hi:
> Is there a functio
Didn't this question get asked and answered within a week or two?
Daren Tan, meet John Baron's help search page:
http://search.r-project.org/
( and it apparently gets repeatedly asked and answered over the
years.)
--
David Winsemius
On Nov 25, 2008, at 7:14 AM, Daren Tan wrote:
Dear all,
For an introductory course on glm?s I would like to create an example to show the difference between
glm and transformation of the response. For this, I tried to create a dataset where the variance
increases with the mean (as is the case in many ecological datasets):
poisson
Dear list,
I hope the topic is of sufficient interest, because it is not
R-related. I have N=100 yes/no-responses from a psychophysics
paradigm (say Y Yes and 100-Y No-Responses). I want to see
whether these yes-no-responses are in line with a model
predicting a certain amount p of yes-responses.
On Tue, Nov 25, 2008 at 4:16 PM, Rob Carnell <[EMAIL PROTECTED]> wrote:
> Rainer M Krug gmail.com> writes:
>
>>
>> Hi
>>
>> I want to du a sensitivity analysis using Latin Hypercubes. But my
>> parameters have to fulfill two conditions:
>>
>> 1) ranging from 0 to 1
>> 2) have to sum up to 1
>>
>>
Hi Mark,
similar questions were at least two times during the last weeks, see
http://tolstoy.newcastle.edu.au/R/e5/help/08/11/6722.html
http://tolstoy.newcastle.edu.au/R/e5/help/08/11/6736.html
or
http://tolstoy.newcastle.edu.au/R/e5/help/08/11/7790.html
or search the archives yourself:
htt
Similarly tis and chron have nearly the identical function:
> library(tis)
> 365 + isLeapYear(2000:2010)
[1] 366 365 365 365 366 365 365 365 366 365 365
> isLeapYear
function (y)
y%%4 == 0 & (y%%100 != 0 | y%%400 == 0)
> library(chron)
> 365 + leap.year(2000:2010)
[1] 366 365 365 365 366 365
Hello,
I'm trying to split my DF into a list using incremental loop. How can
I avoid NULL elements in this list?
DF <- data.frame(var1 = 1:10, var2 = 11:20, var3 = 21:30, var4 = 31:40)
x <- list()
i <- 1
while (i <= ncol(DF)-1) {
x[[i]] <- DF[, i:c(i+1)]
i <- i + 2
}
x
Many
Dear R-users,
After adding the secondary y-axis at the right side of a lattice xyplot (cfr.
Lattice: Multivariate Data Visualization with R - figures 8.4 and 8.6, from
http://lmdvr.r-forge.r-project.org/figures/figures.html), I'm trying to add a
title to that second y-axis (which has to be dif
Here's one way
x <- sapply(seq(1,ncol(DF),by=2), function(i) DF[,i:(i+1)], simplify=F)
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Lauri Nikkinen
Sent: Tuesday, November 25, 2008 9:00 AM
To: [EMAIL PROTECTED]
Subject: [R] How to split DF into a list
Hi guys,
I have one problem when I use R+Weka+Xmeans. I set the parameters for Xmeans
as follows:
xc.control <- Weka_control(I=10,M=1000,J=1000,L=1000,H=2000,B=1.0,
C=0.5,D="weka.core.EuclideanDistance",S=20)
xc <- XMeans(data,control=xc.control)
Here I set the L as 1000. according to Xmeans in
On examining non-linearity of Cox coefficients with penalized splines - I
have not been able to dig up a completely clear description of the test
performed in R or S-plus.
>From the Therneau and Grambsch book (2000 - page 126) I gather that the test
reported for "linear" has as its null hypothesi
Hi,
I have more questions about the fft. The application in Excel is very
limited.
In Excel I can adjust graphs and calibrate the x and y-axis. The input and
process, however, is limited compared to R.
With a Dataset table where one column is the hour difference and the second
are the values wi
Dear List,
Does there exist a function that produces a heat map like this one
(image 3 of 4):
http://www.tdameritrade.com/tradingtools/options360.html?a=HDY&referrer=http%3A%2F%2Fquery.nytimes.com%2Fsearch%2Fsitesearch%3Fquery%3Dheatmaptype%3Dnyt
In addition to colors, two other main features I
Your reading of the referenced page is completely different than
mine, ... but IANAL.
In particular:
Q3: Can an open source software project combine and distribute any of
Sun’s GPL-licensed MySQL software with other open source software
under the FOSS License Exception?
A: Open source
I'm not sure on what kind of dataset would be most appropriate, but
following code I used to create a dataset with a linear response and
an increasing variance (the megaphone type, common in ecological
datasets if I'm right) :
beta0 <- 10
beta1 <- 1
x <- c(1:40)
y <- beta0 + x*beta1 +rnorm(40,0,1
Christoph Scherber wrote:
> Dear all,
>
> For an introductory course on glm?s I would like to create an example to
> show the difference between glm and transformation of the response. For
> this, I tried to create a dataset where the variance increases with the
> mean (as is the case in many ecol
Why not just plot all your graphs directly to a file rather than sending them
to a windows device that you are not looking at, then copying from there. The
pdf and postscript devices will hold several plots in a single file, or the png
device (and others) will automatically create 1 file per gr
Dear All,
Currently I'm using the "segmented" package. While using the package,
(i.e segmented - version 0.2-4) to investigate a possible change point
(around X = 2) in my data, I had the following error message:
dat00<-read.table("data.txt",header=T)
library(segmented)
glm.Y<-glm(Y~X,data=dat00)
On Tue, 25 Nov 2008, Uwe Ligges wrote:
See ?help and its argument "offline"
Uwe Ligges
Thanks, that's very helpful. This doesn't exactly print, but saves the
help page to a ps file, which is as good as.
help(write.table, offline=TRUE)
No latex file is available: shall I try to create i
I think your problem is more with indexing than with function writing. The
main confusion is in how to use '$', this is a shortcut to make certain things
easier, but you are trying to use the shortcut like going from France to
Germany by way of New York City because you know a great shortcut th
Dear Peter,
But even if I change things as you suggested, the question still remains the same: why do the glm
models perform so poorly on this dataset? And what would your advice to the students be?
Best wishes
Christoph
# by the way, I disagree on taking logs on the explanatory; the explan
I don't have a good reference for you, but here are a couple of things that you
could try:
1. Do a bootstrap estimation of p by resampling the blocks of 5 (rather than
the individual observations) and see if the hypothesized p is in the confidence
interval.
2. Simulate data using the hypothe
If the reason you want to pause is so that you can save a copy of the graph, or
go back and look at earlier ones, then it may be easiest to just write all the
graphs to a file to start with. Use the pdf device, write all the graphs to
the pdf file, close the file using dev.off, then open the pd
On Tue, Nov 25, 2008 at 9:18 AM, Jacques Wagnor
<[EMAIL PROTECTED]> wrote:
> Dear List,
>
> Does there exist a function that produces a heat map like this one
> (image 3 of 4):
>
> http://www.tdameritrade.com/tradingtools/options360.html?a=HDY&referrer=http%3A%2F%2Fquery.nytimes.com%2Fsearch%2Fsite
what about ?sub and ?ifelse
Spilak,Jacqueline [Edm] wrote:
> I need help with replacing NaN with zero (the value '0') in my dataset.
> The reason is that I can't get it to graph because of the NaN in the
> dataset. I have tried:
> data[is.nan(data)] <- 0
> that others have suggested in the help
I am using density() to plot a density curves. However, one of my variables
is truncated at zero, but has most of its density around zero. I would like
to know how to plot this with the density function.
The problem is that if I do this the regular way density(), values near zero
automatically ge
Try the 'portfolio' package; it has a basic treemap.
On Tue, Nov 25, 2008 at 10:18 AM, Jacques Wagnor
<[EMAIL PROTECTED]> wrote:
> Dear List,
>
> Does there exist a function that produces a heat map like this one
> (image 3 of 4):
>
> http://www.tdameritrade.com/tradingtools/options360.html?a=HDY&
Default kernel density estimation is poorly suited for this sort of
situation.
A better alternative is logspline -- see the eponymous package -- you
can
specify lower limits for the distribution as an option.
url:www.econ.uiuc.edu/~rogerRoger Koenker
email[EMAIL PROTECTED
How about something like:
censor_choose <- function(fr)
do.call(rbind,
lapply( split( fr, fr$id),
function(sub)
sub[which.max( if (max(sub$censor))
sub$censor
else sub$time)
,] ) )
Using your data,
itc <-
data.frame(id=c(1,1,1,2
Hi all
Does anyone know if it is possible when plotting a line or scatter plot, to
selectively color the data points based on the data value? i.e. if plotting say
the percentage change in stock price movements, to color +ve points in green
and -ve points in red? And extending this to a user-def
Given a set of integers of different values how do I calculate the
minimum number of the largest of integers that are required, when
summed, to equal 50% of the total sum of the the set?
For example,
> length(myTable$lgth)
[1] 303403
> sum(myTable$lgth)
[1] 4735396
I know through brute force that
> Given a set of integers of different values how do I calculate the
> minimum number of the largest of integers that are required, when
> summed, to equal 50% of the total sum of the the set?
>
Actually I need the value of the smallest member such that the
sum of all members equal or greater to th
Thank very much ! Indexing is exactly the problem. I think it´s not
because somebody wrote a bad doc, it´s rather because being an amateur
PHP etc scripter i did not realize the power of this indexing yet.
Sometime ago i surely would have used a lot more loops instead of
proper indexing.
Try this:
> tmp <- sample( 100, 50 )
>
> tmp2 <- rev( sort(tmp) )
>
> tmp3 <- cumsum(tmp2) <= sum(tmp)/2
>
> sum(tmp3) # number needed
[1] 14
>
> tmp2[ sum(tmp3) ] # the smallest value
[1] 78
>
> sum(tmp2[tmp3]) / sum(tmp) # check
[1] 0.4894614
> sum(tmp2[ 1:(sum(tmp3)+1) ]) / sum(tmp)
[1] 0.51951
2008/11/25 Jeremy Leipzig <[EMAIL PROTECTED]>:
>> Given a set of integers of different values how do I calculate the
>> minimum number of the largest of integers that are required, when
>> summed, to equal 50% of the total sum of the the set?
>>
> Actually I need the value of the smallest member su
Try this:
tmp <- with(iris, seq( min(Petal.Length)-1, max(Petal.Length)+1, length.out=6))
with( iris, plot( Sepal.Width, Sepal.Length, col=topo.colors(5)[
cut(Petal.Length,tmp) ] ) )
hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECT
Hi,
for example:
today=rnorm(100)
yesterday=rnorm(100)
up=today[today>yesterday]
down=today[todayyesterday)
index.down=which(todaymailto:[EMAIL PROTECTED] Im
Auftrag von [EMAIL PROTECTED]
Gesendet: Tuesday, November 25, 2008 12:35 PM
An: r-help@r-project.org
Betreff: [R] Line color based on data
sorry, you are completely right!
sps is not the extension for portable file! sorry for the time I make you
spend.
I try to make my problem more clear.
I exporting a dataset from limesurvey (a free software for internet survey).
It works very fine and it allow to export in different format such as c
Hi,
This is really strange. Can anyone help explain what's going on here
(on 3 and 7)?
> targets <- seq(from=.1, to=.9, by=.1)
> targets[1]==.1
[1] TRUE
> targets[2]==.2
[1] TRUE
> targets[3]==.3
[1] FALSE
> targets[4]==.4
[1] TRUE
> targets[5]==.5
[1] TRUE
> targets[6]==.6
[1] TRUE
>
Hi All,
Following Mike Praeger's posting on this list,
I'm happy to pass on that AD Model Builder is now freely available from
the ADMB Foundation.
http://admb-foundation.org/
Two areas where AD Model builder would be especially useful to R users
are multi-parmater smooth optimization as in
Dear Jon,
See FAQ 7.31 at
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
HTH,
Jorge
On Tue, Nov 25, 2008 at 1:05 PM, Jon Zadra <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This is really strange. Can anyone help explain what's going on here (on 3
>
On 11/25/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Dear R-users,
>
> After adding the secondary y-axis at the right side of a lattice xyplot
> (cfr. Lattice: Multivariate Data Visualization with R - figures 8.4 and 8.6,
> from http://lmdvr.r-forge.r-project.org/figures/figures.html), I
Greg's solution is most elegant (I think). This is more of an illustrative
approach:
set.seed(1) #to replicate identical sampling if you use this code
x=sample(1:100,replace=T)
x=rev(sort(x)) #reverse order
sum(x)/2 # what is the mean of x: 2613.5
cumsum(x) # the cumulative sums for x=1:i
al
There have been several posts about optimizations where the parameters
for the objective function are bounds-constrained. Brian Ripley took my
1990 "Compact numerical methods for computers" codes and p2c'd them to
give the CG and BFGS and (possibly, I should check!) the Nelder Mead
code. Howeve
1 - 100 of 138 matches
Mail list logo