[R] Spearman's Correlation Coefficient to compare distributions?

2010-07-29 Thread Ralf B
Hi,

I have distributions from two different data sets and I would like to
measure how similar their distributions (in terms of their bin
frequencies) are. In other words, I am not interested in the exact
sequence of data points but rather in the their distributional
properties and in their similarities.
Spearman's Correlation Coefficient is used to compare data without the
assumption of normality. I wonder if this measure can also be used to
compare distributional data rather than the data poitns that are
summarized in a distribution. Here the example code that exemplifies
what I would like to check:

aNorm <- rnorm(100)
bNorm <- rnorm(100)
cUni <- runif(100)
ha <- hist(aNorm)
hb <- hist(bNorm)
hc <- hist(cUni)
print(ha$counts)
print(hb$counts)
print(hc$counts)
# relatively similar
n <- min(c(NROW(ha$counts),NROW(hb$counts)))
cor.test(ha$counts[1:n], hb$counts[1:n], method="spearman")
# quite different
n <- min(c(NROW(ha$counts),NROW(hc$counts)))
cor.test(ha$counts[1:n], hc$counts[1:n], method="spearman")

Does this make sense or am I violating some assumptions of the coefficient?

Thanks,
R.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] New Open Source Community

2010-07-29 Thread CJN

Equalis just announced it's public beta today 

http://www.equalis.com http://www.equalis.com .  

It has forums dedicated to lots of math topics including open source
software.  It specifically has an R forum and an R user group.  Also has
forums and groups for Octave, Scilab, and Sage.
http://www.equalis.com/forums/ http://www.equalis.com/forums/ 
http://www.equalis.com/members/group.asp?id=66492
http://www.equalis.com/members/group.asp?id=66492 

Check it out - registration is free.  We can use it as a resource to promote
R and help each other.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/New-Open-Source-Community-tp2306058p2306058.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] precision of minus operation and if statments

2010-07-29 Thread yoni gavish
Hi Everyone, 
as part of a larger script, I need to insert the result of a simple minus 
operation into an if statement. 

I have noticed that the precision that appear on the screen is not the 
precision 
in which R stores the result of the minus operation, and that this change 
alters 
the result of the if statement. For example, when running this simple script:

 
> a=0.90
> b=0.95
> c=b-a
> e=paste(c)
> if(c==0.05) d=12

I get:

> c
[1] 0.05
> d
Error: object 'd' not found
> e
[1] "0.0499"

Although I have solved it by changing the command for c to:
> c=round((b-a),15)

I do not understand the source of this mistake and how it can be avoided in the 
future

Many thanks and sorry for this very basic question...


 Yoni Gavish 


Department of Life Sciences,


Ben-Gurion University of the Negev,


POB 653, Beer Sheva, 84105


ISRAEL


Tel: 972-77-6450238 (home), 972-50-9930553 (mobile) 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] xlsx [path input]

2010-07-29 Thread nero

Good morning ,

i want to read in a file with the xlsx package...
the documentation says, that i could define the desired destination with an
absolute path.

the argument 'file' in the function-call should be: quote :
"file->the absolute path to the file which the data are to be read from"
(http://cran.r-project.org/web/packages/xlsx/xlsx.pdf ; pagina 14)

But it doesn´t work. It only works, if i put the file into the
xlsx-directory and set a dynamic path.
a short example:

http://r.789695.n4.nabble.com/file/n2306056/example_loading_xls.png 

But the file is there...
Am i missing something?

Thanks in advance.
Best regards,
Nero

-- 
View this message in context: 
http://r.789695.n4.nabble.com/xlsx-path-input-tp2306056p2306056.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Multiple binomial tests on a large table

2010-07-29 Thread Wilson, Andrew
I need to run binomial tests (binom.test) on a large set of data, stored
in a table - 600 tests in total.

The values of x are stored in a column, as are the values of n.  The
data for each test are on a separate row.

For example:

X   N
11  19
9   26
13  21
13  27
18  30

It is a two-tailed test, and P in all cases is 0.5.

My question is:  Is there a quicker way of running these tests without
having to type an individual command for each test - and ideally also to
store the resulting p-values in a single data vector?

Many thanks for any pointers,

Andrew Wilson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] precision of minus operation and if statments

2010-07-29 Thread ONKELINX, Thierry
This is FAQ 7.31: 
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
  

> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens yoni gavish
> Verzonden: donderdag 29 juli 2010 8:23
> Aan: r-help@r-project.org
> Onderwerp: [R] precision of minus operation and if statments
> 
> Hi Everyone,
> as part of a larger script, I need to insert the result of a 
> simple minus operation into an if statement. 
> 
> I have noticed that the precision that appear on the screen 
> is not the precision in which R stores the result of the 
> minus operation, and that this change alters the result of 
> the if statement. For example, when running this simple script:
> 
>  
> > a=0.90
> > b=0.95
> > c=b-a
> > e=paste(c)
> > if(c==0.05) d=12
> 
> I get:
> 
> > c
> [1] 0.05
> > d
> Error: object 'd' not found
> > e
> [1] "0.0499"
> 
> Although I have solved it by changing the command for c to:
> > c=round((b-a),15)
> 
> I do not understand the source of this mistake and how it can 
> be avoided in the 
> future
> 
> Many thanks and sorry for this very basic question...
> 
> 
>  Yoni Gavish 
> 
> 
> Department of Life Sciences,
> 
> 
> Ben-Gurion University of the Negev,
> 
> 
> POB 653, Beer Sheva, 84105
> 
> 
> ISRAEL
> 
> 
> Tel: 972-77-6450238 (home), 972-50-9930553 (mobile) 
> 
> 
>   
>   [[alternative HTML version deleted]]
> 
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Statistical mailing list

2010-07-29 Thread Liviu Andronic
On Wed, 28 Jul 2010 22:36:08 -0400
Ralf B  wrote:
> I am looking for a mailing list for general statistical questions that
> are not R related. Do you have any suggestions for lists that are busy
> and helpful and/or lists that you use and recommend?
> 
Maybe StackExchange [1]? 
Liviu

[1] http://robjhyndman.com/researchtips/stats-stackexchange/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Adding lines to two graphs alternately

2010-07-29 Thread Jim Lemon

On 07/29/2010 07:02 AM, Dennis Fisher wrote:

Colleagues

I do a series of calculations, then add some output as a line in a graphic.  
This is repeated a large number of times.  Then, I move to the next panel and 
do a similar set of calculations, add lines, 

Many of the calculations are identical for the two panels, so the calculations 
are done twice.  In order to avoid this redundancy, it would be ideal to do the 
following:
1.  Set up the two panels (i.e., draw the axes for each
2.  Do the calculations for the first iteration for both panels.  Draw 
the line in each panel.  Then move to the second iteration.
In other words, I am trying to add to both two panels in an alternating manner 
-- do some calculations, add a line to panel 1, then add a line to panel 2, 
then do more calculations.


Hi Dennis,
You are probably looking for split.screen. You can specify the layout:

split.screen(c(1,2))

make a plot on each screen:
plot(1:5)
screen(2)
plot(5:1)

swap back and forth to add lines

screen(1,FALSE)
lines(c(2,5,4,3,1))
screen(2,FALSE)
lines(c(1,2,5,2,3))

and so on.

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Displaying Counts of Unused Factors in Contingency Tables with table()

2010-07-29 Thread Dennis Murphy
Hi,

table() is behaving as documented with respect to your example. local.labels
is a *character* vector with two distinct values and local.preds is a
*character* variable with one distinct value. If you were expecting your
table to divine that you wanted to include 'ah~' as a missing value in your
local.preds object, it's not going to happen under your current setup.

> local.labels <- c("ah", "ah", "ah~")
> local.preds <- c("ah", "ah", "ah")
> table(local.labels, local.preds)
local.preds
local.labels ah
 ah   2
 ah~  1
> class(local.labels)
[1] "character"
> class(local.preds)
[1] "character"


Is this what you had in mind?

labels <- factor(local.labels)
preds <- factor(local.preds, levels = c('ah', 'ah~'))
> table(labels, preds)
  preds
labels ah ah~
   ah   2   0
   ah~  1   0

> labels
[1] ah  ah  ah~
Levels: ah ah~
> preds
[1] ah ah ah
Levels: ah ah~

There is a distinction in R between character objects and factor objects.
More generally, many [generic] functions behave differently depending on the
type of object(s) supplied as input.

HTH,
Dennis

On Wed, Jul 28, 2010 at 10:29 PM, Na'im R. Tyson wrote:

> R-philes,
>
> I have a question about displaying counts of unused factors using the
> table() function.  I have two vectors with character data in them:
>
> local.labels("ah", "ah", "ah~")
> local.preds("ah", "ah", "ah")
>
> If I use the table function as shown below, I get an error because the
> number of levels do not match up.
>
> v.cont.table <- table(local.labels, local.preds, dnn=c("observed",
> "predicted"));
>
> Is there any way to get zero counts into the contingency table, or would I
> have to use a flat table?  Any help with sample code, or a pointer to a
> previous post, would be much appreciated.
>
> Regards,
>
> Na'im
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Different decimal places in a matrix

2010-07-29 Thread Nicola Sturaro Sommacal
Hi!

I have a ftable object in which some row contains integers and some other
contains a percentage that I would like to show with two digits after the
dot.

I tried something like ftblP[index,] = as.character(round(ftblP[index, ],
2)) where the index vector contains the number of the rows containing a
percentage. My workaround works but it shows all numbers aligned to left,
while I prefer that number will be aligned "correctly" (to the right).

It is possible?

Thanks in advance.

Nicola S.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different decimal places in a matrix

2010-07-29 Thread Ted Harding
On 29-Jul-10 09:08:22, Nicola Sturaro Sommacal wrote:
> Hi!
> I have a ftable object in which some row contains integers and
> some other contains a percentage that I would like to show with
> two digits after the dot.
> 
> I tried something like
> ftblP[index,] = as.character(round(ftblP[index,],2))
> where the index vector contains the number of the rows containing a
> percentage. My workaround works but it shows all numbers aligned to
> left, while I prefer that number will be aligned "correctly" (to
> the right).
> 
> It is possible?
> 
> Thanks in advance.
> Nicola S.

Interesting question! I take it you want to see something like

  49  21 166
  12.216.75   49.65

The "raw" approach I would suggest is to "pack" the integers
on the right with 3 blanks. I think it should be possible to
do this with sprintf(). using different 'fmt' specifications
for the "integer" rows and the "percentage" rows, and using
cat() to output the results. However, I don't have time right
now to explore the details of how it might be done. Sorry.

Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 29-Jul-10   Time: 10:25:33
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] xlsx [path input]

2010-07-29 Thread Stefan Grosse
Am 29.07.2010 09:24, schrieb nero:

> But it doesn´t work. It only works, if i put the file into the
> xlsx-directory and set a dynamic path.
> a short example:
> 
> http://r.789695.n4.nabble.com/file/n2306056/example_loading_xls.png 
> 
> But the file is there...
> Am i missing something?

Lukas,
You have probably misspecified your path. Maybe it is better to use setwd:

setwd("c:/Users/[INSERT YOUR USERNAME]/Documents")
# our your path with desktop, make sure the file is there
# you could check with dir()
library(xlsx)
read.xlsx("test.xlsx",1)

  A B C
1 1 3 5
2 2 4 6


hth
Stefan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multiple binomial tests on a large table

2010-07-29 Thread Dennis Murphy
Hi:

Here's one approach (not unique), and dragged out a bit to illustrate its
different components.

1. Create a list object, something like
   l <- vector('list', 600)
2. Populate it. There are several ways to do this, but one is to initially
create a vector of file names and then populate the list by looping over the
file names. If your file names have a simple format (dat001 - dat600, say),
then it's easy to create the file name vector with paste(); otherwise, you
may need to do more work. Then run a loop that assigns to each list
component the corresponding data frame, something like

for(i in seq_along(filenames)) l[[i]] <- get(filenames[i])

3. Create a function for one of the data sets, under the obvious proviso
that you intend to process each data frame in the list the same way. To
return only the p-values from a binomial test applied to each row of your
input data frame, the following works for me (explanation below):

f <- function(df)
  do.call(c, with(df, mapply(binom.test, x = X, n = N))[3, ])

4. Use lapply() to map the function to each component data frame in your
list; the result will also be a list.
 pvlist <- lapply(l, f)

5. *IF* each of your data frames has the same number of rows, you can use
the following to slurp together all the p-values into a matrix:

do.call(rbind, pvlist)

OTOH, if the number of rows vary from one data frame to another, it may be
best to keep the p-value results in list form or perhaps you could flatten
them into a numeric vector, depending on your purposes.


The function f:

 mapply() allows you, in this case, to execute the non-vectorized function
binom.test() to a pair of vector arguments supplied from the input data
frame. The result is a 9 x n matrix where each column comprises a list of
output for each of the n calls to binom.test() [where n = number of rows of
the input data frame]. Since you wanted the p-values (component/row 3), we
pull out the third row of the matrix. This will return a list, so using the
concatenation function c() in do.call() coerces them into a numeric vector
for output.

The lapply() call maps the function f to each component of the list of data
frames created in (2).
-

An alternative approach to this problem would be to use the plyr (and
perhaps reshape, too) package, since it was designed to handle this
'split-apply-combine' strategy.

HTH,
Dennis

On Thu, Jul 29, 2010 at 1:05 AM, Wilson, Andrew wrote:

> I need to run binomial tests (binom.test) on a large set of data, stored
> in a table - 600 tests in total.
>
> The values of x are stored in a column, as are the values of n.  The
> data for each test are on a separate row.
>
> For example:
>
> X   N
> 11  19
> 9   26
> 13  21
> 13  27
> 18  30
>
> It is a two-tailed test, and P in all cases is 0.5.
>
> My question is:  Is there a quicker way of running these tests without
> having to type an individual command for each test - and ideally also to
> store the resulting p-values in a single data vector?
>
> Many thanks for any pointers,
>
> Andrew Wilson
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] where did the column names go to?

2010-07-29 Thread pdb

I've just tried to merge 2 data sets thinking they would only keep the common
columns, but noticed the column count was not adding up. I've then
replicated a simple example and got the same thing happening.

q1. why doesn't 'b' have a column name?

q2. when I merge, why does the new column 'y' have all values as 5.1?

Thanks in advance,

Mr. confused
 

> a <- iris[,]
> b <- iris[,1]
> 
> head(a)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1  5.1 3.5  1.4 0.2  setosa
2  4.9 3.0  1.4 0.2  setosa
3  4.7 3.2  1.3 0.2  setosa
4  4.6 3.1  1.5 0.2  setosa
5  5.0 3.6  1.4 0.2  setosa
6  5.4 3.9  1.7 0.4  setosa
> head(b)
[1] 5.1 4.9 4.7 4.6 5.0 5.4
> 
> c <-merge(a,b)
> head(c)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species   y
1  5.1 3.5  1.4 0.2  setosa 5.1
2  4.9 3.0  1.4 0.2  setosa 5.1
3  4.7 3.2  1.3 0.2  setosa 5.1
4  4.6 3.1  1.5 0.2  setosa 5.1
5  5.0 3.6  1.4 0.2  setosa 5.1
6  5.4 3.9  1.7 0.4  setosa 5.1
> 
> NCOL(a)
[1] 5
> NCOL(b)
[1] 1
> NCOL(c)
[1] 6
> 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/where-did-the-column-names-go-to-tp2306267p2306267.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Multiple binomial tests on a large table

2010-07-29 Thread Dennis Murphy
Hi:

As it turns out, this is pretty straightforward using plyr's ldply()
function. Here's a toy example:

d1 <- structure(list(X = c(11L, 9L, 13L, 13L, 18L), N = c(19L, 26L,
21L, 27L, 30L)), .Names = c("X", "N"), class = "data.frame", row.names =
c(NA,
-5L))
w <- sample(1:50, 5)
d2 <- data.frame(X = mapply(rbinom, 1, w, 0.5), N = w)
w <- sample(1:50, 5)
d3 <- data.frame(X = mapply(rbinom, 1, w, 0.5), N = w)

# Combine data frames into a list - since these are already R objects, the
call is easy:
l <- list(d1, d2, d3)

# the function:
f <- function(df)
  do.call(c, with(df, mapply(binom.test, x = X, n = N))[3, ])

# do.call + lapply:
do.call(rbind, lapply(l, f))
  [,1]  [,2]   [,3]  [,4]  [,5]
[1,] 0.6476059 0.1686375 0.38331032 1.000 0.3615946
[2,] 0.3019956 0.6515878 0.02944937 0.5600646 1.000
[3,] 1.000 1.000 0.81452942 0.0390625 0.4050322

# plyr approach:
library(plyr)
ldply(l, f)
 V1V2 V3V4V5
1 0.6476059 0.1686375 0.38331032 1.000 0.3615946
2 0.3019956 0.6515878 0.02944937 0.5600646 1.000
3 1.000 1.000 0.81452942 0.0390625 0.4050322

ldply() takes a list as input along with a function to process in the
lapply() step and returns a data frame of results. So the plyr approach can
be summarized as:

1. Create a list of data frames.
2. Create a function to apply to each data frame.
3. Load the plyr package.
4. Run ldply().

Essentially, the plyr package provides a number of convenient 'wrapper'
functions to simplify the 'split-apply-combine' strategy of data analysis
for various combinations of input and output objects.

HTH,
Dennis


On Thu, Jul 29, 2010 at 1:05 AM, Wilson, Andrew wrote:

> I need to run binomial tests (binom.test) on a large set of data, stored
> in a table - 600 tests in total.
>
> The values of x are stored in a column, as are the values of n.  The
> data for each test are on a separate row.
>
> For example:
>
> X   N
> 11  19
> 9   26
> 13  21
> 13  27
> 18  30
>
> It is a two-tailed test, and P in all cases is 0.5.
>
> My question is:  Is there a quicker way of running these tests without
> having to type an individual command for each test - and ideally also to
> store the resulting p-values in a single data vector?
>
> Many thanks for any pointers,
>
> Andrew Wilson
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] where did the column names go to?

2010-07-29 Thread Dennis Murphy
Hi:

On Thu, Jul 29, 2010 at 3:28 AM, pdb  wrote:

>
> I've just tried to merge 2 data sets thinking they would only keep the
> common
> columns, but noticed the column count was not adding up. I've then
> replicated a simple example and got the same thing happening.
>
> q1. why doesn't 'b' have a column name?
>
> q2. when I merge, why does the new column 'y' have all values as 5.1?
>
> Thanks in advance,
>
> Mr. confused
>
>
> > a <- iris[,]
> > b <- iris[,1]
>

b is not a data frame - since it is only one column, by default it is
coerced into a numeric vector:

> class(b)
[1] "numeric"
> b
  [1] 5.1 4.9 4.7 4.6 5.0 5.4 ...

The way to keep b a data frame is to use the argument drop = FALSE, as in
> b2 <- iris[, 1, drop = FALSE]# b2 is now a data frame
> dd <- merge(iris, b2)
> head(dd)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1  4.3 3.0  1.1 0.1  setosa
2  4.4 2.9  1.4 0.2  setosa
3  4.4 2.9  1.4 0.2  setosa
4  4.4 2.9  1.4 0.2  setosa
5  4.4 3.0  1.3 0.2  setosa
6  4.4 3.0  1.3 0.2  setosa

HTH,
Dennis

>
> > head(a)
>  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> 1  5.1 3.5  1.4 0.2  setosa
> 2  4.9 3.0  1.4 0.2  setosa
> 3  4.7 3.2  1.3 0.2  setosa
> 4  4.6 3.1  1.5 0.2  setosa
> 5  5.0 3.6  1.4 0.2  setosa
> 6  5.4 3.9  1.7 0.4  setosa
> > head(b)
> [1] 5.1 4.9 4.7 4.6 5.0 5.4
> >
> > c <-merge(a,b)
> > head(c)
>  Sepal.Length Sepal.Width Petal.Length Petal.Width Species   y
> 1  5.1 3.5  1.4 0.2  setosa 5.1
> 2  4.9 3.0  1.4 0.2  setosa 5.1
> 3  4.7 3.2  1.3 0.2  setosa 5.1
> 4  4.6 3.1  1.5 0.2  setosa 5.1
> 5  5.0 3.6  1.4 0.2  setosa 5.1
> 6  5.4 3.9  1.7 0.4  setosa 5.1
> >
> > NCOL(a)
> [1] 5
> > NCOL(b)
> [1] 1
> > NCOL(c)
> [1] 6
> >
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/where-did-the-column-names-go-to-tp2306267p2306267.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to 'stack' data frames?

2010-07-29 Thread pdb

I have 2 data frames (A & B) with some common column names.

A has 10 rows.
B has 20 rows.

How do I combine them so I end up with a data frame with 30 rows that only
contains the common columns.

I was trying 'merge' (Merge two data frames by common columns .etc. )
but that is not giving me what I expect...

> a <- iris
> b <- iris
> 
> c <-merge(a,b)
> 
> NROW(a)
[1] 150
> NROW(c)
[1] 152

Why is there only 152 rows and not 300?



-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-stack-data-frames-tp2306284p2306284.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Reading timestamp column from MySQL

2010-07-29 Thread Allan Engelhardt



On 29/07/10 00:20, harsh yadav wrote:

Hi,

I am reading a SQL (MySQL) table in R data frame.

When I read in the table that has a timestamp data-type field, R gives it
the following format:-

1.236887e+12

So when I want to manipulate a column with timestamp = 1236887146615

It returns me multiple rows, as many timestamps gets converted to same
value: 1.236887e+12

Any ideas of how this could be dealt with, so that I can get the entire
timestamp field.
   


It should just be a printing issue, not a problem with the data, in 
which case you can just run you analysis as usual.  If it *is* an issue 
with the data, and not the printing, then we probably need more 
information, see the posting guide.


If you are worried about the formatting, look at options("scipen"); try 
a value of 5 or so to get you started.



[*Off topic*:
why does
options("scipen" = 2^31-13); print(1236887146615);
produce different output [1] from
options("scipen" = 2^31-12); print(1236887146615);
and why does the rather intuitive approach suggested by one of my 
colleagues,

options("scipen" = +Inf); print(1236887146615);
produce warnings (and why does warnings() then produce even more 
warnings, ad infinitum)? ]


Hope this helps,


Allan

[1] at least under trunk and also 2.11.1

> sessionInfo()
R version 2.12.0 Under development (unstable) (2010-07-28 r52631)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] ctv_0.6-0

loaded via a namespace (and not attached):
[1] tools_2.12.0

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] I need the dataset--thank you

2010-07-29 Thread 笑啸
dear:

I am a user of R project.And now ,I have a problem.

I want to know what is the name of the datasets in the web page--"Draw a 
Nomogram Representing a Regression Fit" which come from the 
R-home(http://www.r-project.org/   Package rms version 3.0-0).

And can you supply the dataset to me?

wish for your help,thank you!


truly yours


   2010-07-29__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to 'stack' data frames?

2010-07-29 Thread Dennis Murphy
Hi:

Here's a *reproducible* example:

> a <- data.frame(w = rnorm(10), x = rnorm(10), y = rnorm(10), z =
rnorm(10))
> b <- data.frame(w = rnorm(20), x = rnorm(20), x2 = rnorm(20), x3 =
rnorm(20))
> commonCols <- intersect(names(a), names(b))
> commonCols
[1] "w" "x"
> rbind(a[commonCols], b[commonCols])

HTH,
Dennis

On Thu, Jul 29, 2010 at 3:53 AM, pdb  wrote:

>
> I have 2 data frames (A & B) with some common column names.
>
> A has 10 rows.
> B has 20 rows.
>
> How do I combine them so I end up with a data frame with 30 rows that only
> contains the common columns.
>
> I was trying 'merge' (Merge two data frames by common columns .etc. )
> but that is not giving me what I expect...
>
> > a <- iris
> > b <- iris
> >
> > c <-merge(a,b)
> >
> > NROW(a)
> [1] 150
> > NROW(c)
> [1] 152
>
> Why is there only 152 rows and not 300?
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-stack-data-frames-tp2306284p2306284.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Sweaving quotes

2010-07-29 Thread Murray Jorgensen

I am happy enough with

options(useFancyQuotes = FALSE)

(or = "TeX") but I will test Brian's suggestion tomorrow and report back.

Murray

Prof Brian Ripley wrote:
The alternative is to tell LaTeX what encoding the file is in.  For 
those using UTF-8 locales this means adding the line


\usepackage[utf8]{inputenc}

Now Murray mentions 'Vista', and so is presumably using cp1252 (the 
Western-European-language Windows default).  That is spported by 
inputenc, so try


\usepackage[cp1252]{inputenc}

In either case, the LaTeX font used may or may not have directional 
quotes -- since this is an issue for the R manuals, see our 
documentation for ways around this (such as package ae).


On Wed, 28 Jul 2010, Marc Schwartz wrote:


On Jul 28, 2010, at 7:43 PM, Murray Jorgensen wrote:

The significance code line to summary() applied to an lm() fitted 
model object is


Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

The corresponding line in the LaTeX source produced by Sweave is

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

which looks the same in my email (Thunderbird on a Vista machine), 
but when I look at the file in WinEdt the quotes appear rounded and 
cursive.


On LaTeXing and dvipsing the opening and closing quotes turn into 
S-acute and S-circumflex respectively.


Does anyone know how avoid this effect?

Cheers,  Murray



Murray,

Try this:


summary(lm.D9)


...

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

...


# Set to not use fancy quotes, but "TeX" style
# See ?options and ?sQuote
options(useFancyQuotes = "TeX")




summary(lm.D9)


...

Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

...


HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.






--
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: m...@waikato.ac.nzmajorgen...@ihug.co.nz  Fax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441   Mobile 021 0200 8350

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Function to return variable name

2010-07-29 Thread Allan Engelhardt

On 29/07/10 04:21, Jeremy Miles wrote:

I'd like a function that returns the variable name.

As in:

MyData$Var1

Would return:

Var1
   


Not quite sure what you mean, but does this get you started?

nn <- function(x) deparse(substitute(x))
str( z <- nn(airquality$Month) )
#  chr "airquality$Month"
## Not sure what now - maybe:
strsplit(z, "$", fixed = TRUE)[[1]][-1]
# [1] "Month"

You'll have to figure out with a variable called foo$bar$baz and with 
airquality["Month"] etc.


Hope this helps a little.

Allan

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to 'stack' data frames?

2010-07-29 Thread Gabor Grothendieck
On Thu, Jul 29, 2010 at 6:53 AM, pdb  wrote:
>
> I have 2 data frames (A & B) with some common column names.
>
> A has 10 rows.
> B has 20 rows.
>
> How do I combine them so I end up with a data frame with 30 rows that only
> contains the common columns.
>
> I was trying 'merge' (Merge two data frames by common columns .etc. )
> but that is not giving me what I expect...
>
>> a <- iris
>> b <- iris
>>
>> c <-merge(a,b)
>>
>> NROW(a)
> [1] 150
>> NROW(c)
> [1] 152
>
> Why is there only 152 rows and not 300?
>

Because rows 102 and 143 are the same:

> iris[c(102, 143),]
Sepal.Length Sepal.Width Petal.Length Petal.Width   Species
102  5.8 2.7  5.1 1.9 virginica
143  5.8 2.7  5.1 1.9 virginica

so row 102 gets joined to both 102 and 143 and row 143 gets joined to
both 102 and 143 and all other rows get joined to themselves giving 2
+ 2 + 148 = 152 rows.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to 'stack' data frames?

2010-07-29 Thread pdb

Thanks Dennis - easy when you know how !

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-stack-data-frames-tp2306284p2306309.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Replace last element in a vector - elegant solution?

2010-07-29 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi

I have to replace the last element of a vector with 0, but the length of
x is not known at coding time. So I do the following:

x <- 1:10
x

x[length(x)] <- 0
x

it is working nicely, but I am wondering: is there a more elegant
solution( like tail(x, 1) <- 0 , which does not work)?

Thanks,

Rainer
- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Tel:+33 - (0)9 53 10 27 44
Cell:   +27 - (0)8 39 47 90 42
Fax (SA):   +27 - (0)8 65 16 27 82
Fax (D) :   +49 - (0)3 21 21 25 22 44
Fax (FR):   +33 - (0)9 58 10 27 44
email:  rai...@krugs.de

Skype:  RMkrug
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxRYh0ACgkQoYgNqgF2ego4iQCePSFCnWMPuY1eD2fyXUUXGRmF
PXgAnjIDIB0EnODWv4HuYjwgU3SJW01x
=JVQu
-END PGP SIGNATURE-

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ...more values follow?

2010-07-29 Thread Uwe Ligges

See ?options and its argument "max.print".

Uwe Ligges

On 28.07.2010 09:50, nero wrote:


Hello!

I´m playing arround with rJava...
Always when i want to print(list), it only shows me the first values, and
then (900534 more values follow)...

How can i get shure, that all list-values are printed?
what i´m doing wrong?



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Detecting seasonality

2010-07-29 Thread vikrant

I have a hourly time series and I am interested in finding presence of
seasonality in this data. I know one method of finding seasonality using
autocorrelation function(ACF). But I dont want to use any graphical
technique. I want to know is there any theorotical method using R which can
be helpful ? Also the method should give  period of seasonality.

Thanks, 
Vikrant
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Detecting-seasonality-tp2306292p2306292.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] newton.method

2010-07-29 Thread sammyny

Hi,
Is this method broken in R? I am using it to find roots of the following
function:
f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100

It is giving an answer of -38.4762403 which is not even close (f(x) =
2.903809e+25 for x=-38.4762403). The answer should be around 0.01-0.1. This
function should converge..

Even for a simple function like  f(x) = exp(-x) * x, it gives answer as
8.89210984 for which f(x) = 0.001222392 and I set tolerance to 10^-12..

Also, is there a non graphical version of newton method? I looked at nleqslv
but have no idea how to use it..

Thanks for your help. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/newton-method-tp2306111p2306111.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] I need the dataset--thank you

2010-07-29 Thread David Winsemius


On Jul 29, 2010, at 7:00 AM, 笑啸 wrote:


dear:

I am a user of R project.And now ,I have a problem.

I want to know what is the name of the datasets in the web  
page--"Draw a Nomogram Representing a Regression Fit" which come  
from the R-home(http://www.r-project.org/   Package rms version  
3.0-0).


I suspect you are referring to the documentation for the nomogram  
function which has that title:

http://finzi.psych.upenn.edu/R/library/rms/html/nomogram.html




And can you supply the dataset to me?


If you are talking about the example for the nomogram function, then  
there is no name for a "dataset". In that example, Harrell constructs  
a group of vectors at the beginning and then refers to them separately  
without ever bundling them into a dataframe. You get the "dataset" by  
running the code at the beginning of the example.


n <- 1000 # define sample size
set.seed(17) # so can reproduce the results
age <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol <- rnorm(n, 200, 25)
sex <- factor(sample(c('female','male'), n,TRUE))
# Specify population model for log odds that Y=1
L <- .4*(sex=='male') + .045*(age-50) +
(log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)
ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')

There are some additional variables defined (also as vectors) in the  
second example on that page.


-- David.



wish for your help,thank you!

   truly 
 yours


  2010 
-07-29__

R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread David Winsemius


On Jul 29, 2010, at 4:32 AM, sammyny wrote:



Hi,
Is this method broken in R?


> ?newton.method
No documentation for 'newton.method' in specified packages and  
libraries:

you could try '??newton.method'

If you are asking about a non-base function, you are asked by the  
Posting Guide to supply the package name. You can do that in the text  
of you message or by providing code that starts out with:


require(package)

You are further asked to provide the code and data you used.

You are finally asked to contact the package maintainer if you believe  
that a package function is not providing correct results.



So   read the Posting Guide.

--
David.

I am using it to find roots of the following
function:
f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) +  
2.5*exp(-1.5*x) - 100


It is giving an answer of -38.4762403 which is not even close (f(x) =
2.903809e+25 for x=-38.4762403). The answer should be around  
0.01-0.1. This

function should converge..

Even for a simple function like  f(x) = exp(-x) * x, it gives answer  
as
8.89210984 for which f(x) = 0.001222392 and I set tolerance to  
10^-12..


Also, is there a non graphical version of newton method? I looked at  
nleqslv

but have no idea how to use it..

Thanks for your help.
--


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] message box

2010-07-29 Thread Uwe Ligges



On 28.07.2010 14:00, bruno Piguet wrote:

Martin du Saire asked :



I need some help figuring out how to make a pop-up message box appear with
error messages when running a script using Rterm.  Windows XP R2.10.1




Or see ?winDialog

Uwe Ligges



Have you tried the
examplescompiled
by James
Wettenhall ?

http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/mb.html

Bruno.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread Dennis Murphy
Hi:

Interesting. Try the following; f is copied and pasted directly from your
e-mail:

f <- function(x) 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) +
2.5*exp(-1.5*x) - 100
curve(f, -3, 8)  # plot it in a localized region
abline(0, 0, lty = 2)

There are two places where the function crosses the x-axis, but not where
you were expecting. The graph suggests one root between -3 and -2 and
another between 7 and 8: Note that uniroot() takes an object of class
function as its first argument and a search interval as its second. It is
the R function that finds a zero of a univariate function. See ?uniroot for
details. (And f is a function object; try class(f).)

On Thu, Jul 29, 2010 at 1:32 AM, sammyny  wrote:

>
> Hi,
> Is this method broken in R? I am using it to find roots of the following
> function:
> f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) -
> 100
>

Which method? It is never (conveniently) mentioned...  Function? Package?

>
> It is giving an answer of -38.4762403 which is not even close (f(x) =
> 2.903809e+25 for x=-38.4762403). The answer should be around 0.01-0.1. This
> function should converge..
>

> Even for a simple function like  f(x) = exp(-x) * x, it gives answer as
> 8.89210984 for which f(x) = 0.001222392 and I set tolerance to 10^-12..
>

I see handwaving and fulminating, but no code...

>
> Also, is there a non graphical version of newton method? I looked at
> nleqslv
> but have no idea how to use it..
>

> Thanks for your help.
>

HTH,
Dennis

> --
> View this message in context:
> http://r.789695.n4.nabble.com/newton-method-tp2306111p2306111.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Replace last element in a vector - elegant solution?

2010-07-29 Thread Henrique Dallazuanna
Another way:

x <- replace(x, length(x), 0)

On Thu, Jul 29, 2010 at 8:12 AM, Rainer M Krug  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi
>
> I have to replace the last element of a vector with 0, but the length of
> x is not known at coding time. So I do the following:
>
> x <- 1:10
> x
>
> x[length(x)] <- 0
> x
>
> it is working nicely, but I am wondering: is there a more elegant
> solution( like tail(x, 1) <- 0 , which does not work)?
>
> Thanks,
>
> Rainer
> - --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
>
> Tel:+33 - (0)9 53 10 27 44
> Cell:   +27 - (0)8 39 47 90 42
> Fax (SA):   +27 - (0)8 65 16 27 82
> Fax (D) :   +49 - (0)3 21 21 25 22 44
> Fax (FR):   +33 - (0)9 58 10 27 44
> email:  rai...@krugs.de
>
> Skype:  RMkrug
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkxRYh0ACgkQoYgNqgF2ego4iQCePSFCnWMPuY1eD2fyXUUXGRmF
> PXgAnjIDIB0EnODWv4HuYjwgU3SJW01x
> =JVQu
> -END PGP SIGNATURE-
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] does package "QuantPsych" function lm.beta can handle resultsof a regression with weights?

2010-07-29 Thread Dimitri Liakhovitski
Thanks a lot, Tom!

On Mon, Jul 26, 2010 at 9:24 AM, Tom Fletcher
 wrote:
> The original function was created for a simple example. It never was
> written to address weighted regression. A quick fix will work for you
> situation.
>
> ### The original is:
>
>
> lm.beta <-
> function (MOD)
> {
>    b <- summary(MOD)$coef[-1, 1]
>    sx <- sd(MOD$model[-1])
>    sy <- sd(MOD$model[1])
>    beta <- b * sx/sy
>    return(beta)
> }
>
>   A newer modification:
>
> lm.betaW <-
> function (MOD)
> {
>    b <- summary(MOD)$coef[-1, 1]
>    sx <- sd(MOD$model[-1][1])
>    sy <- sd(MOD$model[1])
>    beta <- b * sx/sy
>    return(beta)
> }
>
> The above should do the trick.
>
> TF
>
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Dimitri Liakhovitski
> Sent: Thursday, July 22, 2010 12:35 PM
> To: r-help@r-project.org
> Subject: [R] does package "QuantPsych" function lm.beta can handle
> resultsof a regression with weights?
>
> Hello, and sorry for not providing an example.
> I run a regular linear regression (using lm) and use weights with it
> (weights = ...).
> I use "QuantPsych" package, its function lm.beta to extract standardized
> regression weights from my lm regression object.
>
> When I don't use weights, everything is fine.
> But when I do use weights, I get an error that refers to lm.beta code:
> "In b * sx : longer object length is not a multiple of shorter object
> length"
>
> This happens because there is an extra column in the object:
> regr$model that lm.beta is using to get at the betas.
> Is there some other package that just gives me the standardized
> regression weights - even if I used weights for regression?
>
> Thank you!
>
> --
> Dimitri Liakhovitski
> Ninah Consulting
> www.ninah.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Mailing list for download

2010-07-29 Thread Sigbert Klinke
Hi,

is it possible to get all the mails of the mailing list / mail archives
for download (preferably in XML format)?

Thanks Sigbert

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Mailing list for download

2010-07-29 Thread Henrique Dallazuanna
Yes,

https://stat.ethz.ch/pipermail/r-help/

On Thu, Jul 29, 2010 at 10:13 AM, Sigbert Klinke
wrote:

> Hi,
>
> is it possible to get all the mails of the mailing list / mail archives
> for download (preferably in XML format)?
>
> Thanks Sigbert
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Mailing list for download

2010-07-29 Thread Jonathan Baron
This is what I do to make the search database at
http://finzi.psych.upenn.edu, which is also used for RSiteSearch.

Here is an example:

wget -r -np -p --no-check-certificate 
https://stat.ethz.ch/pipermail/r-help/2009-February/

I do this for each month.  But you could probably modify this to do it
all at once.  I run this as root, on linux.  (I'm not sure WHY I do it
as root, and probably you don't need to do that.)

This then gets dumped in a directory called stat.ethz.ch, with many 
subdirectories.

Jon

On 07/29/10 15:13, Sigbert Klinke wrote:
> Hi,
> 
> is it possible to get all the mails of the mailing list / mail archives
> for download (preferably in XML format)?
> 
> Thanks Sigbert
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help Creating a Stacked Bar Chart with Color Coding

2010-07-29 Thread Wu Gong

It is a little complicate for me to transform the table. Hope it works for
you.

x <- read.table(textConnection("Johnson 4
Smith4
Smith2
Smith3
Garcia   1
Garcia   4
Rodriguez   2
Adams   2
Adams   3
Adams   4
Turner   4
Turner   3 "),header=F)
## sort data
x<-x[order(x[,1],-x[,2]),]
## add another column to be the index used for reshape
x$times<-sequence(rle(as.character(x[,1]))$lengths)

y <- t(reshape(x, timevar="times", idvar="V1", direction="wide"))
colnames(y)<-y[1,]

barplot(y[-1,],col=27:29)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-Creating-a-Stacked-Bar-Chart-with-Color-Coding-tp2305487p2306464.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Statistical mailing list

2010-07-29 Thread Tal Galili
This is the new and exiting kid on the block:
http://stats.stackexchange.com/

There is also:
http://metaoptimize.com/qa
For more "machine learning" type questions.


Best,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jul 29, 2010 at 5:36 AM, Ralf B  wrote:

> I am looking for a mailing list for general statistical questions that
> are not R related. Do you have any suggestions for lists that are busy
> and helpful and/or lists that you use and recommend?
>
> Thanks in advance,
> Ralf
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Replace last element in a vector - elegant solution?

2010-07-29 Thread Wu Gong

Hi, 

The function head also works.

x <- 1:10
head(x,-1)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Replace-last-element-in-a-vector-elegant-solution-tp2306315p2306471.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2010-07-29 Thread Dévaványai Agamemnón
  Dear R Users! 
  I have a dataframe with duplicate cases. Var1 duplicated by var2.   

var1var2
var3
var4
var5var6
1   
4   
500 1   
2   
a   
1   3   
200 
2   5   
b   
1   
8   125 
1   
9   b   
2   
2   
120 2   
52  
b   
2   9   
400 
1   
22  c   
2   
6   
22  1   
22  
d   
3   1   
60  
1   54  
s   
3   
2   65  
1   
21  c   
3   
3   
62  1   
36  
a   
4   3   
63  
1   
32  a   
  
  I want to delete duplicate ones from var1 which have low rank at var2, and 
keep that case which has highest rank at var2. I would like to keep the Whole 
row (with the other variables: 

var1var2
var3
var4
var5var6
1   
8   
125 1   
9   
b

Re: [R] Displaying Counts of Unused Factors in Contingency Tables with table()

2010-07-29 Thread ntyson

Dennis,

Thank you for your response.  For clarification, I was not expecting  
table() to divinely figure out the intent that I was making two levels  
out of one (given my character vectors).  Since table() is a generic  
function that behaves differently with character and factor vectors, I  
needed a way to convert the data I had to get the desired behavior.   
Your factor() statements will accomplish my goal of putting zeros into  
contingency tables.


Regards,

Na'im


Quoting "Dennis Murphy" :


Hi,

table() is behaving as documented with respect to your example. local.labels
is a *character* vector with two distinct values and local.preds is a
*character* variable with one distinct value. If you were expecting your
table to divine that you wanted to include 'ah~' as a missing value in your
local.preds object, it's not going to happen under your current setup.


local.labels <- c("ah", "ah", "ah~")
local.preds <- c("ah", "ah", "ah")
table(local.labels, local.preds)

local.preds
local.labels ah
 ah   2
 ah~  1

class(local.labels)

[1] "character"

class(local.preds)

[1] "character"


Is this what you had in mind?

labels <- factor(local.labels)
preds <- factor(local.preds, levels = c('ah', 'ah~'))

table(labels, preds)

  preds
labels ah ah~
   ah   2   0
   ah~  1   0


labels

[1] ah  ah  ah~
Levels: ah ah~

preds

[1] ah ah ah
Levels: ah ah~

There is a distinction in R between character objects and factor objects.
More generally, many [generic] functions behave differently depending on the
type of object(s) supplied as input.

HTH,
Dennis

On Wed, Jul 28, 2010 at 10:29 PM, Na'im R. Tyson  
wrote:



R-philes,

I have a question about displaying counts of unused factors using the
table() function.  I have two vectors with character data in them:

local.labels("ah", "ah", "ah~")
local.preds("ah", "ah", "ah")

If I use the table function as shown below, I get an error because the
number of levels do not match up.

v.cont.table <- table(local.labels, local.preds, dnn=c("observed",
"predicted"));

Is there any way to get zero counts into the contingency table, or would I
have to use a flat table?  Any help with sample code, or a pointer to a
previous post, would be much appreciated.

Regards,

Na'im

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Residuals of mixed effects model

2010-07-29 Thread will . eagle
Dear all,

how do I get the residuals from a lme() output objects which are adjusted for 
fixed AND (!) random effects?

I tried residuals(), but it seems they just give me the residuals adjusted for 
the fixed effects of the regression model.

The model I use is:
lme.out <- lme(data=MyDataInLongFormat,fixed= outcome~1, random= ~ 
1|individual, correlation=corSymm(form = ~time|individual))

Actually, I use only the intercept in the fixed part of the predictor, and I 
want to get residuals which are adjusted for the fixed part (intercept) and the 
random effect, ie to get rid of the correlatedness of individual measures 
across time. This way I want to get data where I can treat the measures per 
time point as independent groups. Makes sense?

Thanks in advance,

Will

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: (no subject)

2010-07-29 Thread Petr PIKAL
Hi 

Your data came rather corrupted but probably you can split your data frame 
according to var1, select highest rank in var2 and reconstruct data frame 
from the result

see
split, lapply, 

Regards
Petr



r-help-boun...@r-project.org napsal dne 29.07.2010 15:48:26:

>   Dear R Users! 
>   I have a dataframe with duplicate cases. Var1 duplicated by var2. 
>var1  
> var2var3var4  
> var5var61  
> 45001 2
> a13  
> 20025 b
> 18125 1
> 9b2  
> 21202  
> 52b2  
> 94001  
> 22c2  
> 622122
> d31  
> 60154 s
> 32651 
> 21c3  
> 362136
> a43  
> 63132 a 
>   I want to delete duplicate ones from var1 which have low rank at var2, 
and 
> keep that case which has highest rank at var2. I would like to keep the 
Whole 
> row (with the other variables: 
>var1  
> var2var3var4  
> var5var61  
> 81251 9
> b29  
> 400122  
> c33  
> 62136 a
> 43631 
> 32a 
>   Thanks Ag
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Displaying Counts of Unused Factors in Contingency Tables with table()

2010-07-29 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 29.07.2010 16:03:30:

> Dennis,
> 
> Thank you for your response.  For clarification, I was not expecting 
> table() to divinely figure out the intent that I was making two levels 
> out of one (given my character vectors).  Since table() is a generic 
> function that behaves differently with character and factor vectors, I 

I am not sure if table behaves differently with character and factor 
vectors.

x<-sample(letters[1:3], 10, replace=T)
table(x) # character
x
a b c 
3 6 1 

x.f<-as.factor(x) # same factor
table(x.f)
x.f
a b c 
3 6 1 

# factor with extra levels
x.f.extra.levels<-factor(x, levels=letters[1:6])
table(x.f.extra.levels)
x.f.extra.levels
a b c d e f 
3 6 1 0 0 0 

So if you do not supply extra levels to factor, result is same as with 
character vector.

Regards
Petr

> needed a way to convert the data I had to get the desired behavior. 
> Your factor() statements will accomplish my goal of putting zeros into 
> contingency tables.
> 
> Regards,
> 
> Na'im
> 
> 
> Quoting "Dennis Murphy" :
> 
> > Hi,
> >
> > table() is behaving as documented with respect to your example. 
local.labels
> > is a *character* vector with two distinct values and local.preds is a
> > *character* variable with one distinct value. If you were expecting 
your
> > table to divine that you wanted to include 'ah~' as a missing value in 
your
> > local.preds object, it's not going to happen under your current setup.
> >
> >> local.labels <- c("ah", "ah", "ah~")
> >> local.preds <- c("ah", "ah", "ah")
> >> table(local.labels, local.preds)
> > local.preds
> > local.labels ah
> >  ah   2
> >  ah~  1
> >> class(local.labels)
> > [1] "character"
> >> class(local.preds)
> > [1] "character"
> >
> >
> > Is this what you had in mind?
> >
> > labels <- factor(local.labels)
> > preds <- factor(local.preds, levels = c('ah', 'ah~'))
> >> table(labels, preds)
> >   preds
> > labels ah ah~
> >ah   2   0
> >ah~  1   0
> >
> >> labels
> > [1] ah  ah  ah~
> > Levels: ah ah~
> >> preds
> > [1] ah ah ah
> > Levels: ah ah~
> >
> > There is a distinction in R between character objects and factor 
objects.
> > More generally, many [generic] functions behave differently depending 
on the
> > type of object(s) supplied as input.
> >
> > HTH,
> > Dennis
> >
> > On Wed, Jul 28, 2010 at 10:29 PM, Na'im R. Tyson 
> > wrote:
> >
> >> R-philes,
> >>
> >> I have a question about displaying counts of unused factors using the
> >> table() function.  I have two vectors with character data in them:
> >>
> >> local.labels("ah", "ah", "ah~")
> >> local.preds("ah", "ah", "ah")
> >>
> >> If I use the table function as shown below, I get an error because 
the
> >> number of levels do not match up.
> >>
> >> v.cont.table <- table(local.labels, local.preds, dnn=c("observed",
> >> "predicted"));
> >>
> >> Is there any way to get zero counts into the contingency table, or 
would I
> >> have to use a flat table?  Any help with sample code, or a pointer to 
a
> >> previous post, would be much appreciated.
> >>
> >> Regards,
> >>
> >> Na'im
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Question about geoR package.

2010-07-29 Thread Alaios
Hello in geoR package there is a function called grf()
According to the geoR short manual grf() takes the following arguments



* n number of points (spatial locations) in each simulations.
* grid optional. An n × 2 matrix with coordinates of the simulated data.
* nx optional. Number of points in the X direction.
* ny optional. Number of points in the Y direction.

What I want to create is a matrix (at least this is a matlab in matrix) that 
contains values created from grf(). The array is of dimensions x*y so the grf() 
needs to create a x*y map.

If you see the parameters again you will notice that there is a n (n number of 
points) and nx and ny also.

If I put nx=400 and ny=200 (this is just an example) the grf() will return 
values for 400 cells (for some reason picks the highest values of nx and ny). 
If 
I try something like n=x*y I get the message that the RandomField package must 
be used. Really do you what the parameter n is about (number of points))?

I would like to thank you in advance for your help
Alex



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fwd: duplicates

2010-07-29 Thread Dévaványai Agamemnón
 

-- Eredeti üzenet --
Feladó: Dévaványai Agamemnón  Címzett: 
r-...@r-project.org, r-...@r-project.orgelküldve: 2010. július 29. 
16:29Tárgy : duplicates

 Sorry!
I try it again

Dear R Users!


I have a dataframe with duplicatecases. Var1 duplicated by var2. 



 var1 var2  var3  var4  var5
14   500 12
 13   200 25
 18   125 19
 22   120 252
 2622  120
29400122
3110028
32200540
 4820  160

I want to delete duplicate ones from var1 which have low rank at var2, and keep 
that case which has highest rank at var2. I would like to keep the Whole row 
(with the other variables: 

var1 var2 var3var4var5
1  8  125 1 9
2  9   400122
3  2   20050 40
4   8  200 1  60

 Thanks Ag

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] heplots 0.9-3 and candisc 0.5-18 released to CRAN

2010-07-29 Thread Michael Friendly
I've just released the latest R-Forge versions of heplots 0.9-3 and 
candisc 0.5-18 to CRAN.

They should appear there within a day or two.

== heplots
The heplots package provides functions for visualizing hypothesis tests
in multivariate linear models (MANOVA, multivariate multiple regression, 
MANCOVA, etc.). They
represent sums-of-squares-and-products matrices for linear hypotheses 
and for

error using ellipses (in two dimensions), ellipsoids (in three dimensions),
or by line segments in one dimension.  Both of these require the latest 
version of car (2.0-0)

but allow some backward compatibility with car 1.x-x

The most substantial change is that (with car 2), heplots now handles 
repeated measures designs
and doubly multivariate designs within the multivariate linear model 
approach.  A vignette

on this has been written, but is not yet included in the package.
New since the last CRAN version:
Version 0.9-3 (2010-07-27)
o Added gsorth() for Gram-Schmidt orthogonalization of a matrix or data 
frame, preserving

   column means and standard deviations
o Avoid Deprecated warnings (linear.hypothesis) with car2
o Fixed documentation warnings with car2 (linear.hypothesis, data.ellipse)

Version 0.9-2 (2010-02-12)
o Added demo/Big5.R
o fixed buglet with text3d causing rgl to crash (thx: Duncan Murdoch)
o switched inst/CHANGES to NEWS
o Added data/RatWeight and examples
o Added data/Headache and examples
o Fixed buglets in heplot, heplot1d, heplot3d regarding number of variables
o Added etasq.mlm methods for multivariate measures of association (\eta^2)
o Return ellipse radius from heplot, heplot3d

Version 0.9-1 (2010-01-1)
o heplot.mlm, pairs.mlm, heplot3d.mlm now work for repeated measure designs
  with only covariates on the rhs.
o Implemented heplot1d() for repeated measures designs (untested)
o Revised documentation for repeated measures
o Added center.cex to heplot.mlm()
o Revised mark.H0() to handle 3D plots also
o Added Adoption data -- MMreg with repeated measures
o Added ReactTime data -- 2 within-S, no between-S factors
o Fixed bug with icontrasts
o Added markH0 argument to heplot
o Added label argument to mark.H0()
o Added arrow3d()
o Fixed buglet in pairs.mlm (type)

Version 0.9-0 (2009-12-25)
o Implemented 2D HE plots in heplot.mlm for repeated measures designs 
by adding
  idata=, idesign=, icontrasts= arguments. 
o imatrix= argument  for doubly-multivariate designs implemented, but 
depends on car 2.0+

o Updated example(OBK)
o Updated example(WeightLoss)
o Implemented 3D HE plots in heplot3d.mlm for repeated measures designs 
(OK)

o Implemented pairs() for repeated measures designs (OK)

== candisc
candisc includes functions for computing and visualizing generalized 
canonical
discriminant analyses for a multivariate linear model. They are designed 
to provide low-rank visualizations of
terms in a \code{mlm} via the \code{plot} method and the \pkg{heplots} 
package.


Recent changes:
Version 0.5-17 (2010-2-11)
o  Allow to select canonical dimension in plot(candisc(), which=)

Version 0.5-18 (2010-7-27)
o  Fixed predictor.names problem with car_2.0-0

--
Michael Friendly Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.

York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] duplicates

2010-07-29 Thread Dévaványai Agamemnón
  Sorry!
I try it again

Dear R Users!


I have a dataframe with duplicatecases. Var1 duplicated by var2. 



var1 var2  var3  var4  var5
14   500 12
13   200 25
18   125 19
22   120 252
2622  120
29400122
3110028
32200540
4820  160

I want to delete duplicate ones from var1 which have low rank at var2, and keep 
that case which has highest rank at var2. I would like to keep the Whole row 
(with the other variables: 

var1 var2 var3var4var5
1  8  125 1 9
2  9   400122
3  2   20050 40
4   8  200 1  60 Thanks Ag 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: duplicates

2010-07-29 Thread ONKELINX, Thierry
Does this works? (Untested)

library(plyr)
ddply(your_dataframe, "var1", function(x){
x[which.max(x$var2), ]
})



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey
  

> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens Dévaványai Agamemnón 
> Verzonden: donderdag 29 juli 2010 16:31
> Aan: r-help@r-project.org
> Onderwerp: [R] Fwd: duplicates
> 
>  
> 
> -- Eredeti üzenet --
> Feladó: Dévaványai Agamemnón  
> Címzett: r-...@r-project.org, 
> r-...@r-project.orgelküldve: 2010. július 29. 16:29Tárgy : duplicates
> 
>  Sorry!
> I try it again
> 
> Dear R Users!
> 
> 
> I have a dataframe with duplicatecases. Var1 duplicated by var2. 
> 
> 
> 
>  var1 var2  var3  var4  var5
> 14   500 12
>  13   200 25
>  18   125 19
>  22   120 252
>  2622  120
> 29400122
> 3110028
> 32200540
>  4820  160
> 
> I want to delete duplicate ones from var1 which have low rank 
> at var2, and keep that case which has highest rank at var2. I 
> would like to keep the Whole row (with the other variables: 
> 
> var1 var2 var3var4var5
> 1  8  125 1 9
> 2  9   400122
> 3  2   20050 40
> 4   8  200 1  60
> 
>  Thanks Ag
> 
>   [[alternative HTML version deleted]]
> 
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread Ravi Varadhan
Yes, there are two roots.   Try this to get the 2 roots:

require(BB)

p0.mat <- matrix(rnorm(10), 10, 1) # 10 random starting values

ans <- multiStart(par=p0, fn=f)

ans$par


You can see that the 2 roots are -2.438285 and 7.419378.


Hope this helps,

Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Dennis Murphy 
Date: Thursday, July 29, 2010 8:28 am
Subject: Re: [R] newton.method
To: sammyny 
Cc: r-help@r-project.org


> Hi:
>  
>  Interesting. Try the following; f is copied and pasted directly from 
> your
>  e-mail:
>  
>  f <- function(x) 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) +
>  2.5*exp(-1.5*x) - 100
>  curve(f, -3, 8)  # plot it in a localized region
>  abline(0, 0, lty = 2)
>  
>  There are two places where the function crosses the x-axis, but not where
>  you were expecting. The graph suggests one root between -3 and -2 and
>  another between 7 and 8: Note that uniroot() takes an object of class
>  function as its first argument and a search interval as its second. 
> It is
>  the R function that finds a zero of a univariate function. See 
> ?uniroot for
>  details. (And f is a function object; try class(f).)
>  
>  On Thu, Jul 29, 2010 at 1:32 AM, sammyny  wrote:
>  
>  >
>  > Hi,
>  > Is this method broken in R? I am using it to find roots of the following
>  > function:
>  > f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 
> 2.5*exp(-1.5*x) -
>  > 100
>  >
>  
>  Which method? It is never (conveniently) mentioned...  Function? Package?
>  
>  >
>  > It is giving an answer of -38.4762403 which is not even close (f(x) 
> =
>  > 2.903809e+25 for x=-38.4762403). The answer should be around 
> 0.01-0.1. This
>  > function should converge..
>  >
>  
>  > Even for a simple function like  f(x) = exp(-x) * x, it gives 
> answer as
>  > 8.89210984 for which f(x) = 0.001222392 and I set tolerance to 10^-12..
>  >
>  
>  I see handwaving and fulminating, but no code...
>  
>  >
>  > Also, is there a non graphical version of newton method? I looked at
>  > nleqslv
>  > but have no idea how to use it..
>  >
>  
>  > Thanks for your help.
>  >
>  
>  HTH,
>  Dennis
>  
>  > --
>  > View this message in context:
>  > 
>  > Sent from the R help mailing list archive at Nabble.com.
>  >
>  > __
>  > R-help@r-project.org mailing list
>  > 
>  > PLEASE do read the posting guide
>  > 
>  > and provide commented, minimal, self-contained, reproducible code.
>  >
>  
>   [[alternative HTML version deleted]]
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread Ravi Varadhan
Oops, it should have been:

ans <- multiStart(par=p0.mat, fn=f)

ans$par


Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvarad...@jhmi.edu


- Original Message -
From: Ravi Varadhan 
Date: Thursday, July 29, 2010 11:22 am
Subject: Re: [R] newton.method
To: Dennis Murphy 
Cc: r-help@r-project.org, sammyny 


> Yes, there are two roots.   Try this to get the 2 roots:
>  
>  require(BB)
>  
>  p0.mat <- matrix(rnorm(10), 10, 1) # 10 random starting values
>  
>  ans <- multiStart(par=p0, fn=f)
>  
>  ans$par
>  
>  
>  You can see that the 2 roots are -2.438285 and 7.419378.
>  
>  
>  Hope this helps,
>  
>  Ravi.
>  
>  
>  Ravi Varadhan, Ph.D.
>  Assistant Professor,
>  Division of Geriatric Medicine and Gerontology
>  School of Medicine
>  Johns Hopkins University
>  
>  Ph. (410) 502-2619
>  email: rvarad...@jhmi.edu
>  
>  
>  - Original Message -
>  From: Dennis Murphy 
>  Date: Thursday, July 29, 2010 8:28 am
>  Subject: Re: [R] newton.method
>  To: sammyny 
>  Cc: r-help@r-project.org
>  
>  
>  > Hi:
>  >  
>  >  Interesting. Try the following; f is copied and pasted directly 
> from 
>  > your
>  >  e-mail:
>  >  
>  >  f <- function(x) 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) +
>  >  2.5*exp(-1.5*x) - 100
>  >  curve(f, -3, 8)  # plot it in a localized region
>  >  abline(0, 0, lty = 2)
>  >  
>  >  There are two places where the function crosses the x-axis, but 
> not where
>  >  you were expecting. The graph suggests one root between -3 and -2 
> and
>  >  another between 7 and 8: Note that uniroot() takes an object of class
>  >  function as its first argument and a search interval as its 
> second. 
>  > It is
>  >  the R function that finds a zero of a univariate function. See 
>  > ?uniroot for
>  >  details. (And f is a function object; try class(f).)
>  >  
>  >  On Thu, Jul 29, 2010 at 1:32 AM, sammyny  
> wrote:
>  >  
>  >  >
>  >  > Hi,
>  >  > Is this method broken in R? I am using it to find roots of the following
>  >  > function:
>  >  > f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 
>  > 2.5*exp(-1.5*x) -
>  >  > 100
>  >  >
>  >  
>  >  Which method? It is never (conveniently) mentioned...  Function? Package?
>  >  
>  >  >
>  >  > It is giving an answer of -38.4762403 which is not even close 
> (f(x) 
>  > =
>  >  > 2.903809e+25 for x=-38.4762403). The answer should be around 
>  > 0.01-0.1. This
>  >  > function should converge..
>  >  >
>  >  
>  >  > Even for a simple function like  f(x) = exp(-x) * x, it gives 
>  > answer as
>  >  > 8.89210984 for which f(x) = 0.001222392 and I set tolerance to 10^-12..
>  >  >
>  >  
>  >  I see handwaving and fulminating, but no code...
>  >  
>  >  >
>  >  > Also, is there a non graphical version of newton method? I 
> looked at
>  >  > nleqslv
>  >  > but have no idea how to use it..
>  >  >
>  >  
>  >  > Thanks for your help.
>  >  >
>  >  
>  >  HTH,
>  >  Dennis
>  >  
>  >  > --
>  >  > View this message in context:
>  >  > 
>  >  > Sent from the R help mailing list archive at Nabble.com.
>  >  >
>  >  > __
>  >  > R-help@r-project.org mailing list
>  >  > 
>  >  > PLEASE do read the posting guide
>  >  > 
>  >  > and provide commented, minimal, self-contained, reproducible code.
>  >  >
>  >  
>  >[[alternative HTML version deleted]]
>  >  
>  >  __
>  >  R-help@r-project.org mailing list
>  >  
>  >  PLEASE do read the posting guide 
>  >  and provide commented, minimal, self-contained, reproducible code.
>  
>  __
>  R-help@r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] New Open Source Community

2010-07-29 Thread Tal Galili
You mean along with:

http://stats.stackexchange.com/
and
http://metaoptimize.com/qa/

We have passed the online-over-proliferation stage for out topic of
interest... :)



Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Thu, Jul 29, 2010 at 10:28 AM, CJN  wrote:

>
> Equalis just announced it's public beta today
>
> http://www.equalis.com http://www.equalis.com .
>
> It has forums dedicated to lots of math topics including open source
> software.  It specifically has an R forum and an R user group.  Also has
> forums and groups for Octave, Scilab, and Sage.
> http://www.equalis.com/forums/ http://www.equalis.com/forums/
> http://www.equalis.com/members/group.asp?id=66492
> http://www.equalis.com/members/group.asp?id=66492
>
> Check it out - registration is free.  We can use it as a resource to
> promote
> R and help each other.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/New-Open-Source-Community-tp2306058p2306058.html
> Sent from the R help mailing list archive at Nabble.com.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Meaning of proc.time()

2010-07-29 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Christofer Bogaso
> Sent: Thursday, July 29, 2010 7:51 AM
> To: jim holtman
> Cc: r-h...@stat.math.ethz.ch
> Subject: Re: [R] Meaning of proc.time()
> 
> Ok, but what are "user CPU" and "system CPU?" If I know corrrectly, I
> only have a single CPU in my system. It is not a multi-corer system.
> Should I read that, system CPU time is the time that my CPU took for
> actual calculation, and the user CPU time is the time that my CPU took
> to analyze my code that I have written in the console?

"User CPU time" gives the CPU time spent by the current
process (i.e., the current R session) and "system CPU time"
gives the CPU time spent by the kernel (the operating
system) on behalf of the current process.  The operating
system is used for things like opening files, doing
input or output, starting other processes, and looking at
the system clock:  operations that involve resources that many
processes must share.  Different operating systems will
have different things done by the operating system.

E.g., look at the difference between opening a file once
per write for many writes and opening it just once:

> system.time(for(i in 1:10^4)cat(i, file="e:/temp/i.txt", append=TRUE))
   user  system elapsed 
   1.002.924.08 
> system.time({file<-file("e:/temp/i.txt","w");for(i in 1:10^4)cat(i, 
> file=file);close(file)})
   user  system elapsed 
   0.100.080.15

Most of the time you are not terribly interested in whether
the CPU is being used by R or by the operating system on
R's behalf.  However, a large system time can point towards
problems in not batching up I/O or other OS requests enough.   

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

> 
> On Tue, Jul 27, 2010 at 4:12 PM, jim holtman 
>  wrote:
> > This is reporting on the accumulated values of the user CPU, system
> > CPU and elapsed time.  The 'user + system' values indicate how much
> > CPU has been used to process whatever has occurred in the R 
> session so
> > far.  To get the time to execute a statement, or block of code, you
> > can use 'system.time' or take the difference in two values of
> > proc.time:
> >
> >> a <- proc.time()
> >> for(i in 1:1e6) x <- 1
> >> proc.time() - a  # elapsed
> >   user  system elapsed
> >   0.38    0.05   42.48
> >>
> >
> > Here is some stuff I typed in at the console.  It took me 42 seconds
> > (elapsed or wall clock time) to type in the commands to the GUI.  I
> > executed a simple 'for' loop for 1,000,000 iteration and 
> this required
> > 0.43 CPU seconds (user + system).
> >
> >> a <- proc.time()
> >> for(i in 1:1e7) x <- 1
> >> proc.time() - a  # elapsed
> >   user  system elapsed
> >   3.33    0.03   18.14
> >>
> >
> > Notice that I executed the 'for' loop 10,000,000 times and the CPU
> > time is now 3.36 seconds, or about 10X more than the first one which
> > is about what you would expect.   This is a common way of 
> determining
> > what portions of your script are taking the most resource.
> >
> > HTH
> >
> > On Tue, Jul 27, 2010 at 4:03 AM, Christofer Bogaso
> >  wrote:
> >> If I run proc.time() function, I would get following:
> >>
> >>> proc.time()
> >>    user  system elapsed
> >>    2.82    4.18  792.39
> >>
> >> However I am struggling the meaning of the object what it 
> returned. In
> >> help file it says that:
> >>
> >> "user time" is the time required to execute the calling 
> process. Here
> >> what is the calling process exactly? Who executes this? 
> system itself?
> >>
> >> 2ndly "system time" is the time required by the system for 
> execution
> >> of something.. what execution? What is the meaning of " on
> >> behalf of the
> >>  calling process?"
> >>
> >> 3rdly what is elapsed time? Total time I spent on current session,
> >> since I opened the R window?
> >>
> >> Really sorry if I asked trivial questions, however honestly I could
> >> not understand those. Some helpful comments are highly appreciated.
> >>
> >> Thanks,
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
> >
> > --
> > Jim Holtman
> > Cincinnati, OH
> > +1 513 646 9390
> >
> > What is the problem that you are trying to solve?
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.ht

[R] how to get higher derivatives with "deriv"

2010-07-29 Thread Marius Hofert
Dear ExpeRts,

I have trouble implementing a function which computes the k-th derivative of a 
specified function f and returns it as a function. I tried to adapt what I 
found under ?deriv but could not get it to work. Here is how it should look 
like: 

## specify the function
f <- function (x,alpha) x^alpha

## higher derivatives
DD <- function(expr, variable, order = 1) {
   if(order < 1) stop("'order' must be >= 1")
   if(order == 1) deriv(expr, variable)
   else DD(deriv(expr, variable), variable, order - 1)
}

## compute the second derivative of f
f.prime.prime <- DD(f,"x",2)

## evaluate it at x=1 for alpha=0.5
f.prime.prime(1,0.5)


Many thanks,

Marius
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Fry Plots

2010-07-29 Thread cassandra browne

Does anyone know how to do a fry plot in R? I have 600-800 points per image, 
and I really don't want to attempt that manually. 
 
Thank you!
Cassie
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to run this video link

2010-07-29 Thread Velappan Periasamy
Pls tell me how to run this video in R

http://nptel.iitm.ac.in/video.php?courseId=1083&p=4

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fwd: duplicates

2010-07-29 Thread Wu Gong

Hi,

Please try ?rle

t.x <- x[order(x[,1],x[,2]),]
t.x[cumsum(rle(t.x[,1])$lengths),]

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Fwd-duplicates-tp2306555p2306617.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.delim()

2010-07-29 Thread Ben Bolker
Doran, Harold  air.org> writes:

> 
> Thank you, Phil. Unfortunately, there are quotes used properly elsewhere. 
> - Original Message -
> From: Phil Spector  stat.berkeley.edu>
> To: Doran, Harold
> Cc: r-help  r-project.org  r-project.org>
> Sent: Wed Jul 28 18:29:32 2010
> Subject: Re: [R] read.delim()
> 
> Harold -
> If there aren't any true quoted fields in the file, you 
> could  pass the quote="" option to read.delim().
> 
>   - Phil Spector
>Statistical Computing Facility
>Department of Statistics
>UC Berkeley
>spector  stat.berkeley.edu
> 
> On Wed, 28 Jul 2010, Doran, Harold wrote:
> 
> > I am reading in a very large file with names in it and R is truncating the
number of rows it reads in. The
> separator in this file is a pipe '|' and so I use
> >
> > dat <- read.delim('pathToMyFile', header= TRUE, sep='|')
> >
> > It turns out that it is reading up to row 61145 and stopping and I think I
see why, but am not sure of the best
> solution to this problem. I see the name of the person in the next row has a
quote in it, such as:
> >
> > Joe Sm"ith
> >
> > I *think* this is causing a problem in the read in. In fact, whenever I use
> >
> >
> > ?  tail(dat)
> >
> > ?  or dat[61145,]
> >
> > R crashes.
> >
> > But, it doesn't crash when I use head(dat) or index any other row. 
> I could change my raw data and manually
> delete this ". However, is there another solution within the
> args of read.delim that would be useful as a
> solution such that I would not have to manually change my raw data
> >
> > Harold


  Does R actually 'crash' (i.e., stop/segmentation fault/etc.)?
Or does it just give you an error message?

  Assuming that the bad cases are always represented by a *single*
quotation mark on a line, you could find them by reading in the
whole file with r <- readLines(...) [assuming the file is small enough
to suck into memory whole] and do something like

 sapply(strsplit(r,""),function(x) sum(x=="\""))

to find the bad lines.  There are certainly many more pathological
cases (what if there are (good) paired quotes and (bad) unpaired
quotes on the same line?  What if there are two (bad) unpaired quotes
on the same line? 

  Sounds like it's time to do some manual editing.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] locator function and connecting segment

2010-07-29 Thread Erin Hodgess
Dear R People:

I'm using the locator() function on a chart and I select two values.

Is there a way already in place to connect the two values with a line
segment, please?

Just thought I'd check before I started coding.

Thanks in advance,
Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 3d data plot

2010-07-29 Thread szisziszilvi

Hello!

I'm a newbe, and a bit confused amongst the data types and functions...

The problem to be solved is the following: We have measurements. They are in
a csv file, in 3 columns. So this would be an x-y-z plot, where z is the
measurement at (x,y) conditions. Just a simple plot, nothing special. Dots,
surface columns - doesn't matter to me. I just can't figure it out somehow.

Szilvia
-- 
View this message in context: 
http://r.789695.n4.nabble.com/3d-data-plot-tp2306540p2306540.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Crash report: projection pursuit & predict

2010-07-29 Thread Horace Tso
Folks,

The projection pursuit regression function in the base R seems to crash when 
the optimization level is set to zero, i.e. the initial ridge terms are 
accepted without refitting. I encountered this problem in an out-of-sample 
prediction exercise using predict. But further investigation suggests the issue 
is with the ppr fit and predict just sppeds up the crash. The other optlevels 
seem to be OK, but I have not done enough testing to say for sure.

I'm using 2.11.1 under the 32-bit Windows XP. I've also tested the codes under 
a 64-bit Ubuntu and the same problem occurred. By the way, right before Rgui 
shuts down, the pop-up window suggests it's a runtime error in C++.

Here are the codes that cause the crash,

library(mlbench)
data(BostonHousing2)
BH = BostonHousing2[,-c(1:5)]
dat1 = BH[1:200,]
dat2 = BH[201:400,]
mod = ppr(log(cmedv)~., data=dat1, optlevel=0, nterms=2, max.terms=5)
pred = predict(mod, newdata=dat2)

Thks.

HT

> sessionInfo()
R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

loaded via a namespace (and not attached):
[1] tools_2.11.1

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Help on installation of R Packages

2010-07-29 Thread Raghu
Hi

I tried installing the packages with:

*install.packages("quantstrat", repos="http://R-Forge.R-project.org";)
* *install.packages("blotter", repos="http://R-Forge.R-project.org";)
**install.packages("FinancialInstrument", repos="
http://R-Forge.R-project.org";)*

But non of these packages is getting loaded. I tried re-installing R as well
but that did not help. Can someone kindly help please?

Thx

-- 
'Raghu'

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Crash report: projection pursuit & predict

2010-07-29 Thread Ben Bolker
Horace Tso  pgn.com> writes:
 
> I'm using 2.11.1 under the 32-bit Windows XP. I've also tested the 
> codes under a 64-bit Ubuntu and the same
> problem occurred. By the way, right before Rgui shuts down, the \
> pop-up window suggests it's a runtime
> error in C++.
> 
> Here are the codes that cause the crash,
> 
> library(mlbench)
> data(BostonHousing2)
> BH = BostonHousing2[,-c(1:5)]
> dat1 = BH[1:200,]
> dat2 = BH[201:400,]
> mod = ppr(log(cmedv)~., data=dat1, optlevel=0, nterms=2, max.terms=5)
> pred = predict(mod, newdata=dat2)
> 
> Thks.
> 
> HT
> 
   On 32-bit Ubuntu, clean session (--vanilla), it seems to work the first
time and crash the second:

> sessionInfo()
R version 2.11.1 (2010-05-31) 
i486-pc-linux-gnu 

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 
> library(mlbench)
> data(BostonHousing2)
> BH = BostonHousing2[,-c(1:5)]
> dat1 = BH[1:200,]
> dat2 = BH[201:400,]
> mod = ppr(log(cmedv)~., data=dat1, optlevel=0, nterms=2, max.terms=5)
> pred = predict(mod, newdata=dat2)
> 
> library(mlbench)
> data(BostonHousing2)
> BH = BostonHousing2[,-c(1:5)]
> dat1 = BH[1:200,]
> dat2 = BH[201:400,]
> mod = ppr(log(cmedv)~., data=dat1, optlevel=0, nterms=2, max.terms=5)

 *** caught segfault ***
address 0xe024, cause 'memory not mapped'

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help on installation of R Packages

2010-07-29 Thread Uwe Ligges



On 29.07.2010 15:34, Raghu wrote:

Hi

I tried installing the packages with:

*install.packages("quantstrat", repos="http://R-Forge.R-project.org";)
* *install.packages("blotter", repos="http://R-Forge.R-project.org";)
**install.packages("FinancialInstrument", repos="
http://R-Forge.R-project.org";)*

But non of these packages is getting loaded. I tried re-installing R as well
but that did not help. Can someone kindly help please?

Thx




To install a package use install.packages(), but to load it, use 
library()...


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fry Plots

2010-07-29 Thread Ben Bolker
cassandra browne  hotmail.com> writes:

> 
> 
> Does anyone know how to do a fry plot in R? I have 600-800 points per image,
and I really don't want to attempt
> that manually. 
> 
> Thank you!
> Cassie

library(sos)  ## you'll have to install this first
findFn("fry plot")

finds useful stuff in the geophys and spatstat packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Reset R environment through R command

2010-07-29 Thread Ralf B
Is it possible to remove all variables in the current environment
through a R command.

Here is what I want:

x <- 5
y < 10:20
reset()
print(x)
print(y)

Output should be NULL for x and y, and not 5 and 10:20.

Can one do that in R?

Best,
Ralf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Reset R environment through R command

2010-07-29 Thread Ralf B
With environment I actually meant workspace.

On Thu, Jul 29, 2010 at 1:22 PM, Ralf B  wrote:
> Is it possible to remove all variables in the current environment
> through a R command.
>
> Here is what I want:
>
> x <- 5
> y < 10:20
> reset()
> print(x)
> print(y)
>
> Output should be NULL for x and y, and not 5 and 10:20.
>
> Can one do that in R?
>
> Best,
> Ralf
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 3d data plot

2010-07-29 Thread Sarah Goslee
You don't really give a lot of information about exactly what you want. Some
time spent browsing the R Graph Gallery at
http://addictedtor.free.fr/graphiques/
might be helpful. Each plot has associated the code necessary to reproduce
it. Especially look at the lattice and scatterplot3d sections. You can also
search for 3D.

Sarah

On Thu, Jul 29, 2010 at 10:19 AM, szisziszilvi  wrote:
>
> Hello!
>
> I'm a newbe, and a bit confused amongst the data types and functions...
>
> The problem to be solved is the following: We have measurements. They are in
> a csv file, in 3 columns. So this would be an x-y-z plot, where z is the
> measurement at (x,y) conditions. Just a simple plot, nothing special. Dots,
> surface columns - doesn't matter to me. I just can't figure it out somehow.
>
> Szilvia
> --


-- 
Sarah Goslee
http://www.functionaldiversity.org

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Reset R environment through R command

2010-07-29 Thread Henrique Dallazuanna
rm(list = ls(all = TRUE))

On Thu, Jul 29, 2010 at 2:26 PM, Ralf B  wrote:

> With environment I actually meant workspace.
>
> On Thu, Jul 29, 2010 at 1:22 PM, Ralf B  wrote:
> > Is it possible to remove all variables in the current environment
> > through a R command.
> >
> > Here is what I want:
> >
> > x <- 5
> > y < 10:20
> > reset()
> > print(x)
> > print(y)
> >
> > Output should be NULL for x and y, and not 5 and 10:20.
> >
> > Can one do that in R?
> >
> > Best,
> > Ralf
> >
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Installing a newer version of a package - problems

2010-07-29 Thread Raghu
Hi

I am trying to install the latest version of the package quantstrat but I
get the following error:

install.packages("quantstrat", repos="http://R-Forge.R-project.org";)
Warning in install.packages("quantstrat", repos = "
http://R-Forge.R-project.org";) :
  argument 'lib' is missing: using
'C:\Users\Owner\Documents/R/win-library/2.11'
Warning: package 'quantstrat' is in use and will not be installed
> Warning in install.packages("quantstrat", repos = "
http://R-Forge.R-project.org";) :
Error: unexpected 'in' in "Warning in"
>   argument 'lib' is missing: using
'C:\Users\Owner\Documents/R/win-library/2.11'
Error: unexpected string constant in "  argument 'lib'"
> Warning: package 'quantstrat' is in use and will not be installed
Error: unexpected string constant in "Warning: package 'quantstrat'"


This package works with 32-bit and so I had installed a 32-bit before. Can
anyone help pls? Update Package did not help either.

Thx
-- 
'Raghu'

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] reading dates in Excel into R

2010-07-29 Thread Hongying Li

I am reading dates in Excel2007 into R.

Here are the functions I used:

library(RODBC)
channel<-odbcConnectExcel2007("myfile.xlsx")
tmp<-sqlFetch(channel,"1",as.is=T)


The dates in myfile.xlsx are all in this format: mm/dd/. But when I read it 
to R, some columns look like "-mm-dd 00:00:00", some columns look like 
"-mm-dd", and some columns are numbers. I do not know how I can control 
this.

 

Any help? Thanks!

 
  
_
Hotmail is redefining busy with tools for the New Busy. Get more from your 
inbox.

N:WL:en-US:WM_HMP:042010_2
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Reset R environment through R command

2010-07-29 Thread Stefan Grosse
Am Donnerstag, den 29.07.2010, 13:22 -0400 schrieb Ralf B:
> Is it possible to remove all variables in the current environment
> through a R command.
> 
> Can one do that in R?

see
?rm

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R and WinBUGS (via R2WinBUGS) error

2010-07-29 Thread Uwe Ligges

Since this requert seems to be unanswered so far:



On 19.07.2010 23:34, YL Grize wrote:

Hi
I have got the same error than you


Who? This is a mailing list with thousands of readers ...



had, calling BUGS from R with the
bugs() function:


/ Error in FUN(X[[1L]], ...) :

/>/.C(..): 'type' must be "real" for this format/

but couldn't find the answer on the R help site.


Which R help site?



Could you please give me a hint? Could you solve it?
( i am simply trying to reproduce the example in Gelman's book on
multilevels models)


Could you specify that example, please? Which book exactly? Which page? 
Is there any URL where we can get the example from? I really do not want 
to walk into the library in order to solve your problems.



Best,
Uwe Ligges




Thanks for any help.

Best regards
Yves
yl.gr...@gmx.ch

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Colour points in plot according to third variable

2010-07-29 Thread Anna Berthinussen

Hi,

I am using the plot function to make a simple plot of my data with one  
variable against another and want to colour the data points according  
to a third variable. The third variable is continuous (Time) and I  
want to try two different ways of colouring the data points, either:


Divide time it into three groups and then colour each data point  
accordingly eg. 30-60 minutes in green, 60-90 minutes in red and  
90-120 minutes in blue..


or,

Colour the data points using a colour gradient eg. with increasing  
colour intensity as time increases..


I think I need to be able to do it within the plot() function as I  
have lines fitted from a model which I will also add to the graph.


Any suggestions would be greatly appreciated??

Thanks in advance

Anna

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] fix()ing an S4 method

2010-07-29 Thread Uwe Ligges
No, I'd recommend to work with the sources directly, or if you really 
want to do it from command line, you can access with ?getMethod


Uwe Ligges

On 21.07.2010 14:36, Albert-Jan Roskam wrote:

Hi R experts,

The fix() function canbe used to edit normal functions. I would like to know 
whether it's also possible to use something similar to edit a method of an S4 
class. In other words, is there a fix-like function that allows me to edit 
method definitions without having to go back to the source code?

setGeneric (name="doStuff",def = function(object){standardGeneric("doStuff")})
setClass("SomeClass", representation(text = "character"))
setMethod(f = "doStuff", signature ("SomeClass"), definition = function(object){
 return(print(paste("***", obj...@text)))  })
fix(doStuff) # Does NOT give the intended result. How can I make R show the 
method definition?

Cheers!!
Albert-Jan

~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the Romans ever done for us?
~~



[[alternative HTML version deleted]]




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Colour points in plot according to third variable

2010-07-29 Thread Henrique Dallazuanna
Try this:

library(RColorBrewer)
plot(iris$Sepal.Length,
 col = as.character(cut(iris$Sepal.Length, c(4,6,7,8), labels =
brewer.pal(3, 'Blues'



On Thu, Jul 29, 2010 at 2:51 PM, Anna Berthinussen wrote:

> Hi,
>
> I am using the plot function to make a simple plot of my data with one
> variable against another and want to colour the data points according to a
> third variable. The third variable is continuous (Time) and I want to try
> two different ways of colouring the data points, either:
>
> Divide time it into three groups and then colour each data point
> accordingly eg. 30-60 minutes in green, 60-90 minutes in red and 90-120
> minutes in blue..
>
> or,
>
> Colour the data points using a colour gradient eg. with increasing colour
> intensity as time increases..
>
> I think I need to be able to do it within the plot() function as I have
> lines fitted from a model which I will also add to the graph.
>
> Any suggestions would be greatly appreciated??
>
> Thanks in advance
>
> Anna
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installing a newer version of a package - problems

2010-07-29 Thread Duncan Murdoch

On 29/07/2010 8:43 AM, Raghu wrote:

Hi

I am trying to install the latest version of the package quantstrat but I
get the following error:

install.packages("quantstrat", repos="http://R-Forge.R-project.org";)
Warning in install.packages("quantstrat", repos = "
http://R-Forge.R-project.org";) :
  argument 'lib' is missing: using
'C:\Users\Owner\Documents/R/win-library/2.11'
Warning: package 'quantstrat' is in use and will not be installed
  


Start a new session of R that doesn't load quantstrat.  Then the above 
warning should go away.

> Warning in install.packages("quantstrat", repos = "
http://R-Forge.R-project.org";) :
Error: unexpected 'in' in "Warning in"
  


This is bizarre:  you are attempting to execute the warning message.  
What front end are you using?


Duncan Murdoch


>   argument 'lib' is missing: using
'C:\Users\Owner\Documents/R/win-library/2.11'
Error: unexpected string constant in "  argument 'lib'"
> Warning: package 'quantstrat' is in use and will not be installed
Error: unexpected string constant in "Warning: package 'quantstrat'"


This package works with 32-bit and so I had installed a 32-bit before. Can
anyone help pls? Update Package did not help either.

Thx



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread sammyny

newton.method is in package 'animation'. 

Thanks Ravi.
BBSolve/BBOptim seems to work very well although I am not familiar with the
optimization methods being used there. Is there a way to specify a tolerance
in the function to get the required precision.

I did something like this to use newton method.
require(animation)
newton.method(f, init=2, tol=10*exp(-8))
But it gives bogus results.

If someone could point me a correct working version of newton method for
finding roots and its usage, that would be helpful.

cheers,

Sam



-- 
View this message in context: 
http://r.789695.n4.nabble.com/newton-method-tp2306111p2306895.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] adding new devices and plots

2010-07-29 Thread Erin Hodgess
Dear R People:

I have the following function:

> eplot
function (x)
{
plot(x)
z <- locator(2)
dev.new()
plot(window(x, start = min(z$x), end = max(z$x)))
}
>

I want to generate a new plot from a subset of the original, but I
want to keep the original plot up.  When I use this, it opens a new
window, but the first device goes blank.

Is there a way around this, please?

Thank you!
Sincerely,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] KLdiv question

2010-07-29 Thread Ralf B
I am having a data set that causes flexmix::KLdiv to produce NA as a
result and I was told that increasing the sensitivity of the 'esp'
value can be used to avoid a lot of values being set to a default
(which presumably causes the problem).

Now here my question.

When running KLdiv on a normal distribution:

a <- rnorm(5)
b <- rnorm(5)
mydata <- cbind(a,b)
KLdiv(mydata, esp=1e-4)
KLdiv(mydata, esp=1e-5)
KLdiv(mydata, esp=1e-6)
KLdiv(mydata, esp=1e-7)
KLdiv(mydata, esp=1e-8)
KLdiv(mydata, esp=1e-9)
KLdiv(mydata, esp=1e-10)
KLdiv(mydata, esp=1e-100)

the result is stable independent from the chosen esp accuracy.
However, when I run the data on a distribution such as values in a
given range, I get NA and the method seems not to work independently
of how high I choose the accuracy.


y1 <- sample(1:1280, 20, replace=T)
y2 <- sample(1:1280, 20, replace=T)
mydata2 <- cbind(y1,y2)
KLdiv(mydata2, esp=1e-4)
KLdiv(mydata2, esp=1e-5)
KLdiv(mydata2, esp=1e-6)
KLdiv(mydata2, esp=1e-7)
KLdiv(mydata2, esp=1e-8)
KLdiv(mydata2, esp=1e-9)
KLdiv(mydata2, esp=1e-10)
KLdiv(mydata2, esp=1e-100)

Am I doing something wrong here? Does KL have any distributional
assumptions that I violate?

Best,
Ralf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fry Plots

2010-07-29 Thread bbolker
[cc'ing back to r-help]

At this point it sounds like you may need to poke around some more on your  
own -- I'm guessing
you're not familiar with R. Reading through the various documentation on  
these packages (try
help(package=...) to see if there is a vignette too) and/or  
the "Introduction to R" to get
acquainted with R more generally is probably a good idea. You need to  
figure out how to
create an object of the same class produced by randFRY() ...

On Jul 29, 2010 2:10pm, cassandra browne   
wrote:

> Thank you so much! One more, i think. So I got this lovely little piece,  
> and I put it in R, and it produced plots.
> Where do I put my x and y values though? And if I change the number of  
> points, does anything else change in the code?


> Thank you for helping me, really.



> Cassie

> ExamplesRDAT = randFRY(400, LIM=c(0,0, 200, 200) , rlen=5 )
> length(RDAT$x)
> plot(RDAT$x, RDAT$y, asp=1, pch=".", cex=2)

> u = par( no.readonly = TRUE)


> par(mfrow=c(3,2))
> shr = 0.0
> simpleshear = matrix(c(1, shr, 0, 1), ncol=2)

> Showfry(RDAT, simpleshear, 75)
> shr = 1.2
> simpleshear = matrix(c(1, shr, 0, 1), ncol=2)

> Showfry(RDAT, simpleshear, 75)

> epsilon1 = 0.4
> H = matrix(c(1+epsilon1, 0, 0, 1/(1+epsilon1) ), ncol=2)

> Showfry(RDAT, H, 75)

> par(u)



> > To: r-h...@stat.math.ethz.ch
> > From: bbol...@gmail.com
> > Date: Thu, 29 Jul 2010 17:16:09 +
> > Subject: Re: [R] Fry Plots
> >
> > cassandra browne hotmail.com> writes:
> >
> > >
> > >
> > > Does anyone know how to do a fry plot in R? I have 600-800 points per  
> image,
> > and I really don't want to attempt
> > > that manually.
> > >
> > > Thank you!
> > > Cassie
> >
> > library(sos) ## you'll have to install this first
> > findFn("fry plot")
> >
> > finds useful stuff in the geophys and spatstat packages
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide  
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] looking for setdiff equivalent on dataset

2010-07-29 Thread BaKaLeGuM
Hi everybody !

little question.

I have 2 dataset

TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))

And I would like to obtain the TheBigOne - TheLittleOne (the row in
TheBigOne not in TheLittleOne

The result should be:
cbind(c(1,1),c(1,1))


Have you any idea?




PS : this function work.. but too slow and too much complex!..

diff2data<-function(data1,data2){
afaire<-setdiff(paste(data1[,1],data1[,2]),paste(data2[,1],data2[,2]))
afaire<-data.frame(t(data.frame(strsplit(afaire," "
if (sum(dim(afaire))
!=0){afaire[,1]<-as.numeric(as.character(afaire[,1]));afaire[,2]<-as.numeric(as.character(afaire[,2]))}
return(afaire)}

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] package xpose4 in Vista - Update

2010-07-29 Thread Uwe Ligges
The binary package you downloaded is a binary for R < 2.11.x. Since it 
is a package bndle, it cannot work on R-2.11.x anymore: Package bundles 
are no longer supported.


Best,
Uwe Ligges


On 29.07.2010 02:11, Santosh wrote:

Dear R experts,

There seems to be a problem (please see the error messages below) with the
installation of the latest version of xpose4 (version 4.2.1) with the latest
R version.(2.11.1)... I didn't face such installation problems when using
version R.2.10.1

Would really appreciate your assistance in debugging installation of xpose
4..2.1 with R.2.11.1

Thanks again..
-Santosh

On Wed, Jul 28, 2010 at 12:46 PM, Santosh  wrote:


Dear R experts...
I would really appreciate your suggestions in installing a package in
Windows Vista...

I am unable to install a package on a windows vista based computer, in
spite of running it as an administrator. The package "xpose4.2.1" is
available from "
https://sourceforge.net/projects/xpose/files/Xpose4/Xpose_4.2.1/xpose4_4.2.1_win32.zip/download
"

Following is the error message when I try to install the package from the
Rgui command line...
I get similar errors when I try to install the packages from Rgui
("Packages | Install packages from local zip files") menu, but with default
lib="C:/Users/santosh/Documents/R/win-library/2.11"
.___



install.packages("C:/Users/santosh/Downloads/xpose4_4.2.1_win32.zip",repos=NULL,lib="C:/Program
Files/R/R-2.11.1/library")
Error in gzfile(file, "r") : cannot open the connection
In addition: Warning message:
In gzfile(file, "r") :
   cannot open compressed file 'xpose4_4.2.1_win32/DESCRIPTION', probable
reason 'No such file or directory'






However, I see "file" folder in which the library related folders
are installed, and contains different xpose4 related folders..

Thanks again,
Santosh







[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Different decimal places in a matrix

2010-07-29 Thread Ted Harding
On 29-Jul-10 09:25:37, Ted Harding wrote:
> On 29-Jul-10 09:08:22, Nicola Sturaro Sommacal wrote:
>> Hi!
>> I have a ftable object in which some row contains integers and
>> some other contains a percentage that I would like to show with
>> two digits after the dot.
>> 
>> I tried something like
>> ftblP[index,] = as.character(round(ftblP[index,],2))
>> where the index vector contains the number of the rows containing a
>> percentage. My workaround works but it shows all numbers aligned to
>> left, while I prefer that number will be aligned "correctly" (to
>> the right).
>> 
>> It is possible?
>> 
>> Thanks in advance.
>> Nicola S.
> 
> Interesting question! I take it you want to see something like
> 
>   49  21 166
>   12.216.75   49.65
> 
> The "raw" approach I would suggest is to "pack" the integers
> on the right with 3 blanks. I think it should be possible to
> do this with sprintf(). using different 'fmt' specifications
> for the "integer" rows and the "percentage" rows, and using
> cat() to output the results. However, I don't have time right
> now to explore the details of how it might be done. Sorry.
> 
> Ted.

Well, I've got something to work along the lines I suggested.
Example:


N <- c(21,33,145,18,102)   # Integers
P <- 100*N/sum(N)  # Percebtages

## [A]: decimal alignment
cat(rbind(paste(c(sprintf("%4.0f ",N),"\n"),collapse=""),
  paste(c(sprintf("%6.2f   ",P),"\n"),collapse="")))
## Result:
#21   33  145   18  102
# 6.5810.3445.45 5.6431.97


## [B]: right-justified alignment
cat(rbind(paste(c(sprintf("%7.0f  ",N),"\n"),collapse=""),
  paste(c(sprintf("%6.2f   ",P),"\n"),collapse="")))
## Result:
#  21   33  145   18  102
#6.5810.3445.45 5.6431.97


I'm sure there's someone who can improve on this!
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 29-Jul-10   Time: 19:48:18
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Hadley Wickham
Here's one way, using a function from the plyr package:

TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))

keys <- plyr:::join.keys(TheBigOne, TheLittleOne)

!(keys$x %in% keys$y)

TheBigOne[!(keys$x %in% keys$y), ]

Hadley

On Thu, Jul 29, 2010 at 1:38 PM, BaKaLeGuM  wrote:
> Hi everybody !
>
> little question.
>
> I have 2 dataset
>
> TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
> TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))
>
> And I would like to obtain the TheBigOne - TheLittleOne (the row in
> TheBigOne not in TheLittleOne
>
> The result should be:
> cbind(c(1,1),c(1,1))
>
>
> Have you any idea?
>
>
>
>
> PS : this function work.. but too slow and too much complex!..
>
> diff2data<-function(data1,data2){
> afaire<-setdiff(paste(data1[,1],data1[,2]),paste(data2[,1],data2[,2]))
> afaire<-data.frame(t(data.frame(strsplit(afaire," "
> if (sum(dim(afaire))
> !=0){afaire[,1]<-as.numeric(as.character(afaire[,1]));afaire[,2]<-as.numeric(as.character(afaire[,2]))}
> return(afaire)}
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Bert Gunter
Well, here's one way that "might" work (explanation below):

The ideas is to turn each row into a character vector and then work with the
two character vectors.

> bigs <- do.call(paste,TheBigOne)
> ix <-  which(bigs %in% setdiff(bigs,do.call(paste,TheLittleOne)))
> TheBigOne[ix,]

However, this may not work if the data frame contain calculated numeric
values which theoretically (infinite precision) are equal but are not
exactly due to finite precision. For example, try:

> 0 %in% pi/2

If this is what you have, then you have to do something fancier working
directly with the numeric values.

 Bert Gunter
Genentech Nonclinical Biostatistics





On Thu, Jul 29, 2010 at 11:38 AM, BaKaLeGuM  wrote:

> Hi everybody !
>
> little question.
>
> I have 2 dataset
>
> TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
> TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))
>
> And I would like to obtain the TheBigOne - TheLittleOne (the row in
> TheBigOne not in TheLittleOne
>
> The result should be:
> cbind(c(1,1),c(1,1))
>
>
> Have you any idea?
>
>
>
>
> PS : this function work.. but too slow and too much complex!..
>
> diff2data<-function(data1,data2){
> afaire<-setdiff(paste(data1[,1],data1[,2]),paste(data2[,1],data2[,2]))
> afaire<-data.frame(t(data.frame(strsplit(afaire," "
> if (sum(dim(afaire))
>
> !=0){afaire[,1]<-as.numeric(as.character(afaire[,1]));afaire[,2]<-as.numeric(as.character(afaire[,2]))}
> return(afaire)}
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread BaKaLeGuM
perfect !

thx


( I found prob::setdiff too.. but not really what i want)


2010/7/29 Hadley Wickham 

> Here's one way, using a function from the plyr package:
>
> TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
> TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))
>
> keys <- plyr:::join.keys(TheBigOne, TheLittleOne)
>
> !(keys$x %in% keys$y)
>
> TheBigOne[!(keys$x %in% keys$y), ]
>
> Hadley
>
> On Thu, Jul 29, 2010 at 1:38 PM, BaKaLeGuM  wrote:
> > Hi everybody !
> >
> > little question.
> >
> > I have 2 dataset
> >
> > TheLittleOne<-data.frame(cbind(c(2,3),c(2,3)))
> > TheBigOne<-data.frame(cbind(c(1,1,2),c(1,1,2)))
> >
> > And I would like to obtain the TheBigOne - TheLittleOne (the row in
> > TheBigOne not in TheLittleOne
> >
> > The result should be:
> > cbind(c(1,1),c(1,1))
> >
> >
> > Have you any idea?
> >
> >
> >
> >
> > PS : this function work.. but too slow and too much complex!..
> >
> > diff2data<-function(data1,data2){
> > afaire<-setdiff(paste(data1[,1],data1[,2]),paste(data2[,1],data2[,2]))
> > afaire<-data.frame(t(data.frame(strsplit(afaire," "
> > if (sum(dim(afaire))
> >
> !=0){afaire[,1]<-as.numeric(as.character(afaire[,1]));afaire[,2]<-as.numeric(as.character(afaire[,2]))}
> > return(afaire)}
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Residuals of mixed effects model

2010-07-29 Thread ONKELINX, Thierry
Dear Will,

residuals() should take both the fixed and random effects into account.
Can you give us a reproducible example if you get something different?

Use residuals(model, type = "normalized") if you also want to account
for the correlation structure.

What do you want to do with the residuals? Model them? In that case I
would suggest that you model the response variable directly. Note that
the parameter estimates of the random effects and the correlation
structure can (will) change if you add variables to the model.

Best regards,

Thierry

PS Use the mixed models list for this kind of questions about mixed
models.



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
  

> -Oorspronkelijk bericht-
> Van: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens will.ea...@gmx.net
> Verzonden: donderdag 29 juli 2010 16:07
> Aan: r-help@r-project.org
> Onderwerp: [R] Residuals of mixed effects model
> 
> Dear all,
> 
> how do I get the residuals from a lme() output objects which 
> are adjusted for fixed AND (!) random effects?
> 
> I tried residuals(), but it seems they just give me the 
> residuals adjusted for the fixed effects of the regression model.
> 
> The model I use is:
> lme.out <- lme(data=MyDataInLongFormat,fixed= outcome~1, 
> random= ~ 1|individual, correlation=corSymm(form = ~time|individual))
> 
> Actually, I use only the intercept in the fixed part of the 
> predictor, and I want to get residuals which are adjusted for 
> the fixed part (intercept) and the random effect, ie to get 
> rid of the correlatedness of individual measures across time. 
> This way I want to get data where I can treat the measures 
> per time point as independent groups. Makes sense?
> 
> Thanks in advance,
> 
> Will
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread Berend Hasselman


sammyny wrote:
> 
> 
> If someone could point me a correct working version of newton method for
> finding roots and its usage, that would be helpful.
> 

You mentioned in your original post that you had no idea how to use nleqslv.
nleqslv provides a Broyden and Newton method with several different global
search  strategies for "difficult" functions.

Here it is an example using your function (which is not particulary
difficult if you look at the plot):

library(nleqslv)

# starting value -2
nleqslv(-2,f)

# starting value 8
nleqslv(8,f)

# manual multistart
for( x in seq(-3,8,1)) { z <- nleqslv(x,f); print(c(z$x,z$fvec))}

These example all use the Broyden method.

If you want the Newton method then you can do

for( x in seq(-3,8,1)) { z <- nleqslv(x,f,method="Newton");
print(c(z$x,z$fvec))}


/Berend
-- 
View this message in context: 
http://r.789695.n4.nabble.com/newton-method-tp2306111p2306973.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Odp: Fwd: duplicates

2010-07-29 Thread Petr PIKAL
Hi

rather complicated one liner assuming your data frame has name test

do.call(rbind,lapply(split(test,test$var1), function(x) 
x[which.max(x[,"var2"]),]))

Here it is in 3 lines

test.s <- split(test,test$var1) # splits data frame
result <- lapply(test.s, function(x) x[which.max(x[,"var2"]),]) # chose 
maximum value from var2 and selects corresponding row
do.call(rbind, result) # put evereything into one data frame again

There could be issues if you had NA values in var1 or var2

Regards
Petr



r-help-boun...@r-project.org napsal dne 29.07.2010 16:31:06:

> 
> 
> -- Eredeti ĂĽzenet --
> Feladó: Dévaványai Agamemnón 
CĂ­mzett: r-
> h...@r-project.org, r-...@r-project.orgelkĂĽldve: 2010. jĂşlius 29. 
16:29Tárgy
> : duplicates
> 
>  Sorry!
> I try it again
> 
> Dear R Users!
> 
> 
> I have a dataframe with duplicatecases. Var1 duplicated by var2. 
> 
> 
> 
>  var1 var2  var3  var4  var5
> 14   500 12
>  13   200 25
>  18   125 19
>  22   120 252
>  2622  120
> 29400122
> 3110028
> 32200540
>  4820  160
> 
> I want to delete duplicate ones from var1 which have low rank at var2, 
and 
> keep that case which has highest rank at var2. I would like to keep the 
Whole 
> row (with the other variables: 
> 
> var1 var2 var3var4var5 
> 1  8  125 1 9
> 2  9   400122
> 3  2   20050 40
> 4   8  200 1  60
> 
>  Thanks Ag
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] multiple graphics windows open

2010-07-29 Thread Erin Hodgess
Dear R People:

Now I have a function with 3 graphics windows.  I'd like for them all
to be visible.  However, the first window goes blank.  Here is the
basic setup.  The first plot is the entire series.  The user selects
two points, which in turns generates a subset plot and an EWMA subset
plot.  Finally, if things worked right, the user should be able to
click on "Tile Vertically" and see all 3 windows.  Also, there should
be a line segment on the original plot connecting the two selected
points.

> library(zoo)
> xdate <- seq(as.Date("1998-01-01"),as.Date("2010-06-30"),by="day")
> length(xdate)
[1] 4564
> xt <- zoo(rnorm(4564),order=xdate)
> eplot
function (x)
{
x11()
plot(x)
z <- locator(2)
x11()
plot(window(x, start = min(z$x), end = max(z$x)))
 dev.set(dev.prev())
segments(z$x[1],z$y[1],z$x[2],z$y[2],col="red")
dev.set(dev.next())
x11()
ewma(window(x, start = min(z$x), end = max(z$x)))
dev.set(dev.prev())
return(z)
}
> eplot(xt)
$x
[1]  9400.369 11592.073

$y
[1] 3.641633 3.353061

>

How do I get that original plot to appear without losing any of the
other plots, please?

Thanks,
Erin

-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] newton.method

2010-07-29 Thread Yihui Xie
The function newton.method() in the package 'animation' is merely for
demonstration purpose instead of serious computation -- it illustrates
how Newton's method works step by step. But I'm unable to reproduce
your bogus results:

library(animation)
par(pch = 20)
ani.options(nmax = 50, interval = 0.5)
newton.method(f, init = 2, tol = 10 * exp(-8))
# $root
# [1] 7.419378
#
# $value
# [1] 1.211038e-07
#
# $iter
# [1] 17

ani.options(nmax = 50)
newton.method(f, init = -1, rg = c(-4, 12))$root
# about -2.44

ani.options(nmax = 50)
newton.method(f, init = 4, rg = c(-4, 12))$root
# 7.42


Regards,
Yihui
--
Yihui Xie 
Phone: 515-294-6609 Web: http://yihui.name
Department of Statistics, Iowa State University
3211 Snedecor Hall, Ames, IA



On Thu, Jul 29, 2010 at 1:15 PM, sammyny  wrote:
>
> newton.method is in package 'animation'.
>
> Thanks Ravi.
> BBSolve/BBOptim seems to work very well although I am not familiar with the
> optimization methods being used there. Is there a way to specify a tolerance
> in the function to get the required precision.
>
> I did something like this to use newton method.
> require(animation)
> newton.method(f, init=2, tol=10*exp(-8))
> But it gives bogus results.
>
> If someone could point me a correct working version of newton method for
> finding roots and its usage, that would be helpful.
>
> cheers,
>
> Sam
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/newton-method-tp2306111p2306895.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Meaning of proc.time()

2010-07-29 Thread Christofer Bogaso
Ok, but what are "user CPU" and "system CPU?" If I know corrrectly, I
only have a single CPU in my system. It is not a multi-corer system.
Should I read that, system CPU time is the time that my CPU took for
actual calculation, and the user CPU time is the time that my CPU took
to analyze my code that I have written in the console?

On Tue, Jul 27, 2010 at 4:12 PM, jim holtman  wrote:
> This is reporting on the accumulated values of the user CPU, system
> CPU and elapsed time.  The 'user + system' values indicate how much
> CPU has been used to process whatever has occurred in the R session so
> far.  To get the time to execute a statement, or block of code, you
> can use 'system.time' or take the difference in two values of
> proc.time:
>
>> a <- proc.time()
>> for(i in 1:1e6) x <- 1
>> proc.time() - a  # elapsed
>   user  system elapsed
>   0.38    0.05   42.48
>>
>
> Here is some stuff I typed in at the console.  It took me 42 seconds
> (elapsed or wall clock time) to type in the commands to the GUI.  I
> executed a simple 'for' loop for 1,000,000 iteration and this required
> 0.43 CPU seconds (user + system).
>
>> a <- proc.time()
>> for(i in 1:1e7) x <- 1
>> proc.time() - a  # elapsed
>   user  system elapsed
>   3.33    0.03   18.14
>>
>
> Notice that I executed the 'for' loop 10,000,000 times and the CPU
> time is now 3.36 seconds, or about 10X more than the first one which
> is about what you would expect.   This is a common way of determining
> what portions of your script are taking the most resource.
>
> HTH
>
> On Tue, Jul 27, 2010 at 4:03 AM, Christofer Bogaso
>  wrote:
>> If I run proc.time() function, I would get following:
>>
>>> proc.time()
>>    user  system elapsed
>>    2.82    4.18  792.39
>>
>> However I am struggling the meaning of the object what it returned. In
>> help file it says that:
>>
>> "user time" is the time required to execute the calling process. Here
>> what is the calling process exactly? Who executes this? system itself?
>>
>> 2ndly "system time" is the time required by the system for execution
>> of something.. what execution? What is the meaning of " on
>> behalf of the
>>  calling process?"
>>
>> 3rdly what is elapsed time? Total time I spent on current session,
>> since I opened the R window?
>>
>> Really sorry if I asked trivial questions, however honestly I could
>> not understand those. Some helpful comments are highly appreciated.
>>
>> Thanks,
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Detecting seasonality

2010-07-29 Thread Jannis
Your question is really vague and it is hard to guess what you are 
after. And the possible answer is that a huge variety of methods exist, 
all designed for specific questions (that you did not specify). How 
about fourier transform?


?fft()

Or SSA?

library(simssalabim)

Or the Hewitt test?


I would advice you to read some introductory text on time series 
analysis and try to get a clearer picture of your problem. And then 
decide for a technique and chances are high that it is implemented in R



Jannis

vikrant schrieb:

I have a hourly time series and I am interested in finding presence of
seasonality in this data. I know one method of finding seasonality using
autocorrelation function(ACF). But I dont want to use any graphical
technique. I want to know is there any theorotical method using R which can
be helpful ? Also the method should give  period of seasonality.

Thanks, 
Vikrant




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Colour points in plot according to third variable

2010-07-29 Thread Jannis

check out the Plotrix package and the color.scale() or similar functions.

Henrique Dallazuanna schrieb:

Try this:

library(RColorBrewer)
plot(iris$Sepal.Length,
 col = as.character(cut(iris$Sepal.Length, c(4,6,7,8), labels =
brewer.pal(3, 'Blues'



On Thu, Jul 29, 2010 at 2:51 PM, Anna Berthinussen wrote:

  

Hi,

I am using the plot function to make a simple plot of my data with one
variable against another and want to colour the data points according to a
third variable. The third variable is continuous (Time) and I want to try
two different ways of colouring the data points, either:

Divide time it into three groups and then colour each data point
accordingly eg. 30-60 minutes in green, 60-90 minutes in red and 90-120
minutes in blue..

or,

Colour the data points using a colour gradient eg. with increasing colour
intensity as time increases..

I think I need to be able to do it within the plot() function as I have
lines fitted from a model which I will also add to the graph.

Any suggestions would be greatly appreciated??

Thanks in advance

Anna

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






  



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Beginner stucked with raster + geoR package.

2010-07-29 Thread Alaios


I would like to thank you for your kindness to help me.
But I am not sure if
temp <- grf(ncell(r), cov.pars=c(1, .25)) is correct as this will create around 
64.000 locations (not sure what the parameter location is in grf package).

Unfortunately it seems that I have a more serious problem when I try to load 
RandomFields package.


1. Error in dyn.load(file, DLLpath = DLLpath, ...) :
2. unable to load shared library 
'/home/apa/R/x86_64-unknown-linux-gnu-library/2.11/RandomFields/libs/RandomFields.so':

3.  /usr/lib64/R/lib/libRlapack.so: undefined symbol: _gfortran_concat_string

I spend one hour in google for this but so far did not find anything.

You can find all the output I get during the installation of the package here
http://pastebin.com/apxPxnyd

Best Regards
Alex



>
>

From: Nikhil Kaza 

>Sent: Thu, July 29, 2010 1:29:52 AM
>Subject: Re: [R] Beginner stucked with raster + geoR package.
>
>
>
>I tried the following. Not sure if this is the right approach.
>
>require(RandomFields)
>r <- raster()
>> r <- setValues(r,1:ncell(r)/100)
>> temp <- grf(ncell(r), cov.pars=c(1, .25))
>> r <- setValues(r,temp$data)
>plot(r)
>
>
>Nikhil Kaza
>Asst. Professor,
>City and Regional Planning
>University of North Carolina
>
>nikhil.l...@gmail.com
>
>On Jul 28, 2010, at 6:53 PM, Alaios wrote:
>
>> Can someone help me please with step 5?
>> 
>> r <- setValues(r,temp) # Unfortunately this ends with the message: Error in
>> setValues(r, temp) : values must be a vector
>> 
>> How to make temp a vector?
>> 
>> 
>> 
>> 
>> 
>> To: r-help@r-project.org
>> Sent: Wed, July 28, 2010 3:55:54 PM
>> Subject: [R] Beginner stucked with raster + geoR package.
>> 
>> 
>> 
>> Hello everyone.
>> I am trying to build up understanding in R by trying to develop just some 
>>simple
>> 
>> scenarios.
>> 
>> I would like to explain you what I am trying to do and what I did so far.
>> 
>> I would like to put inside a RasterLayer (raster package) a Gaussian field 
>(for
>> given covariance) using  grf function (geoR package)
>> 
>> 1. First I created a Raster Layer object
>> r <- raster()  # Default values are ok
>> 2. Then I set some values to test how  if setValues worked
>> r <- setValues(r,1:ncell(r)/100) # Every cell of the RasterLayer takes as 
data
>> its cell number/100.
>> 3.  Tested that 2 works with
>> getValuesBlock(r,1,nrow(r),1,ncol(r))
>> 4. Then I tried to generate a Gaussian random field for given covariance
>> parameters using grf.
>> temp <- grf(1,nx=nrow(r),ny=ncol(r), cov.pars=c(1, .25)) # Note: The first 
>>input
>> 
>> parameter in grf is locations. At first I tried nrow(r)*ncol(y) but I got the
>> ouput that this will produce 15,5 Gb of data :(. I just wanted to created a 
>x*y
>> array of this data. Then I tried to pass the nrow(r) and ncol(r) to the nx 
and
>> ny arguments. Now this seems ok to me.
>> 5. Final step is to set the values created in 4th step to the RasterLayer 
>>object
>> 
>> that was created at first step.
>> r <- setValues(r,temp) # Unfortunately this ends with the message: Error in
>> setValues(r, temp) : values must be a vector
>> 
>> and at this point I am completely stuck :(
>> 
>> I would like to request some of your kindness to help me unstuck
>> 
>> Best Regards
>> Alex.
>> 
>> 
>> 
>>[[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>> 
>> 
>> 
>> [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] duplicates

2010-07-29 Thread Jannis
There is most probably a function doing exactly this, but i would give 
this solution a try:



dataframe=dataframe[order(dataframe[,1],-dataframe[,2]),]

kept.rows<-which(diff(dataframe[,1])+1

new.dataframe <- dataframe[kept.rows,]

Dévaványai Agamemnón schrieb:

  Sorry!
I try it again

Dear R Users!


I have a dataframe with duplicatecases. Var1 duplicated by var2. 




var1 var2  var3  var4  var5
14   500 12
13   200 25
18   125 19
22   120 252
2622  120
29400122
3110028
32200540
4820  160

I want to delete duplicate ones from var1 which have low rank at var2, and keep that case which has highest rank at var2. I would like to keep the Whole row (with the other variables: 

var1 var2 var3var4var5
1  8  125 1 9

2  9   400122
3  2   20050 40
4   8  200 1  60 Thanks Ag 



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] locator function and connecting segment

2010-07-29 Thread Greg Snow
Do you mean like:

> plot(1:10)
> locator(2, type='l')



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Erin Hodgess
> Sent: Thursday, July 29, 2010 10:50 AM
> To: R help
> Subject: [R] locator function and connecting segment
> 
> Dear R People:
> 
> I'm using the locator() function on a chart and I select two values.
> 
> Is there a way already in place to connect the two values with a line
> segment, please?
> 
> Just thought I'd check before I started coding.
> 
> Thanks in advance,
> Sincerely,
> Erin
> 
> 
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] adding new devices and plots

2010-07-29 Thread Greg Snow
It is possible that the plot function starts to plot before the new device is 
fully in place, you could try sleeping for a second or 2 between the call to 
dev.new and the call to plot.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Erin Hodgess
> Sent: Thursday, July 29, 2010 12:16 PM
> To: R help
> Subject: [R] adding new devices and plots
> 
> Dear R People:
> 
> I have the following function:
> 
> > eplot
> function (x)
> {
> plot(x)
> z <- locator(2)
> dev.new()
> plot(window(x, start = min(z$x), end = max(z$x)))
> }
> >
> 
> I want to generate a new plot from a subset of the original, but I
> want to keep the original plot up.  When I use this, it opens a new
> window, but the first device goes blank.
> 
> Is there a way around this, please?
> 
> Thank you!
> Sincerely,
> Erin
> 
> 
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   >