Re: [R] changing Swaeve output settings for .pdf and .eps - is there a way?

2009-04-17 Thread cls59


markheckmann wrote:
 
 
 The pdf() settings do not affect Sweave settings when producing a .pdf
 graphic. How can I change the Sweave default settings to e.g. 3 inch?
 
 

Try setting the width and height options in the figure chunk:

fig1,echo=F,plot=T,pdf=T,width=5,height=3
plot(1:10
@

To make a certain set of dimensions the defaults, use \SweaveOpts:

\SweaveOpts{width=5,height=3}

-Charlie



-
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University
-- 
View this message in context: 
http://www.nabble.com/changing-Swaeve-output-settings-for-.pdf-and-.eps---is-there-a-way--tp23078496p23091546.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] question about the Text Mining package tm

2009-04-17 Thread onyourmark

Hello. I am trying to work with the text mining package tm.

I have a directory called textsTweet1 which contains three files
short.txt
myTextFile.txt
myTextFile.csv

short.txt contains one line: THE CAT IN THE HAT\n

myTextFile contains some tweets from Twitter. The first few lines of
myTextFile.txt are:

@oliviamunn I miss a good Yakaniku...I miss Japan...I NEED COCO EVERYBODY. I
NEED TO GET ON JAPAN TIME NOW. NO SLEEP!!!SAKURA at Niigata, Japan 
http://ff.im/-29ufG19:30 [BS Japan] 絶対可憐チルドレン #50 「一意奮闘!オーバー・ザ・フューチャー」RT@
kvsrinath Japan's New Flat Screens: The Eco-Friendly TV . 
http://is.gd/sIS7 #greenMold99 says: Introduction to Chiropractic and manual
therapeutics when unfit.Choice of schools in Japan, and mo... 
http://i.sitesays.com/lc7Japan Said to Sell 17 Trillion Yen of Extra Bonds -
Bloomberg 

Actually there were no new lines in the original file but I inserted a new
line before every occurrence of http.

I ran the following code:
library(tm)
my.path - 'C:\\dataForR\\textsTweet1\\'
my.path.csv-'C:\\dataForR\\textsTweet1\\myTextFile.csv'
(ovid - Corpus(DirSource(my.path), readerControl = list(reader = readPlain,
language = la)))

Response from R:
A text document collection with 3 text documents
Warning message:
In readLines(filename, encoding = encoding) :
  incomplete final line found on 'C:\dataForR\textsTweet1\/short.txt'

Then I ran the TermDocMatrix function. It is supposed to take a file and
more or less count the occurrences of each word in the file. Or as the
documentation says Constructs a term-document matrix

 tdm-TermDocMatrix(ovid)
 Data(tdm)[1:2, 105:107]
2 x 3 sparse Matrix of class dgCMatrix
  revealed said sakura
1..  .
2   15   15 15


 Data(tdm)[1:21, 100:105]
Error in intI(i, n = di[1], dn = dn[[1]]) : index larger than maximal 3

I don't understand why I am getting only two lines. I can see that the first
line is for the short.txt file
and the second line seems to be for the whole myTextFile.txt file.

How can I get TermDocMatrix to output each row of myTextFile.txt as a
separate row?

Thanks very much.
-- 
View this message in context: 
http://www.nabble.com/question-about-the-Text-Mining-package-tm-tp23091573p23091573.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] vertex ordering by date on a network diagram

2009-04-17 Thread fr510
Dear R helpers I am working with a csv file containing data about a 
citation graph. This csv file contains a column with an id of the paper 
containing the citation the next with the id of the paper being cited and 
the third the date of publication (dd/mm/). I can create a directed 
network with vertices distributed randomly but cant seem to order them so 
that the oldest publications lie at the top and get younger moving down the 
graph. Any help would be very much 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.


Re: [R] changing Swaeve output settings for .pdf and .eps - is there a way?

2009-04-17 Thread cameron.bracken



markheckmann wrote:
 
 The pdf() settings do not affect Sweave settings when producing a .pdf
 graphic. How can I change the Sweave default settings to e.g. 3 inch?
 

Also, even if you set the width of your plot to 3 inches, the plot will be
expanded to 80% of the textwidth by default.  To disable this (i.e you set
width=3 and your plot is actually 3 inches) use 

\usepackage[nogin]{Sweave}.
  
You will have to copy Sweave.sty to your local directory or to your texmf
directory for this to work. 

-- 
View this message in context: 
http://www.nabble.com/changing-Swaeve-output-settings-for-.pdf-and-.eps---is-there-a-way--tp23078496p23091931.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] [R-pkgs] Major bigmemory revision released.

2009-04-17 Thread Jay Emerson
The re-engineered bigmemory package is now available (Version 3.5
and above) on CRAN.  We strongly recommend you cease using
the older versions at this point.

bigmemory now offers completely platform-independent support for
the big.matrix class in shared memory and, optionally, as filebacked
matrices for larger-than-RAM applications.  We're working on updating
the package vignette, and a draft is available upon request (just send
me an email if you're interested).  The user interface is largely unchanged.

Feedback, bug reports, etc... are welcome.

Jay Emerson  Michael Kane

-- 
John W. Emerson (Jay)
Assistant Professor of Statistics
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-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.


Re: [R] Odp: splitting vector into equal sets

2009-04-17 Thread Petr PIKAL
utkarshsinghal utkarsh.sing...@global-analytics.com napsal dne 
16.04.2009 17:20:10:

 Hi Pikal,
 
 Thanks for your comments and apologies for not providing a clear 
example. But 
 you have completely ignored the small example I mentioned:

Well, this is not exactly an example. So let us clarify things a bit. You 
do not explain how to handle your vector at all.

One option
split(1:20, factor(1:3))

splits your vector to 3 groups. It recycles 1:3 so every third observation 
is put into one vector.
This function randomly samples a vector and gives you list with 3 almost 
equal groups and can be easily expanded to arbitrary number of groups.

function(x) {
x1-sample(x, ceiling(length(x)/3))
x.-x[-x1]
x2-sample(x., ceiling(length(x.)/2))
x3-x[-c(x2,x1)]
list(x1,x2,x3)
}

Here are two functions which compute how many members are in each group 
and how many are left.
 20%%3
[1] 2
 20%/%3
[1] 6

split(x, rep(letters[1:3], each=length(x)%/%3))
and this splits your vector to 3 portions and put last 2 values to the 
first vector.

I think I gave you some insights how to handle such problem.

 
 I want to split rnorm(20) into three equal groups.
 Note that here number of observations is not a multiple of number of 
groups. 
 For that I want an option where I can specify how to treat these extra 

which extra observations, first 2, last 2, arbitrary 2?

 observations, i.e.,  to put these observations into the 1st group or the 
last 
 group or one in each  group starting from 1st or starting from last

Only **you** know how exactly **you** want to handle it so **you** need to 
elaborate a function **yourself**. If the function shall split arbitrary 
length vector to arbitrary number of groups and put extra values to 
arbitrary groups it would not be a simple case and it would need a little 
bit of programming work.

 Also I dont want to calculate the number of observations going in each 
group beforehand.

You do not need to calculate it yourself. R will do it for you if you tell 
it.

Regards
Petr

 
 Regards
 Utkarsh
 
 
 Petr PIKAL wrote: 
 Hi
 
 r-help-boun...@r-project.org napsal dne 16.04.2009 15:23:15:
 
 
 Hi R,
 
 I have explored R archives a lot but couldn't find an efficient way of 
 doing the following:
 
 I want to split a vector into sets of equal sizes. Is there any inbuilt 
 function of doing so with the option of specifying how to treat the 
 remaining observations. For example: suppose I want to split 20 
 observations in 3 groups, then I also want the option to put the extra 
 two observations into the 1st group or the last group or one in each 
 group starting from 1st or starting from last.
 
 I have already tried the cut  the quantcut function but of no use.
 Any help will be appreciated. Note that I am looking for an R function 
 rather than lines of code.
 
 
 Did you try split?
 e.g.
 split(rnorm(12), rep(1:3,4))
 gives list with 3 vectors. Then you can use lapply, sapply or other list 

 functions to make some computation.
 
 Or I could be completely wrong what you really want as you did not 
provide 
 any example.
 
 Regards
 Petr
 
 
 
 Regards
 Utkarsh
 
 __
 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] Sourcecode documentation

2009-04-17 Thread _

Hi all,
I am searching for a tool or a package that can generate a documentation 
file e.g. html, txt  from
defined commands like params, function etc - a tool like javadoc but 
featuring R.

NaturalDocs support R but is a little bit to heavy for my needs.

Thank you.

__
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] rnorm() converted to daily

2009-04-17 Thread Ken-JP


yearly 8% drift, 25% sd

why are x and y so different (x and z look ok)?

Does this have something to do with biases due to the relationship between
population and sample-estimates as a function of n samples and sd?  Or am I
doing something wrong?

---

set.seed( 1 );
x - mean( rnorm( 10, mean=0.08, sd=0.25 ));
set.seed( 1 );
y - mean( rnorm( 10, mean=(0.08/252), sd=(0.25/sqrt(252)) )) * 252;
set.seed( 1 );
z - mean( rnorm( 10, mean=(0.08/252), sd=0.001 )) * 252;
# ---
x# 0.07943898
y# 0.07109407
z# 0.07943449



-- 
View this message in context: 
http://www.nabble.com/rnorm%28%29-converted-to-daily-tp23092444p23092444.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] Turning off warnings from cor.test

2009-04-17 Thread Daren Tan
I would like to turn off the warnings from cor.test while retaining
exact=NULL. Is that possible ?

 cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),  method = spearman)

Spearman's rank correlation rho

data:  c(1, 2, 3, 3, 4, 5) and c(1, 2, 3, 3, 4, 5)
S = 0, p-value  2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
  1

Warning message:
In cor.test.default(c(1, 2, 3, 3, 4, 5), c(1, 2, 3, 3, 4, 5), method =
spearman) :
  Cannot compute exact p-values with ties

__
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] Turning off warnings from cor.test

2009-04-17 Thread Dimitris Rizopoulos
check option 'warn' in the on-line help file of ?options(), e.g., you 
can use something like this:


op - options(warn = (-1)) # suppress warnings

cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),  method = spearman)

options(op) # reset the default value, if you want


I hope it helps.

Best,
Dimitris


Daren Tan wrote:

I would like to turn off the warnings from cor.test while retaining
exact=NULL. Is that possible ?


cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),  method = spearman)


Spearman's rank correlation rho

data:  c(1, 2, 3, 3, 4, 5) and c(1, 2, 3, 3, 4, 5)
S = 0, p-value  2.2e-16
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
  1

Warning message:
In cor.test.default(c(1, 2, 3, 3, 4, 5), c(1, 2, 3, 3, 4, 5), method =
spearman) :
  Cannot compute exact p-values with ties

__
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.



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
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] Linear model with interaction

2009-04-17 Thread Marian Thieme
Hi all,

I have a question about linear model with interaction:

I created a data frame df like this:

df
V1 V2 V3 V4 V5
1 6.414094  c  t  a  g
2 6.117286  t  a  g  t
3 5.756922  a  g  t  g
4 6.090402  g  t  g  t
...

which holds the response in the first column and letters (a,c,g,t) in the
other columns. I am interested to see if there are interactions between the
neigbouring letters so I have defined the following linear model:

lm-lm(df[,1] ~ (df[,2]:df[,3]) + (df[,3]:df[,4]) + (df[,4]:df[,5]) )

the result then looks like this:
Coefficients: (1 not defined because of singularities)
Estimate Std. Error t value Pr(|t|)
(Intercept)8.8987163  0.0211457 420.828   2e-16 ***
df[, 2]a:df[, 3]a   -0.1021543  0.0253486  -4.030 5.59e-05 ***
df[, 2]c:df[, 3]a0.0535562  0.0255685   2.095 0.036213 *
df[, 2]g:df[, 3]a0.0224073  0.0318965   0.703 0.482372
df[, 2]t:df[, 3]a0.0024165  0.0259862   0.093 0.925911
df[, 2]a:df[, 3]c0.0355502  0.0260197   1.366 0.171861
df[, 2]c:df[, 3]c0.0433014  0.0252535   1.715 0.086415 .
df[, 2]g:df[, 3]c0.147  0.0309441   4.758 1.97e-06 ***
df[, 2]t:df[, 3]c0.0613779  0.0270601   2.268 0.023323 *
df[, 2]a:df[, 3]g0.0646498  0.0299286   2.160 0.030770 *
df[, 2]c:df[, 3]g0.1302731  0.0359439   3.624 0.000290 ***
df[, 2]g:df[, 3]g0.1512754  0.0360951   4.191 2.78e-05 ***
df[, 2]t:df[, 3]g0.1084278  0.0339142   3.197 0.001389 **
df[, 2]a:df[, 3]t   -0.0249016  0.0262402  -0.949 0.342633
df[, 2]c:df[, 3]t0.0860302  0.0253518   3.393 0.000691 ***
df[, 2]g:df[, 3]t0.0241031  0.0358496   0.672 0.501372
df[, 2]t:df[, 3]t   NA NA  NA   NA
df[, 3]a:df[, 4]1   -0.0970149  0.0143730  -6.750 1.50e-11 ***
df[, 3]c:df[, 4]1   -0.0153732  0.0152519  -1.008 0.313486
df[, 3]g:df[, 4]1   -0.0706682  0.0225665  -3.132 0.001740 **
df[, 3]t:df[, 4]1   -0.0581889  0.0158485  -3.672 0.000241 ***
df[, 3]a:df[, 4]20.0485333  0.0150167   3.232 0.001231 **
df[, 3]c:df[, 4]2   -0.0790008  0.0150513  -5.249 1.54e-07 ***
df[, 3]g:df[, 4]20.0604465  0.0217557   2.778 0.005465 **
df[, 3]t:df[, 4]20.0232283  0.0167224   1.389 0.164826
df[, 3]a:df[, 4]30.0740046  0.0182221   4.061 4.89e-05 ***
df[, 3]c:df[, 4]30.0797502  0.0234485   3.401 0.000672 ***
df[, 3]g:df[, 4]30.0720160  0.0253456   2.841 0.004495 **
df[, 3]t:df[, 4]30.0778484  0.0221196   3.519 0.000433 ***
df[, 4]a:df[, 5]1   -0.0916618  0.0143707  -6.378 1.81e-10 ***
df[, 4]c:df[, 5]1   -0.0138048  0.0152609  -0.905 0.365691
df[, 4]g:df[, 5]1   -0.0700765  0.0225639  -3.106 0.001900 **
df[, 4]t:df[, 5]1   -0.0734513  0.0158534  -4.633 3.62e-06 ***
df[, 4]a:df[, 5]20.0438002  0.0150128   2.918 0.003531 **
df[, 4]c:df[, 5]2   -0.1107056  0.0150634  -7.349 2.04e-13 ***
df[, 4]g:df[, 5]20.0652739  0.0217520   3.001 0.002694 **
df[, 4]t:df[, 5]20.0219305  0.0167259   1.311 0.189811
df[, 4]a:df[, 5]30.0804106  0.0182290   4.411 1.03e-05 ***
df[, 4]c:df[, 5]30.0970780  0.0234745   4.135 3.55e-05 ***
df[, 4]g:df[, 5]30.0704516  0.0253372   2.781 0.005430 **
df[, 4]t:df[, 5]30.0911914  0.0221237   4.122 3.77e-05 ***



questions:
1.) What could be the reason that the lm function changes the names of the
interactions terms (after the first undefined coefficient)
from a:a, c:a, g:a, ... to a:1, c:1, g:1, ... and obviously omits direct
calculation of interaction terms of the form a:4, c:4, g:4, t:4 which
(if I correctly assume) correspond to a:t, c:t, g:t, t:t.

2.) How I have to correctly define a data frame new_df for a new sequence of
letters to get the predicted response by using the predict function, I tried
something like this:

new_df[2:5]=as.data.frame(t('g'))
new_df[1]=0
predict(lm, new_df)

and also the original data frame which was used to fit the model:
predict(lm, df[1,])

outputs all predicted values with respect to the previously fitted linear
model and gives Warning messages:
1: 'newdata' had 1 rows but variable(s) found have 7020 rows
2: In predict.lm(lm_pm, new_df) :
  prediction from a rank-deficient fit may be misleading

Thanks for any help,
Marian

[[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] there are fontencoding problem in Sweave

2009-04-17 Thread Угодай n/a
2009/4/17 Peter Dalgaard p.dalga...@biostat.ku.dk

 Doesn't \usepackage[noae]{Sweave} do the trick? Sweave.sty has this
 conditionalized.


Yes, it is working. Thanks

[[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] Sourcecode documentation

2009-04-17 Thread Romain Francois

_ wrote:

Hi all,
I am searching for a tool or a package that can generate a 
documentation file e.g. html, txt  from
defined commands like params, function etc - a tool like javadoc but 
featuring R.

NaturalDocs support R but is a little bit to heavy for my needs.

Thank you.

Google for roxygen

--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

__
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] Kruskal's MDS results

2009-04-17 Thread Dieter Vanderelst

A few people suggested taking a look at Ripley's book MASS. I know the formula 
listed there.

The point is that the manual for the isoMDS function says it's stress output is in 
percent. Does this mean, the stress reported by isoMDS is just the stress 
value in MASS (which ranges from 0 to 1) value multiplied by 100? I've haven't been able 
to find any resource that expresses stress in values from 0 to 100. So, this would be a 
convention introduced by the authors of the package?

In general, I think the R manuals could do with a bit more explaining on the 
output of the functions. I understand that some knowledge of statistics is 
assumed when working with R but sometimes the documentation on the returned 
values is really sparse. Even when familiar with the domain, there are several 
different conventions followed by different authors. This should be clear when 
reading the manual.

I know a lot of hard work gets into writing software, but it seems sometimes 
people are less keen on documenting their hard work properly.

stephen sefick wrote:

You can look in MASS 4 for this formula on page 308 .  Go to the
source and ask the horse he'll give you an answer that you endorse.

On Thu, Apr 16, 2009 at 8:13 AM, Bob Green bgr...@dyson.brisnet.org.au wrote:

Dieter,

You could always try the Classification, clustering, and phylogeny
estimation  list which often includes posts regarding MDS:
http://lists.sunysb.edu/index.cgi?A0=CLASS-L

regards

Bob

__
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] rnorm() converted to daily

2009-04-17 Thread Karl Ove Hufthammer
Ken-JP:

 Does this have something to do with biases due to the relationship between
 population and sample-estimates as a function of n samples and sd?  Or am
 I doing something wrong?
 
 ---
 
 set.seed( 1 );
 x - mean( rnorm( 10, mean=0.08, sd=0.25 ));
 set.seed( 1 );
 y - mean( rnorm( 10, mean=(0.08/252), sd=(0.25/sqrt(252)) )) * 252;
 set.seed( 1 );
 z - mean( rnorm( 10, mean=(0.08/252), sd=0.001 )) * 252;

Yes, you’re doing something wrong.

While it is true¹ that rnorm(n, a, b) will give the same results as
rnorm(n, 0, 1) * b + a, it is *not* true that the above calculations
would return the same numbers. That’s the reason the the means 
differ.

¹ True in practice, but not documented as far as I can see, so you
  should not depend on it.

-- 
Karl Ove Hufthammer

__
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] Turning off warnings from cor.test

2009-04-17 Thread Martin Maechler
 DR == Dimitris Rizopoulos d.rizopou...@erasmusmc.nl
 on Fri, 17 Apr 2009 09:44:49 +0200 writes:

DR check option 'warn' in the on-line help file of ?options(), e.g., you 
DR can use something like this:

DR op - options(warn = (-1)) # suppress warnings

DR cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),  method = spearman)

DR options(op) # reset the default value, if you want

[yes, do that!]

To make this more self-contained and error-proof, there
has been the function  suppressWarnings(.)  for several years now.
Hence, I'd strongly recommend

suppressWarnings( cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),
   method = spearman) )

instead of the above.
Regards,
Martin Maechler, ETH Zurich

DR I hope it helps.

DR Best,
DR Dimitris


DR Daren Tan wrote:
 I would like to turn off the warnings from cor.test while retaining
 exact=NULL. Is that possible ?
 
 cor.test(c(1,2,3,3,4,5), c(1,2,3,3,4,5),  method = spearman)
 
 Spearman's rank correlation rho
 
 data:  c(1, 2, 3, 3, 4, 5) and c(1, 2, 3, 3, 4, 5)
 S = 0, p-value  2.2e-16
 alternative hypothesis: true rho is not equal to 0
 sample estimates:
 rho
 1
 
 Warning message:
 In cor.test.default(c(1, 2, 3, 3, 4, 5), c(1, 2, 3, 3, 4, 5), method =
 spearman) :
 Cannot compute exact p-values with ties
 
 __
 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 -- 
DR Dimitris Rizopoulos
DR Assistant Professor
DR Department of Biostatistics
DR Erasmus University Medical Center

DR Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
DR Tel: +31/(0)10/7043478
DR Fax: +31/(0)10/7043014

DR __
DR R-help@r-project.org mailing list
DR https://stat.ethz.ch/mailman/listinfo/r-help
DR PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
DR 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] [R-pkgs] FD: R package to measure functional diversity indices

2009-04-17 Thread Etienne Laliberté
Dear useRs,

The FD package is intended for ecologists interested in functional
diversity (FD). It measures different functional diversity indices
from multiple traits (any type of traits). The first version of FD
(1.0-0) is now available on CRAN:

http://cran.r-project.org/web/packages/FD/

The main functions of FD are:

dbFD: Compute different multidimensional FD indices

gowdis: Gower dissimilarity, including options for variable weights,
asymetric binary variables, and implementing Podani's (1999) extension
to ordinal variables

fdisp: Functional dispersion

functcomp: Functional composition (community-weighted means ot trait
values, or CWM)

I hope that FD will be useful to you. Feedback would be appreciated.

Sincerely,

Etienne Laliberté

Rural Ecology Research Group
School of Forestry
University of Canterbury
Private Bag 4800
Christchurch 8140, New Zealand
Phone: +64 3 366 7001 ext. 8365
Fax: +64 3 364 2124
www.elaliberte.info

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-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.


Re: [R] rnorm() converted to daily

2009-04-17 Thread Ken-JP

Hi Karl,

Your comment is very interesting.  

Do you mean I should favor:

  rnorm(n, 0, 1) * b + a

over

  rnorm(n, a, b)

?  What is the proper/safe way to use rnorm()?



FWIW,

set.seed( 1 );
yy - mean( rnorm( 10 ) * (0.25/sqrt(252)) + (0.08/252)) * 252;
yy   # 0.07109407

still gives me what I had before (but I shouldn't depend on it being the
same, right)?



-- 
View this message in context: 
http://www.nabble.com/rnorm%28%29-converted-to-daily-tp23092444p23093334.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] rnorm() converted to daily

2009-04-17 Thread Meyners, Michael, LAUSANNE, AppliedMathematics
SD in y is more than 15 times (!!!) larger than in x and z,
respectively, and hence SD of the mean y is also larger. 100,000 values
are not enough to stabilize this. You could have obtained 0.09 or even
larger as well. Try y with different seeds, y varies much more than x
and z do. Or check the variances: 

var.x - var(replicate(100, mean( rnorm( 10, mean=0.08, sd=0.25 
var.y - var(replicate(100, mean( rnorm( 10, mean=(0.08/252),
sd=(0.25/sqrt(252)) )) * 252))
var.z - var(replicate(100, mean( rnorm( 10, mean=(0.08/252),
sd=0.001 )) * 252))

I guess what you are doing wrong is assuming that 0.25/sqrt(252) is
similar to 0.25/252, the latter being close so 0.001, while the former
is obviously not. Try to replace 0.25 in y by 0.0158, than you should be
close enough.

HTH, Michael

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Ken-JP
Sent: Freitag, 17. April 2009 09:26
To: r-help@r-project.org
Subject: [R] rnorm() converted to daily



yearly 8% drift, 25% sd

why are x and y so different (x and z look ok)?

Does this have something to do with biases due to the relationship
between population and sample-estimates as a function of n samples and
sd?  Or am I doing something wrong?

---

set.seed( 1 );
x - mean( rnorm( 10, mean=0.08, sd=0.25 )); set.seed( 1 ); y -
mean( rnorm( 10, mean=(0.08/252), sd=(0.25/sqrt(252)) )) * 252;
set.seed( 1 ); z - mean( rnorm( 10, mean=(0.08/252), sd=0.001 )) *
252; #
---
x# 0.07943898
y# 0.07109407
z# 0.07943449



--
View this message in context:
http://www.nabble.com/rnorm%28%29-converted-to-daily-tp23092444p23092444
.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.


[R] Manipulate single line in textfile

2009-04-17 Thread Guillaume Filteau

Hello all,

Is it possible to modify a single line in a textfile?

I know it is possible to load the whole text file, do the change, and  
save this as a new file. However, this is not practical in my case, 
because the document is huge and cannot be fully loaded in R.


Any idea?
Best,
Guillaume

__
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] rnorm() converted to daily

2009-04-17 Thread Karl Ove Hufthammer
Ken-JP:

 Do you mean I should favor:
 
 rnorm(n, 0, 1) * b + a
 
 over
 
 rnorm(n, a, b)

No, as I said, they give exactly the same results.

-- 
Karl Ove Hufthammer

__
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] Manipulate single line in textfile

2009-04-17 Thread Barry Rowlingson
On Fri, Apr 17, 2009 at 9:20 AM, Guillaume Filteau filt...@unc.edu wrote:
 Hello all,

 Is it possible to modify a single line in a textfile?

 I know it is possible to load the whole text file, do the change, and  save
 this as a new file. However, this is not practical in my case, because the
 document is huge and cannot be fully loaded in R.

 Any idea?

 You seek seek! Rough outline:

 Open the file as a read-write connection using con = file(fileName, open=r+)

 Seek to where you want to change the line using seek(con, where =
linelength*linenumber)

 Write the new text using cat(my new text,file=con)

 Close the connection using close(con).

Note this works if the lines are all the same length, since the
position used in seek() is in bytes. You might be able to scan() or
readLines() up to the point you want to change and then read off the
byte position with seek(con,where=NA). Note that seek keeps a read and
a write position.

 Further complications include making sure you don't write over
end-of-line characters - your replacement text has to be the same size
as the existing text.

  read help(connection) and help(seek) for more help :)

 And test it on something else first, lest ye stomp on the original.
And keep backups.

Barry

__
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] matching subvectors in vector sets

2009-04-17 Thread Albert Vilella
Hi,

I've got a list of ~2 elements that look like this:

[1]
A00096:A00096:A00096:A00096:A02178:A02178:A07776

[2]
A00046:A00076:A01101:A04146:A05671:A07169

[3]
A00038:A00932:A02185:A02370:A02818:A02818:A02818:A02818:A04732:A07142:A07142

[4]
A00096:A01352:A01352:A02023:A05001:A05001:A07776

[5]
A00036:A00047:A00059:A00503:A00904:A00904:A00904:A01023:A01023:A01399:A02029:A03941:A07679
[6]
A00041:A00533:A00855:A02178:A02178:A02178:A05671:A05671:A05671:A05671:A05671:A05671:A05671
...

And I would like to have a table with the frequency of occurrences for
matching subvectors in all elements, i.e., not
only the number of times a vector is found but also how many times a
subvector (of at least 2 ids) is found.

How can I do that?
Thanks in advance,
Albert.

[[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] get() versus getAnywhere()

2009-04-17 Thread Duncan Murdoch

Benjamin Tyner wrote:
Many thanks Duncan. Perhaps this merits a more explicit note in the 
documentation?
  


The quote I gave is from the documentation.  How could it be more explicit?

Duncan Murdoch

Duncan Murdoch wrote:
  

On 4/16/2009 9:52 AM, Benjamin Tyner wrote:


Hi

Using R 2.8.1. I have list object called AuxData. Inside a browser(),

   get(AuxData)

succeeds, while

   getAnywhere(AuxData)

fails with the error no object named âAuxDataâ was found. I'm
curious to know if this could be a bug. If yes, I'll try to come up
with a reproducible example.
  
It's not a bug.  getAnywhere doesn't really mean anywhere, it means 
visible on the search path, registered as an S3 method or in a name 
space but not exported.  On the other hand, the browser will show you 
the local evaluation frame.  So I'd expect the browser to be able to 
see x below, but getAnywhere wouldn't find it, because it's not in one 
of the places listed above.


f - function(x) {
  browser()
  getAnywhere(x)
}

f(1)







__
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] changing Swaeve output settings for .pdf and .eps - is there a way?

2009-04-17 Thread Duncan Murdoch

cameron.bracken wrote:


markheckmann wrote:
  

The pdf() settings do not affect Sweave settings when producing a .pdf
graphic. How can I change the Sweave default settings to e.g. 3 inch?




Also, even if you set the width of your plot to 3 inches, the plot will be
expanded to 80% of the textwidth by default.  To disable this (i.e you set
width=3 and your plot is actually 3 inches) use 


\usepackage[nogin]{Sweave}.
  
You will have to copy Sweave.sty to your local directory or to your texmf
directory for this to work. 

  
You shouldn't need Sweave.sty in your local directory for this to work.  
You aren't changing it,

just using one of its options.

There are other ways to control the size:  it isn't always 80%.  I 
normally use something like
\setkeys{Gin}{width=0.75\textwidth} to control it.  You can reset this a 
number of times in
the same document.  (Read the LaTeX docs for graphicx to see the other 
keys that can be set.)


Duncan Murdoch

__
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] map of china without regions

2009-04-17 Thread Roger Bivand
Ray Brownrigg Ray.Brownrigg at ecs.vuw.ac.nz writes:

 
 Sorry, can't be done at the moment with the maps package.
 
...
 
 You *might* be able to achieve what you want by selecting only those line
segments that 
 provide portions of the external border, but I would suggest that other
packages (perhaps 
 someone will suggest the best) are more likely to be able to provide what you
want 
 without so much effort.

You could subset from the mapdata worldHires dataset:

map(worldHires,china,fill=TRUE, col=transparent)

or alternatively for a similar geographical footprint: 

library(maptools)
data(wrld_simpl)
plot(wrld_simpl[wrld_simpl$ISO2 %in% c(CN, TW),])

depending on your needs.

Roger Bivand

 
 HTH
 Ray Brownrigg
 
 On Fri, 17 Apr 2009, Cuvelier Etienne wrote:
  Hello,
  I use the map package in conjunction with the mapdata package,
  and I want to draw the map of China without  interior regions.

__
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] Kruskal's MDS results

2009-04-17 Thread Jari Oksanen
Dieter Vanderelst Dieter.Vanderelst at ua.ac.be writes:

 
 A few people suggested taking a look at Ripley's book MASS. I know the formula
listed there.
 
 The point is that the manual for the isoMDS function says it's stress output
is in percent. Does this mean,
 the stress reported by isoMDS is just the stress value in MASS (which ranges
from 0 to 1) value multiplied by
 100? I've haven't been able to find any resource that expresses stress in
values from 0 to 100. So, this
 would be a convention introduced by the authors of the package?

Yes, it is stress multplied with 100 which makes it per cent instead of per
unit. You can see this also in the software. The extract is from VR_mds_fn
function in MASS.c:


sstar = 0.0;
tstar = 0.0;
for (i = 0; i  n; i++) {
tmp = y[i] - yf[i];
sstar += tmp * tmp;
tstar += y[i] * y[i];
}
ssq = 100 * sqrt(sstar / tstar);

The last line has the multiplication, the previous collect the terms for the
stress. 

Best wishes, Jari Oksanen

__
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] multiplot numbering

2009-04-17 Thread rajesh j
Hi,

I have a multiplot in which i need to label each plot as (a) (b) etc.
preferably on the right side of each plot. My layout is one plot below the
other.How can i do this?

-- 
Rajesh.J

[[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] Numeric data calculated in bwplot

2009-04-17 Thread Yuri Volchik

Hi,

i was wondering if there is a way to extract statistic calculated by the
function bwplot in numeric format, i.e. a list with values of borders mean
etc.
Going through the help i couldn't find it, and text of the function
itself(bwplot) is very long.

Thanks

-- 
View this message in context: 
http://www.nabble.com/Numeric-data-calculated-in-bwplot-tp23096219p23096219.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] How to control distance between rows of figures in multiple plots

2009-04-17 Thread jim holtman
?par

look at the 'mar' parameter.

On Thu, Apr 16, 2009 at 11:54 PM, Gundala Viswanath gunda...@gmail.com wrote:
 Dear all,

 I have a plot with 2 x 2 figures matrix in it.

 pdf(~/Desktop/myplot.pdf,width=13,height=7)
 par(mfrow=c(2,2))
 # follow by some code

 Now the distance between figures of row 1 and row 2
 is too wide. How can I modify?

 - Gundala Viswanath
 Jakarta - Indonesia

 __
 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] multiplot plot spacing and text strip

2009-04-17 Thread jim holtman
?par(mar=...)
?mtext

On Thu, Apr 16, 2009 at 11:31 PM, rajesh j akshay.raj...@gmail.com wrote:
 Hi everyone,

 I have a certain requirement and I'm not sure what to do.I need to reduce
 the spacing between plots in a multiplot. Make them really close together
 such that they almost touch.
 Also, I need to add a rectangular strip under my plot(very close to it) such
 that the strip contains some text describing it.
 Any help is appreciated

 --
 Rajesh.J

        [[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.




-- 
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] Kruskal's MDS results

2009-04-17 Thread Jari Oksanen
Dieter Vanderelst Dieter.Vanderelst at ua.ac.be writes:

 

 The point is that the manual for the isoMDS function says it's stress output
is in percent. Does this mean,
 the stress reported by isoMDS is just the stress value in MASS (which ranges
from 0 to 1) value multiplied by
 100? I've haven't been able to find any resource that expresses stress in
values from 0 to 100. So, this
 would be a convention introduced by the authors of the package?

A comment about novelty of using percentages. I also had a look at some NMDS
resources, and the first I found were two Kruskal's papers that happened to be
on my desk (Psychometrika 29, 1-27 and Psychometrika 29, 115-129, both from
1964). Both of these expressed stress in percents. Certainly this is not a
convention introduced by the authors of the package, since they are much too
young to have done that prior to 1964.

Cheers, Jari Oksanen

__
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] Manipulate single line in textfile

2009-04-17 Thread jim holtman
You can also read/write portions of the text till you get to the line
you want to change, change it and then continue copying the lines.
This is what would be done with any other software approach in trying
to replace 'text' that may not be the same length.

On Fri, Apr 17, 2009 at 4:20 AM, Guillaume Filteau filt...@unc.edu wrote:
 Hello all,

 Is it possible to modify a single line in a textfile?

 I know it is possible to load the whole text file, do the change, and  save
 this as a new file. However, this is not practical in my case, because the
 document is huge and cannot be fully loaded in R.

 Any idea?
 Best,
 Guillaume

 __
 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] Presenting R Results in Webpages

2009-04-17 Thread Jim Lemon

Jason Rupert wrote:
I apologize in advance that this question is not specific to R, but I thought some R users may be using this in their work process flow. 

I would like to be able to have a tool (prefer scriptable) that will take two images and some pre-written text and put it on an simple webpage.  


That is, it would look something like the following:

|-|
|Title|
| |
|  ||  || Some basic txt  |
|  | Image1 |  | Image2 | ... |
|  ||  || ... |
|_|

R comes in because I have R scripts creating the images I would like to import.  There will be 14-18 pages of these type of slides, but the key is we will be producing these over and over.  I tried doing something like this in PowerPoint, but not impressed with the linking capability or Macros.  


Thanks for any feedback and again appologize that this is not exactly a 
specific R question.

  

Hi Jason,
You could do something similar with htmlize in the prettyR package, and 
get exactly what you want with a bit of HTML editing. Get an R script 
that will generate the two images, then the text. Then insert a few tags 
like this:


(All of the HTML before the first image)
table
tr
td
img src=Image1.png
td
img src=Image2.png
td
Text that you want in the right hand cell
/table
(the rest of the HTML)


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] error bars in matplot

2009-04-17 Thread Jim Lemon

Tim Smith wrote:

Hi,

I was trying to get error bars in my matplot. I looked at an earlier thread, 
and the sample code that I made is:

#--
library(plotrix)

mat1 - matrix(sample(1:30,10),nrow=5,ncol=2)
ses - matrix(sample(1:3,10,replace=T),nrow=5,ncol=2)
vect - seq(20,100,20)
rownames(mat1) - rownames(ses) - vect
colnames(mat1) - colnames(ses) - letters[1:2]

matplot(mat1,pch=c('x','o'),type = b,lwd = 2,lty = c(1,2),
col = c(green,black),cex.main = 1.8,cex=2,cex.lab=1.5,
main = Graph 1,xlab = Numbers 1,ylab = Numbers 2,cex.axis = 
1.6,axes=F)
plotCI(rep(vect,2),mat1,ses2,pch=NA,add=T,
col=rep(c(green,black),each=nrow(mat1)))
axis(1,1:5,labels = vect,cex.axis=1.5)
axis(2,cex.axis=1.5)
  
#--


I don't get the error bars though. If I set 'add = F' in plotCI function, then 
I can see the error bars, but they just can't be added to the matplot. What am 
I doing wrong? Is there any other way to get the error bars?

  

Hi Tim,
Try the dispersion function in plotrix to add error bars. You will 
probably have to add ylim=c(0,29) to your matplot command.


dispersion(rep(1:5,2),mat1,ses)

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.


[R] R 2.9.0 is released

2009-04-17 Thread Peter Dalgaard
I've rolled up R-2.9.0.tar.gz a short while ago. This is a development
release which contains a number of new features.

Also, a number of mostly minor bugs have been fixed. See the full list
of changes below.

You can get it (later today) from

http://cran.r-project.org/src/base/R-2/R-2.9.0.tar.gz

or wait for it to be mirrored at a CRAN site nearer to you. In case of
impatience, try http://www.biostat.ku.dk/~pd/R-release

Binaries for various platforms will appear in due course.

For the R Core Team

Peter Dalgaard



These are the md5sums for the freshly created files, in case you wish
to check that they are uncorrupted:


70447ae7f2c35233d3065b004aa4f331  INSTALL
433182754c05c2cf7a04ad0da474a1d0  README
4f004de59e24a52d0f500063b4603bcb  OONEWS
ff4bd9073ef440b1eb43b1428ce96872  ONEWS
7861f511a3f8e8598c9b84d65e93c389  NEWS
7abcbbc7480df75a11a00bb09783db90  THANKS
070cca21d9f8a6af15f992edb47a24d5  AUTHORS
a6f89e2100d9b6cdffcea4f398e37343  COPYING.LIB
eb723b61539feef013de476e68b5c50a  COPYING
020479f381d5f9038dcb18708997f5da  RESOURCES
b96e9596f947794c5628712f8016aa90  FAQ
a5b79a2bc1372136cda4674b5f46d146  R-2.9.0.tar.gz
a5b79a2bc1372136cda4674b5f46d146  R-latest.tar.gz



This is the relevant part of the NEWS file:

CHANGES IN R VERSION 2.9.0


SIGNIFICANT USER-VISIBLE CHANGES

o   expand.grid() by default no longer coerces strings into factors.


NEW FEATURES

o   Package 'Matrix' is now a recommended package contained in the
basic R distribution.  It provides S4 classes and methods for
dense and sparse matrices, often by using the numerical
libraries Lapack and from the SuiteSparse collection CHOLMOD,
CSparse, and SPQR among others.

o   pdf() and postscript() gain a 'useKerning' argument to place
strings using kerning (which had previously been ignored in
display but not in strwidth), based in part on an idea and
code from Ei-ji Nakama. The default is TRUE.

Kerning involving spaces is now ignored (it was previously
only used in the computation of string widths).

o   seq.default() and seq.int() ensure that the result is within the
interval [from, to] even when the last value would previously
have been slightly out of range because of the allowance for
rounding error in computing the number of elements.

o   boxplot() gains a simple 'matrix' method, enabling boxplot(mat)
instead of boxplot(data.frame(mat)).

o   zip.file.extract() gains an optional 'dir' argument (but use
unzip() instead).

o   source() with 'encoding' specified (and not as unknown) marks
the encoding of character strings in Latin-1 and UTF-8
locales.

o   parse(text=z) now marks the encoding of character strings in
Latin-1 and UTF-8 locales if 'z' is of known encoding (that is
all elements are either ASCII or marked as Latin-1 or UTF-8).

o   sprintf() does stricter error checking on input formats to
avoid passing invalid formats to the OS (which have a tendency
to crash under such inputs).

o   expand.grid() gains a 'stringsAsFactor' argument to ask for
automatic conversion of character vectors to factors (which
happened for many years but was not previously documented, and
is no longer the default).

o   bxp() now coputes the 'ylim' including the outliers only if
'outline = TRUE'.  (Wish of PR#13196)

o   barplot() gains a 'args.legend' argument.  (Wish of PR#13265).

o   RweaveLatexSetup() now accepts all (and not just some) options
passed through from Sweave()

o   cumsum(x) and cumprod(x) for double precision x now use a long
double accumulator where available and so more closely match
sum() and prod() in potentially being more accurate.

o   plot() methods for stepfun (and hence ecdf) gain an 'col'
argument, allowing to set all three colors simultaneously.

o   Iterating over a factor in a for loop now coerces to a character
vector (rather than using the integer codes).

o   data.frame() now recycles columns of list arguments, not just
vectors and factors.

o   plot.ts(plot.type=multiple) now makes use of *.lab and
*.axis graphical parameters (wish of PR#13134 and 13135).

o   Classes can be exported from a name space using the NAMESPACE
file directive 'exportClassPattern' which has the same syntax
as 'exportPattern'.

o   strftime() now converts its first argument with as.POSIXlt()
and so is no longer an alias for format.POSIXLt.

o   body-() now treats list values consistently with other
types: they no longer need to be wrapped in a list() call.

o   option(pdfbrowser) is now set on Windows as well as on
Unix-alikes.

o   object.size() now returns an object of class object_size and
has a print() method.

o   

[R] Using spdep example data and R code : bbox should never contain infinite values

2009-04-17 Thread Dejan Gregor
Hi,

I am facing with a problem when running a code against the sample data from
spdep. I am getting

SpatialPoints object : bbox should never contain infinite values
In additionl Warning Messages:
1. In min(x): no non-missing arguments to min; returning Inf
2. In max(x): no non-missing arg...


The code I am trying to execute:

sidgams-opgamdata=as(nc, data.frame), radius=30, step=10, alpha=.002)
gampoints-SpatialPoints(sidsgam[,c(x,y)]*1000,
  CRS(+proj=utm +zone=18 +datum=WGS84))

The input dataset is a modified polygon (in WGS datum) of North Carolina
that comes with spdep, but using some other additional fields for
calculation.

I would be very happy to receive a suggestion on corecting this.

Thanks!

Dejan

[[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] Numeric data calculated in bwplot

2009-04-17 Thread stephen sefick
library(lattice)
x - bwplot(voice.part ~ height, data=singer, xlab=Height (inches))
str(x)

I have not done this before, but the output of str should give you a
starting point for extracting numeric values contained in one of the
numerous lists.

hope this helps

Stephen Sefick

On Fri, Apr 17, 2009 at 8:03 AM, Yuri Volchik yuri.volc...@gmail.com wrote:

 Hi,

 i was wondering if there is a way to extract statistic calculated by the
 function bwplot in numeric format, i.e. a list with values of borders mean
 etc.
 Going through the help i couldn't find it, and text of the function
 itself(bwplot) is very long.

 Thanks

 --
 View this message in context: 
 http://www.nabble.com/Numeric-data-calculated-in-bwplot-tp23096219p23096219.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.




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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 create the null distribution

2009-04-17 Thread Anders Bjorn
Hi,

I want to bootstrap the likelihood ratio test for testing linear
restrictions on the parameters of a regression model. The aim is to perform
a size and power analysis. My question is, as indicated by the subject, how
do I approximate the null distribution? The code that I ran looks like

 boot.test - function(data, indeces, maxit=20) {
+ y1 - fit1+e1[indeces]
+ mod1 - glm(y1 ~ X1-1, maxit=maxit)
+ y2 - fit2+e2[indeces]
+ mod2 - glm(y2~1, maxit=maxit)
+ t - 2*(logLik(mod1)-logLik(mod2))
+ t
+ }
 boot.lrtest - boot(data=M1, statistic=boot.test, R=1999, maxit=100)

However, I suspect that I am not bootstrapping under the null hypothesis.
How do I perform the bootstrap under the null? I would really appriciate any
help, I feel rather lost.

/Anders

[[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] Kruskal's MDS results

2009-04-17 Thread Dieter Vanderelst

Thank you for clearing this out.

Jari Oksanen wrote:

Dieter Vanderelst Dieter.Vanderelst at ua.ac.be writes:



The point is that the manual for the isoMDS function says it's stress output

is in percent. Does this mean,

the stress reported by isoMDS is just the stress value in MASS (which ranges

from 0 to 1) value multiplied by

100? I've haven't been able to find any resource that expresses stress in

values from 0 to 100. So, this

would be a convention introduced by the authors of the package?


A comment about novelty of using percentages. I also had a look at some NMDS
resources, and the first I found were two Kruskal's papers that happened to be
on my desk (Psychometrika 29, 1-27 and Psychometrika 29, 115-129, both from
1964). Both of these expressed stress in percents. Certainly this is not a
convention introduced by the authors of the package, since they are much too
young to have done that prior to 1964.

Cheers, Jari Oksanen

__
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] matching subvectors in vector sets

2009-04-17 Thread Albert Vilella
Starting by the first entry:
A00096:A00096:A00096:A00096:A02178:A02178:A07776

and supposing there aren't any other subvectors identical in the set, the
algorithm will slide through the vector, first in pairs, then in trios, then
in sets of four, etc, and count the occurrences:

A00096:A00096
3
A00096:A02178
1
A02178:A02178
1
A02178:A07776
1
A00096:A00096:A00096
2
A00096:A00096:A02178
1
A00096:A02178:A02178
1
A02178:A02178:A07776
1
A00096:A00096:A00096:A00096
1
A00096:A00096:A00096:A02178
1
A00096:A00096:A02178:A02178
1
A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178
1
A00096:A00096:A00096:A02178:A02178
1
A00096:A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178:A02178
1
A00096:A00096:A00096:A02178:A02178:A07776
1
A00096:A00096:A00096:A00096:A02178:A02178:A07776
1




On Fri, Apr 17, 2009 at 1:04 PM, jim holtman jholt...@gmail.com wrote:

 Can you provide the output that you would expect from the data you
 gave.  I am not sure what you mean by a 'subvector'.

 On Fri, Apr 17, 2009 at 5:25 AM, Albert Vilella avile...@gmail.com
 wrote:
  Hi,
 
  I've got a list of ~2 elements that look like this:
 
  [1]
  A00096:A00096:A00096:A00096:A02178:A02178:A07776
 
  [2]
  A00046:A00076:A01101:A04146:A05671:A07169
 
  [3]
 
 A00038:A00932:A02185:A02370:A02818:A02818:A02818:A02818:A04732:A07142:A07142
 
  [4]
  A00096:A01352:A01352:A02023:A05001:A05001:A07776
 
  [5]
 
 A00036:A00047:A00059:A00503:A00904:A00904:A00904:A01023:A01023:A01399:A02029:A03941:A07679
  [6]
 
 A00041:A00533:A00855:A02178:A02178:A02178:A05671:A05671:A05671:A05671:A05671:A05671:A05671
  ...
 
  And I would like to have a table with the frequency of occurrences for
  matching subvectors in all elements, i.e., not
  only the number of times a vector is found but also how many times a
  subvector (of at least 2 ids) is found.
 
  How can I do that?
  Thanks in advance,
  Albert.
 
 [[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.
 



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?


[[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] cast function in package reshape

2009-04-17 Thread David Hajage
Hello R useRs,

I have a function which returns a list of functions :

freq1 - function(x) {
  lev - unique(x[!is.na(x)])
  nlev - length(lev)
  args - alist(x=)

  if (nlev == 1) {
body - c({, sum(!is.na(x)), })
f - function() {}
formals(f) - as.pairlist(args)
body(f) - parse(text = body)
namef - paste(freq, as.character(nlev), sep = _)
assign(namef, f)
res - list(get(namef))
names(res) - namef
  }
  if (nlev  1) {
res - NULL
namesf - NULL
for (i in 1:nlev) {
  body - c({, paste(sum(x[!is.na(x)] ==, as.character(lev[i]), ),
sep =  ), })
  f - function() {}
  formals(f) - as.pairlist(args)
  body(f) - parse(text = body)
  namef - paste(freq, as.character(lev[i]), sep = _)
  assign(namef, f)
  namesf - c(namesf, namef)
  res - c(res, get(namef))
}
names(res) - namesf
  }
  return(res)
}

df - data.frame(id = 1:50, x = sample(c(NA, 1), 50, T), y = sample(1:2, 50,
T), z = sample(letters[1:2], 50, T))

 freq1(df$x)
$freq_1
function (x)
{
sum(!is.na(x))
}
environment: 0x03d99684

 freq1(df$y)
$freq_2
function (x)
{
sum(x[!is.na(x)] == 2)
}
environment: 0x03d6c930

$freq_1
function (x)
{
sum(x[!is.na(x)] == 1)
}
environment: 0x03d6c930


I would like to use this list of functions with cast function (in package
reshape by Hadley Wickham) :

 cast(melt(df, id = c(id, z), measure = c(x, y)), variable +
result_variable ~ z, fun = function(x) freq1(x), margins = grand_col)
Erreur dans freq1(x) : objet res non trouvé

Here the result I would like to have :

  variable  a  b (all)
1x  freq_1 10 1424
2y  freq_1 18 3250
3y  freq_2  9 1423

I admit it is a bit far-fetched, but is this actually possible ?

Thank you very much.

David

[[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] Presenting R Results in Webpages

2009-04-17 Thread David Hajage
You could perhaps use asciidoc http://www.methods.co.nz/asciidoc/and ascii
http://eusebe.github.com/ascii/package (but I'm not sure you could obtain
exactly the layout you describe...).

2009/4/17 Jim Lemon j...@bitwrit.com.au

 Jason Rupert wrote:

 I apologize in advance that this question is not specific to R, but I
 thought some R users may be using this in their work process flow.
 I would like to be able to have a tool (prefer scriptable) that will
 take two images and some pre-written text and put it on an simple webpage.
 That is, it would look something like the following:

 |-|
 |Title|
 | |
 |  ||  || Some basic txt  |
 |  | Image1 |  | Image2 | ... |
 |  ||  || ... |
 |_|

 R comes in because I have R scripts creating the images I would like to
 import.  There will be 14-18 pages of these type of slides, but the key is
 we will be producing these over and over.  I tried doing something like this
 in PowerPoint, but not impressed with the linking capability or Macros.
 Thanks for any feedback and again appologize that this is not exactly a
 specific R question.



 Hi Jason,
 You could do something similar with htmlize in the prettyR package, and get
 exactly what you want with a bit of HTML editing. Get an R script that will
 generate the two images, then the text. Then insert a few tags like this:

 (All of the HTML before the first image)
 table
 tr
 td
 img src=Image1.png
 td
 img src=Image2.png
 td
 Text that you want in the right hand cell
 /table
 (the rest of the HTML)


 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.


[[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] S+FinMetrics

2009-04-17 Thread Hassan Mohamed
please !, what is the R equivalents for the S-plus package : S+FinMetrics
thanks
hassan



  
[[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] Presenting R Results in Webpages

2009-04-17 Thread David Hajage
and also R2HTML.

2009/4/17 David Hajage dhajag...@gmail.com

 You could perhaps use asciidoc http://www.methods.co.nz/asciidoc/and ascii
 http://eusebe.github.com/ascii/package (but I'm not sure you could
 obtain exactly the layout you describe...).

 2009/4/17 Jim Lemon j...@bitwrit.com.au

 Jason Rupert wrote:

 I apologize in advance that this question is not specific to R, but I
 thought some R users may be using this in their work process flow.
 I would like to be able to have a tool (prefer scriptable) that will
 take two images and some pre-written text and put it on an simple webpage.
 That is, it would look something like the following:

 |-|
 |Title|
 | |
 |  ||  || Some basic txt  |
 |  | Image1 |  | Image2 | ... |
 |  ||  || ... |
 |_|

 R comes in because I have R scripts creating the images I would like to
 import.  There will be 14-18 pages of these type of slides, but the key is
 we will be producing these over and over.  I tried doing something like this
 in PowerPoint, but not impressed with the linking capability or Macros.
 Thanks for any feedback and again appologize that this is not exactly a
 specific R question.



 Hi Jason,
 You could do something similar with htmlize in the prettyR package, and
 get exactly what you want with a bit of HTML editing. Get an R script that
 will generate the two images, then the text. Then insert a few tags like
 this:

 (All of the HTML before the first image)
 table
 tr
 td
 img src=Image1.png
 td
 img src=Image2.png
 td
 Text that you want in the right hand cell
 /table
 (the rest of the HTML)


 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.




[[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] S+FinMetrics

2009-04-17 Thread Patrick Burns

Resources include:

*  Rmetrics
* The finance task view on CRAN
* The R-sig-finance mailing list


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)

Hassan Mohamed wrote:

please !, what is the R equivalents for the S-plus package : S+FinMetrics
thanks
hassan



  
	[[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] cast function in package reshape

2009-04-17 Thread hadley wickham
On Fri, Apr 17, 2009 at 8:38 AM, David Hajage dhajag...@gmail.com wrote:
 Hello R useRs,

 I have a function which returns a list of functions :

 freq1 - function(x) {
  lev - unique(x[!is.na(x)])
  nlev - length(lev)
  args - alist(x=)

  if (nlev == 1) {
    body - c({, sum(!is.na(x)), })
    f - function() {}
    formals(f) - as.pairlist(args)
    body(f) - parse(text = body)
    namef - paste(freq, as.character(nlev), sep = _)
    assign(namef, f)
    res - list(get(namef))
    names(res) - namef
  }
  if (nlev  1) {
    res - NULL
    namesf - NULL
    for (i in 1:nlev) {
      body - c({, paste(sum(x[!is.na(x)] ==, as.character(lev[i]), ),
 sep =  ), })
      f - function() {}
      formals(f) - as.pairlist(args)
      body(f) - parse(text = body)
      namef - paste(freq, as.character(lev[i]), sep = _)
      assign(namef, f)
      namesf - c(namesf, namef)
      res - c(res, get(namef))
    }
    names(res) - namesf
  }
  return(res)
 }

 df - data.frame(id = 1:50, x = sample(c(NA, 1), 50, T), y = sample(1:2, 50,
 T), z = sample(letters[1:2], 50, T))

 freq1(df$x)
 $freq_1
 function (x)
 {
    sum(!is.na(x))
 }
 environment: 0x03d99684

 freq1(df$y)
 $freq_2
 function (x)
 {
    sum(x[!is.na(x)] == 2)
 }
 environment: 0x03d6c930

 $freq_1
 function (x)
 {
    sum(x[!is.na(x)] == 1)
 }
 environment: 0x03d6c930


 I would like to use this list of functions with cast function (in package
 reshape by Hadley Wickham) :

 cast(melt(df, id = c(id, z), measure = c(x, y)), variable +
 result_variable ~ z, fun = function(x) freq1(x), margins = grand_col)
 Erreur dans freq1(x) : objet res non trouvé

 Here the result I would like to have :

  variable                  a  b (all)
 1        x          freq_1 10 14    24
 2        y          freq_1 18 32    50
 3        y          freq_2  9 14    23

 I admit it is a bit far-fetched, but is this actually possible ?

Something like this?

df - data.frame(
  id = 1:50,
  x = sample(c(NA, 1), 50, T),
  y = sample(1:2, 50, T),
  z = sample(letters[1:2], 50, T)
)
dfm - melt(df, id = c(id, z))


f1 - function(base)
  function(x) table(factor(x, levels = unique(base)))
cast(dfm, variable + result_variable ~ z, f1(dfm$value),
  margins = grand_col)

I think f1 effectively does what your freq1 function does, but always
returns the same number of results, a requirement of the aggregation
function in cast.

Hadley

-- 
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] Lattice xyplot with text under x-axis

2009-04-17 Thread kate.m

A million thanks Deepayan! That works great. 


Deepayan Sarkar wrote:
 
 On Wed, Apr 15, 2009 at 8:59 AM, kate.m katherine...@gmail.com wrote:

 Hi All,

 I have a data set which I need to plot and show the values of one of the
 variables as a second x-axis.

 library(lattice)
 year-c(2001,2002,2003,2004,2005,2006)
 fac-c(arts,arts,arts,sci,sci,sci)
 staff-c(95,98,99,32,31,36)
 part-c(32,31,33,15,16,14)
 df1-data.frame(year,fac,staff,part)

 xyplot(part~year, type=o, xlab=, ylab=)

 n.val.text-paste(n = , df1$staff, sep = )
 mtext(n.val.text, side = 1, line = 3, at = axTicks(1), cex = 0.9)

 This works OK.
 
 Not really...
 
 The problem comes in when I plot the data in panels.

 xyplot(part~year | fac, as.table=TRUE, type=o, between=list(x=1,y=1),
 xlab=, ylab=,
 scales=list(x=list(alternating=3),y=list(alternating=3),
 relation=free))

 The mtext code doesn't work anymore. I think it needs some sort of panel
 function (panel.groups?) which would tell it to show the appropriate
 values
 of staff under their respective year for each fac and each panel.
 
 Something like
 
 xyplot(part~year | fac, as.table=TRUE, type=o, between=list(x=1,y=1),
scales = list(relation = free, x = list(at = year, labels =
 paste(year, n.val.text, sep = \n
 
 -Deepayan
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Lattice-xyplot-with-text-under-x-axis-tp23061842p23098408.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] Coloring X, Y and Main Label

2009-04-17 Thread Gundala Viswanath
Dear all,

I have no problem coloring the axis and plot,
following these procedures:

http://www.nabble.com/Coloring-X-and-Y-axis-tt22989739r0.html#a22989739

However the X,Y and Main Label stays in black.
How can we change their colors?

- Gundala Viswanath
Jakarta - Indonesia

__
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] Modular Arithmetic Error?

2009-04-17 Thread iuhz7j202
Hi,

I'm using the '%%' operator in some code, and am running into the following 
erroneous outcome:

   1.2 %% 0.2
  [1] 0.2

Unless I'm very mistaken, the result should be 0 (indeed, 12 %% 2 does result 
in 0). Furthermore:

   1.20001 %% 0.2
  [1] 0.2
   (1.2+1e17) %% .2
  [1] 0
  Warning message:
  probable complete loss of accuracy in modulus 

(Warning comes up only when it is giving a closer-to-correct answer)
What makes it even stranger is this result:

   (1.2 %% 0.2) == 0.2
  [1] FALSE

Does anybody know what's going on here? This seems like very bad behavior.

Thanks,
Peter

__
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] Modular Arithmetic Error?

2009-04-17 Thread iuhz7j202
A few further oddities (no longer having to do with modular arithmetic):

 (0.3 * 3) == 0.9
[1] FALSE
 (0.2 * 6) == 1.2
[1] FALSE

This is bad behavior, right? I feel like I'm going crazy.

I'm using R version 2.8.1 (2008-12-22).

Thanks,
Peter

__
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] Modular Arithmetic Error?

2009-04-17 Thread ONKELINX, Thierry
That is more or less FAQ 7.31:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-the
se-numbers-are-equal_003f 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and 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 iuhz7j...@sneakemail.com
Verzonden: vrijdag 17 april 2009 16:15
Aan: r-help@r-project.org
Onderwerp: [R] Modular Arithmetic Error?

Hi,

I'm using the '%%' operator in some code, and am running into the
following erroneous outcome:

   1.2 %% 0.2
  [1] 0.2

Unless I'm very mistaken, the result should be 0 (indeed, 12 %% 2 does
result in 0). Furthermore:

   1.20001 %% 0.2
  [1] 0.2
   (1.2+1e17) %% .2
  [1] 0
  Warning message:
  probable complete loss of accuracy in modulus 

(Warning comes up only when it is giving a closer-to-correct answer)
What makes it even stranger is this result:

   (1.2 %% 0.2) == 0.2
  [1] FALSE

Does anybody know what's going on here? This seems like very bad
behavior.

Thanks,
Peter

__
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.

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] Modular Arithmetic Error?

2009-04-17 Thread Doran, Harold
You should read the FAQ 7.31 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of 
 iuhz7j...@sneakemail.com
 Sent: Friday, April 17, 2009 10:30 AM
 To: r-help@r-project.org
 Subject: Re: [R] Modular Arithmetic Error?
 
 A few further oddities (no longer having to do with modular 
 arithmetic):
 
  (0.3 * 3) == 0.9
 [1] FALSE
  (0.2 * 6) == 1.2
 [1] FALSE
 
 This is bad behavior, right? I feel like I'm going crazy.
 
 I'm using R version 2.8.1 (2008-12-22).
 
 Thanks,
 Peter
 
 __
 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] Coloring X, Y and Main Label

2009-04-17 Thread Jorge Ivan Velez
Dear Gundala,

See col.lab and col.main arguments in ?par.

plot(1,col.lab='red',col.main='blue',main='Title here')

HTH,

Jorge


On Fri, Apr 17, 2009 at 10:14 AM, Gundala Viswanath gunda...@gmail.comwrote:

 Dear all,

 I have no problem coloring the axis and plot,
 following these procedures:

 http://www.nabble.com/Coloring-X-and-Y-axis-tt22989739r0.html#a22989739

 However the X,Y and Main Label stays in black.
 How can we change their colors?

 - Gundala Viswanath
 Jakarta - Indonesia

 __
 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] Modular Arithmetic Error?

2009-04-17 Thread Dimitris Rizopoulos

check the R FAQ, and in particular entry 7.31:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f


Best,
Dimitris


iuhz7j...@sneakemail.com wrote:

A few further oddities (no longer having to do with modular arithmetic):


(0.3 * 3) == 0.9

[1] FALSE

(0.2 * 6) == 1.2

[1] FALSE

This is bad behavior, right? I feel like I'm going crazy.

I'm using R version 2.8.1 (2008-12-22).

Thanks,
Peter

__
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.



--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
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] Modular Arithmetic Error?

2009-04-17 Thread iuhz7j202
That explains it, thanks. all.equal() gets it right. I always knew I had to be 
careful with rounding errors, just not with something like (0.2*6)...
I guess I'll just have to avoid using '%%' or '%/%' with non-integers, at least 
if I need it to sometimes come out even.
Thanks again,
Peter

 That is more or less FAQ 7.31:
 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

__
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] Color of points in a 3d plot of a PCA

2009-04-17 Thread Alejandro González

Dear all,
I'm trying to perform a principal components analysis of a sample of 
individuals, and to plot it in 3D, assigning different colors according 
to the population each individual belongs to. Given that the matrix I 
have to use for the PCA cannot contain cualitative variables (here, the 
population of origin), I have no idea how can I do this in R. ANy help?

Thanks in advance

Alejandro González
Departamento de Biodiversidad y Conservación
Real Jardín Botánico
Consejo Superior de Investigaciones Científicas

Claudio Moyano, 1
28014 Madrid, Spain

Tel +0034 914203017

__
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] Modular Arithmetic Error?

2009-04-17 Thread Marc Schwartz

On Apr 17, 2009, at 9:29 AM, iuhz7j...@sneakemail.com wrote:

A few further oddities (no longer having to do with modular  
arithmetic):



(0.3 * 3) == 0.9

[1] FALSE

(0.2 * 6) == 1.2

[1] FALSE

This is bad behavior, right?


No...

 (0.3 * 3) - 0.9
[1] -1.110223e-16

 (0.2 * 6) - 1.2
[1] 2.220446e-16


However:

 all.equal(0.3 * 3, 0.9)
[1] TRUE

 all.equal(0.2 * 6, 1.2)
[1] TRUE


See ?all.equal



I feel like I'm going crazy.


Only because you don't understand the etiology of the behavior.

Read:

R FAQ 7.31 Why doesn't R think these numbers are equal?

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

and call us in the morning  :-)

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.


Re: [R] Color of points in a 3d plot of a PCA

2009-04-17 Thread Duncan Murdoch

On 4/17/2009 10:43 AM, Alejandro González wrote:

Dear all,
I'm trying to perform a principal components analysis of a sample of 
individuals, and to plot it in 3D, assigning different colors according 
to the population each individual belongs to. Given that the matrix I 
have to use for the PCA cannot contain cualitative variables (here, the 
population of origin), I have no idea how can I do this in R. ANy help?

Thanks in advance


As long as the order of rows in the matrix is unchanged when you 
calculate the pc scores, you should be able to use a separate dataframe 
or vector to give information about each row, and to work out a colour 
for plotting it.


For example:


X - matrix(rnorm(1000), 100, 10)
# Make up a fake population based on the first column
popn - round(X[,1])
colour - popn - min(popn) + 1
pc - princomp(X)
library(rgl)
plot3d(pc$scores[,1:3], col=colour)

Duncan Murdoch


Alejandro González
Departamento de Biodiversidad y Conservación
Real Jardín Botánico
Consejo Superior de Investigaciones Científicas

Claudio Moyano, 1
28014 Madrid, Spain

Tel +0034 914203017

__
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] Create histogram from data matrix

2009-04-17 Thread Paul Warren Simonin

Hello!
  Thanks for reading this request for assistance. I have a question  
regarding creating a histogram-like figure from data that are not  
currently in the correct format for the hist command.
  Specifically, my data have been processed and are in a matrix with  
columns containing the variables of interest and separate columns  
containing the number of times this variable was observed (counts).  
This data frame/matrix is rather large (1600 rows), and there are  
multiple rows corresponding to the same variable level (e.g.,  
temperature=8, 5 observations in one row, then the next:  
temperature=8, 9 observations, and so on). In other words, the data  
are not one long vector R can read and plot as a histogram, nor are  
they condensed. My goal is to create a figure in which one axis is  
bins (e.g., temperature values) and the other is number of  
observations in this bin (e.g., number of organisms seen).
  My question is: Is there a way R can be told to read my data to  
create a plot like that I desire? So far I have tried several options,  
including bar plots with no success.


  If there is no way to do this with my data as the are currently  
arrange, is there an efficient way to re-arrange them?


Thanks a lot for any assistance or advice!

Sincerely,
Paul Simonin


--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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] Using trace

2009-04-17 Thread Stavros Macrakis
Well, yes, of course I could add the code to the function by hand.  I
could also calculate square roots by hand.  But -- as in every other
basic programming environment -- there exists an R function 'trace'
which appears to automate the process, and I can't figure out how to
use it to handle this most elementary and standard case.  Clearly I'm
missing something.

  -s

On Thu, Apr 16, 2009 at 9:26 PM, ronggui ronggui.hu...@gmail.com wrote:
 Can you just print what you need to know? For example:

 fact - function(x) {
 + if(x1) ans - 1 else ans - x*fact(x-1)
 + print(sys.call())
 + cat(sprintf(X is %i\n,x))
 + print(ans)
 + }
 fact(4)
 fact(x - 1)
 X is 0
 [1] 1
 fact(x - 1)
 X is 1
 [1] 1
 fact(x - 1)
 X is 2
 [1] 2
 fact(x - 1)
 X is 3
 [1] 6
 fact(4)
 X is 4
 [1] 24


 2009/4/13 Stavros Macrakis macra...@alum.mit.edu:
 I would like to trace functions, displaying their arguments and return
 value, but I haven't been able to figure out how to do this with the
 'trace' function.

 After some thrashing, I got as far as this:

    fact - function(x) if(x1) 1 else x*fact(x-1)
    tracefnc - function() dput(as.list(parent.frame()),  #
 parent.frame() holds arg list
                                                control=NULL)
    trace(fact,tracer=tracefnc,print=FALSE)

 but I couldn't figure out how to access the return value of the
 function in the 'exit' parameter.  The above also doesn't work for
 ... arguments.  (More subtly, it forces the evaluation of promises
 even if they are otherwise unused -- but that is, I suppose, a weird
 and obscure case.)

 Surely someone has solved this already?

 What I'm looking for is something very simple, along the lines of
 old-fashioned Lisp trace:

 defun fact (i) (if ( i 1) 1 (* i (fact (+ i -1)
 FACT
 (trace fact)
 (FACT)
 (fact 3)
  1 (FACT 3)
    2 (FACT 2)
      3 (FACT 1)
        4 (FACT 0)
        4 (FACT 1)
      3 (FACT 1)
    2 (FACT 2)
  1 (FACT 6)
 6

 Can someone help? Thanks,

         -s

 __
 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.




 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html


__
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] Generate bivariate binomial data

2009-04-17 Thread ONKELINX, Thierry
Dear all,

Could someone point me to a function or algorithm to generate random
bivariate binomial data? 

Some details about what I'm trying to do. I have a dataset of trees who
were categorised as not damaged or damaged. Each tree is measured twice
(once in two consecutive years). The trees can recover from the damage
but the data is clearly correlated. As a (un)damaged tree is more likely
to stay (un)damaged. A GEE-model indicates a correlation of about 0.6
between the measures on the same tree.
I need to simulate similar dataset to do some power calculations.

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and 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

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] error bars in matplot

2009-04-17 Thread Tim Smith
Thanks Mathieu and Jim,

That worked!







From: Jim Lemon j...@bitwrit.com.au

Cc: r r-h...@stat.math.ethz.ch
Sent: Friday, April 17, 2009 7:45:39 AM
Subject: Re: [R] error bars in matplot

Tim Smith wrote:
 Hi,

 I was trying to get error bars in my matplot. I looked at an earlier thread, 
 and the sample code that I made is:

 #--
 library(plotrix)

 mat1 - matrix(sample(1:30,10),nrow=5,ncol=2)
 ses - matrix(sample(1:3,10,replace=T),nrow=5,ncol=2)
 vect - seq(20,100,20)
 rownames(mat1) - rownames(ses) - vect
 colnames(mat1) - colnames(ses) - letters[1:2]

 matplot(mat1,pch=c('x','o'),type = b,lwd = 2,lty = c(1,2),
 col = c(green,black),cex.main = 1.8,cex=2,cex.lab=1.5,
 main = Graph 1,xlab = Numbers 1,ylab = Numbers 2,cex.axis = 
 1.6,axes=F)
 plotCI(rep(vect,2),mat1,ses2,pch=NA,add=T,
 col=rep(c(green,black),each=nrow(mat1)))
 axis(1,1:5,labels = vect,cex.axis=1.5)
 axis(2,cex.axis=1.5)
  
 #--

 I don't get the error bars though. If I set 'add = F' in plotCI function, 
 then I can see the error bars, but they just can't be added to the matplot. 
 What am I doing wrong? Is there any other way to get the error bars?

  
Hi Tim,
Try the dispersion function in plotrix to add error bars. You will 
probably have to add ylim=c(0,29) to your matplot command.

dispersion(rep(1:5,2),mat1,ses)

Jim


  
[[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] Using trace

2009-04-17 Thread ronggui
Here is a partial solution:

 trace(fact,quote({cat(sprintf(x= %i\n,x));return}),print=T)
[1] fact
 fact(4)
Tracing fact(4) on entry
x= 4
Tracing fact(x - 1) on entry
x= 3
Tracing fact(x - 1) on entry
x= 2
Tracing fact(x - 1) on entry
x= 1
Tracing fact(x - 1) on entry
x= 0
[1] 24


2009/4/17 Stavros Macrakis macra...@alum.mit.edu:
 Well, yes, of course I could add the code to the function by hand.  I
 could also calculate square roots by hand.  But -- as in every other
 basic programming environment -- there exists an R function 'trace'
 which appears to automate the process, and I can't figure out how to
 use it to handle this most elementary and standard case.  Clearly I'm
 missing something.

              -s

 On Thu, Apr 16, 2009 at 9:26 PM, ronggui ronggui.hu...@gmail.com wrote:
 Can you just print what you need to know? For example:

 fact - function(x) {
 + if(x1) ans - 1 else ans - x*fact(x-1)
 + print(sys.call())
 + cat(sprintf(X is %i\n,x))
 + print(ans)
 + }
 fact(4)
 fact(x - 1)
 X is 0
 [1] 1
 fact(x - 1)
 X is 1
 [1] 1
 fact(x - 1)
 X is 2
 [1] 2
 fact(x - 1)
 X is 3
 [1] 6
 fact(4)
 X is 4
 [1] 24


 2009/4/13 Stavros Macrakis macra...@alum.mit.edu:
 I would like to trace functions, displaying their arguments and return
 value, but I haven't been able to figure out how to do this with the
 'trace' function.

 After some thrashing, I got as far as this:

    fact - function(x) if(x1) 1 else x*fact(x-1)
    tracefnc - function() dput(as.list(parent.frame()),  #
 parent.frame() holds arg list
                                                control=NULL)
    trace(fact,tracer=tracefnc,print=FALSE)

 but I couldn't figure out how to access the return value of the
 function in the 'exit' parameter.  The above also doesn't work for
 ... arguments.  (More subtly, it forces the evaluation of promises
 even if they are otherwise unused -- but that is, I suppose, a weird
 and obscure case.)

 Surely someone has solved this already?

 What I'm looking for is something very simple, along the lines of
 old-fashioned Lisp trace:

 defun fact (i) (if ( i 1) 1 (* i (fact (+ i -1)
 FACT
 (trace fact)
 (FACT)
 (fact 3)
  1 (FACT 3)
    2 (FACT 2)
      3 (FACT 1)
        4 (FACT 0)
        4 (FACT 1)
      3 (FACT 1)
    2 (FACT 2)
  1 (FACT 6)
 6

 Can someone help? Thanks,

         -s

 __
 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.




 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html





-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
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] args and test of passed paramters

2009-04-17 Thread Juergen Rose
Hi,
I would like to call a R script sometimes with:
  R --slave --vanilla --args Debug=1 N=25  test.R 
and sometimes with
  R --slave --vanilla Debug=1  test.R 
or similar.

Inside the R script I get the arguments with:

args=(commandArgs(TRUE))
if(length(args)==0){
  print(===No arguments supplied. =)
}else{
  for(i in 1:length(args)){
eval(parse(text=args[[i]]))
  }
}

But I don't know, how can I test inside the script if the parameter N
was passed to script or not. I am looking for something like
is.defined(N), but I could not find it until now.

Any hint?

Juergen

__
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] Generate bivariate binomial data

2009-04-17 Thread Christian Ritz
Hi Thierry,

I think it should be possible to generate such correlated data using a mixed 
model approach:


1) Generate pairs of correlated linear predictor values using an ordinary 
linear mixed
model setup (for example using rnorm() repeatedly)

2) Back-transform these values using the inverse logit (or similar link 
function) to
obtain probabilities

3) Draw binomial responses using the probabilities from 2) (using rbinom())


You may need to use trial-and-error to get the right amount of correlation.


Christian

__
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] issue with L-BFGS-B in optim (optim just hangs)

2009-04-17 Thread Tiago Marques

Dear R-help list,

Just a wrap up for this issue. Thanks to Ravi Varadan and Paul Smith for 
useful feedback (both on and off list).


It seems like the culprit was another function being called within 
optim, namely adapt (used to solve numerically a double integral in the 
likelihood I am maximizing). From what I was able to track down, it is 
adapt that just hangs. I do not know exactly why, but decreasing the 
precision in adapt, using parameter eps, solves it somewhat.


I have not yet investigated thoroughly if decreasing eps does have an 
impact on my results, but that is another story!


Best,

Tiago

Ravi Varadhan wrote:

Hi Tiago,

It is hard for me to speculate without knowing more about your problem.  


Here is what I would suggest, assuming your problem specification and its
computer implementation are correct:

(1) You may try to terminate the algorithm by specifying a different
stopping criterion than the default values, and see whether the solution is
of acceptable accuracy.  You can increase factr and/or pgtol to see if
this problem goes away.  


(2) Another option is to increase lmm parameter, which is the number of
BFGS updates saved for approximating the hessian.  Results in Zhu et al.
(ACM 1997) show that increasing lmm tends to improve the reliability of
the algorithm.  Try, for example, lmm=17 (default is lmm = 5).  Also, try
using trace to get more information on what goes on. 


I can also suggest some alternative solutions:

(3).  An easy solution is to try a different optimization algorithm: YOU can
try either nlminb() or spg() in package BB. 


(4).  If it is easy to do so, specify analytic score function, i.e. the
gradient of log-likelohood, and re-run optim() or nlminb() or spg().


Hope this helps,
Ravi.


Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging and Health
Division of Geriatric Medicine and Gerontology 
Johns Hopkins University

Ph: (410) 502-2619
Fax: (410) 614-9625
Email: rvarad...@jhmi.edu
Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html






-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Tiago Marques
Sent: Wednesday, April 15, 2009 10:57 AM
To: r-help@r-project.org
Subject: [R] issue with L-BFGS-B in optim (optim just hangs)

Dear R-Help List,

I am using optim, with method=L-BFGS-B, to maximize a likelihood inside a
large simulation exercise. This runs fine for most simulated data sets, but
for some reason, about 1 out of 100 times, optim will just hang.
Using a dumb approach to the problem (i.e. printing the parameter values
each time the function being maximized is evaluated), I tracked down when
this happens, and although I do not understand optim's behavior or what
triggers it, it seems to happen specifically when one of the parameter
boundaries is reached - and then the function just stops being evaluated.

But there is nothing special with the parameter boundary, i.e., if  I
decrease or increase the boundary using say lower and upper arguments in
optim, the function seems to hang at the new values. So it does not seem to
be a specific value that triggers the behavior, but the fact that the value
is the boundary defined in the function call.

As anyone seen this behavior before? Is it me missing something or is this
some bug in method=L-BFGS-B? Any suggestions on how to deal with it?

Many thanks for any useful feedback,

Tiago

--

Tiago André Marques
Research Unit for Wildlife Population Assessment Centre for Research into
Ecological and Environmental Modelling University of St Andrews The
Observatory Buchanan Gardens St Andrews Fife KY16 9LZ Scotland

Tel: 00441334461842 Fax: 00441334461800 (Scotland office)
Tel: 00351210198736 (Portugal home)

http://www-maths.mcs.st-andrews.ac.uk/homepages/tam2.html
http://www.creem.st-and.ac.uk/tiago/

The University of St Andrews is a charity registered in Scotland : No
SC013532

__
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] R on Windows and RMySQL

2009-04-17 Thread silv



I have successfully installed R (version 2.8.1) and RMySQL (version 0.7-4) 
on my PC (Windows). Now I have a problem running RMySQL on R. I constantly 
receive the following error-message:


Error in utils::readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 
2) :

  Registry-Schlüssel 'S' nicht gefunden
Error : .onLoad in 'loadNamespace' für 'RMySQL' fehlgeschlagen
Fehler: Laden von Paket/Namensraum für 'RMySQL' fehlgeschlagen

Does anyone have a clue what I should do? I don`t have any experience in 
such issues. I have not installed MySQL on my PC. Could this be the solution 
to my problem? Is it true that RMySQL does work properly on R only if you 
first install MySQL?


Thanks for your answer...

__
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] numbers loop in R

2009-04-17 Thread emj83

I would like to create a matrix in R that looks similar to this:

 [,1] [,2] [,3] [,4]
[1,]  NaN  1  2  3
[2,]  NaN  1  2  4
[3,]  NaN   1  2  5
[4,]  NaN  2  3  4
[5,]  NaN  2  3  5
[6,]  NaN345

I have the loop below:

where A for example is 5

matrixx-function(A){
B=matrix(NaN,nrow=(A+1),ncol=4)
for(k in 1:(A+1)){
for(i in 1:(A-2)){
 for(j in (i+2):A){ 
 }  
}   
   }
B[k,]=c(NaN,i,(i+1),j)
print(B)
}

But it only prints the final line in:

 matrixx(5)
 [,1] [,2] [,3] [,4]
[1,]  NaN  NaN  NaN  NaN
[2,]  NaN  NaN  NaN  NaN
[3,]  NaN  NaN  NaN  NaN
[4,]  NaN  NaN  NaN  NaN
[5,]  NaN  NaN  NaN  NaN
[6,]  NaN345

Could anyone give me a hand? Would be much appreciated.

Thanks Emma

-- 
View this message in context: 
http://www.nabble.com/numbers-loop-in-R-tp23099591p23099591.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] Numeric data calculated in bwplot

2009-04-17 Thread Deepayan Sarkar
On 4/17/09, Yuri Volchik yuri.volc...@gmail.com wrote:

  Hi,

  i was wondering if there is a way to extract statistic calculated by the
  function bwplot in numeric format, i.e. a list with values of borders mean
  etc.

See ?boxplot.stats

-Deepayan

__
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 on Windows and RMySQL

2009-04-17 Thread Duncan Murdoch

On 4/17/2009 6:48 AM, s...@access.unizh.ch wrote:


I have successfully installed R (version 2.8.1) and RMySQL (version 0.7-4) 
on my PC (Windows). Now I have a problem running RMySQL on R. I constantly 
receive the following error-message:


Error in utils::readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 
2) :

   Registry-Schlüssel 'S' nicht gefunden
Error : .onLoad in 'loadNamespace' für 'RMySQL' fehlgeschlagen
Fehler: Laden von Paket/Namensraum für 'RMySQL' fehlgeschlagen

Does anyone have a clue what I should do? I don`t have any experience in 
such issues. I have not installed MySQL on my PC. Could this be the solution 
to my problem? Is it true that RMySQL does work properly on R only if you 
first install MySQL?


That's what it looks like.  I'm not sure why it is reporting 'S' as a 
problem, but when I execute that line I see


 readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 2)
$`MySQL Server 5.0`
$`MySQL Server 5.0`$Location
[1] F:\\Program Files\\MySQL\\MySQL Server 5.0\\

$`MySQL Server 5.0`$Version
[1] 5.0.22


and when I change the key to a nonexistent one I see

 readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2)
Error in readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2) :
  Registry key 'S' not found

I'll take a look at readRegistry and try to improve the error message.

Duncan Murdoch

__
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] issue with L-BFGS-B in optim (optim just hangs)

2009-04-17 Thread Ravi Varadhan

Tiago,

If you have an improper integral, i.e. with at least one of the limits being
infinite, it is generally not a good idea to use large positive or negative
values to compute such integrals. You should use integrate (calling it
twice) to compute your double integral.  This might solve your problem,
assuming that is your problem.

Ravi.

---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvarad...@jhmi.edu

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html







-Original Message-
From: Tiago Marques [mailto:ti...@mcs.st-and.ac.uk] 
Sent: Friday, April 17, 2009 11:56 AM
To: Ravi Varadhan
Cc: r-help@r-project.org
Subject: Re: [R] issue with L-BFGS-B in optim (optim just hangs)

Dear R-help list,

Just a wrap up for this issue. Thanks to Ravi Varadan and Paul Smith for
useful feedback (both on and off list).

It seems like the culprit was another function being called within optim,
namely adapt (used to solve numerically a double integral in the likelihood
I am maximizing). From what I was able to track down, it is adapt that just
hangs. I do not know exactly why, but decreasing the precision in adapt,
using parameter eps, solves it somewhat.

I have not yet investigated thoroughly if decreasing eps does have an impact
on my results, but that is another story!

Best,

Tiago

Ravi Varadhan wrote:
 Hi Tiago,
 
 It is hard for me to speculate without knowing more about your problem.  
 
 Here is what I would suggest, assuming your problem specification and 
 its computer implementation are correct:
 
 (1) You may try to terminate the algorithm by specifying a different 
 stopping criterion than the default values, and see whether the 
 solution is of acceptable accuracy.  You can increase factr and/or 
 pgtol to see if this problem goes away.
 
 (2) Another option is to increase lmm parameter, which is the number 
 of BFGS updates saved for approximating the hessian.  Results in Zhu et
al.
 (ACM 1997) show that increasing lmm tends to improve the reliability 
 of the algorithm.  Try, for example, lmm=17 (default is lmm = 5).  
 Also, try using trace to get more information on what goes on.
 
 I can also suggest some alternative solutions:
 
 (3).  An easy solution is to try a different optimization algorithm: 
 YOU can try either nlminb() or spg() in package BB.
 
 (4).  If it is easy to do so, specify analytic score function, i.e. 
 the gradient of log-likelohood, and re-run optim() or nlminb() or spg().
 
 
 Hope this helps,
 Ravi.
 
 --
 --
 Ravi Varadhan, Ph.D.
 Assistant Professor, The Center on Aging and Health Division of 
 Geriatric Medicine and Gerontology Johns Hopkins University
 Ph: (410) 502-2619
 Fax: (410) 614-9625
 Email: rvarad...@jhmi.edu
 Webpage:  
 http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html
 
 --
 --
 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Tiago Marques
 Sent: Wednesday, April 15, 2009 10:57 AM
 To: r-help@r-project.org
 Subject: [R] issue with L-BFGS-B in optim (optim just hangs)
 
 Dear R-Help List,
 
 I am using optim, with method=L-BFGS-B, to maximize a likelihood 
 inside a large simulation exercise. This runs fine for most simulated 
 data sets, but for some reason, about 1 out of 100 times, optim will just
hang.
 Using a dumb approach to the problem (i.e. printing the parameter 
 values each time the function being maximized is evaluated), I tracked 
 down when this happens, and although I do not understand optim's 
 behavior or what triggers it, it seems to happen specifically when one 
 of the parameter boundaries is reached - and then the function just stops
being evaluated.
 
 But there is nothing special with the parameter boundary, i.e., if  I 
 decrease or increase the boundary using say lower and upper arguments 
 in optim, the function seems to hang at the new values. So it does not 
 seem to be a specific value that triggers the behavior, but the fact 
 that the value is the boundary defined in the function call.
 
 As anyone seen this behavior before? Is it me missing something or is 
 this some bug in method=L-BFGS-B? Any suggestions on how to deal with
it?
 
 Many thanks for any useful feedback,
 
 Tiago
 
 --
 
 Tiago André Marques
 Research Unit for Wildlife Population Assessment Centre for Research 
 into Ecological and Environmental Modelling University of St Andrews 
 The Observatory Buchanan Gardens St Andrews Fife KY16 9LZ Scotland
 
 Tel: 00441334461842 Fax: 

Re: [R] matching subvectors in vector sets

2009-04-17 Thread jim holtman
How about this:

 x - A00096:A00096:A00096:A00096:A02178:A02178:A07776
 x.s - unlist(strsplit(x, :))
 for (i in 2:length(x.s)){
+ x.seq - embed(length(x.s):1, i)
+ print(table(apply(x.seq, 1, function(z){
+ paste(x.s[z], collapse=:)
+ })))
+ }

A00096:A00096 A00096:A02178 A02178:A02178 A02178:A07776
3 1 1 1

A00096:A00096:A00096 A00096:A00096:A02178 A00096:A02178:A02178
A02178:A02178:A07776
   211
   1

A00096:A00096:A00096:A00096 A00096:A00096:A00096:A02178
A00096:A00096:A02178:A02178 A00096:A02178:A02178:A07776
  1   1
   1   1

A00096:A00096:A00096:A00096:A02178 A00096:A00096:A00096:A02178:A02178
A00096:A00096:A02178:A02178:A07776
 1  1
1

A00096:A00096:A00096:A00096:A02178:A02178
A00096:A00096:A00096:A02178:A02178:A07776
1
   1

A00096:A00096:A00096:A00096:A02178:A02178:A07776
   1


On Fri, Apr 17, 2009 at 9:33 AM, Albert Vilella avile...@gmail.com wrote:
 Starting by the first entry:
 A00096:A00096:A00096:A00096:A02178:A02178:A07776

 and supposing there aren't any other subvectors identical in the set, the
 algorithm will slide through the vector, first in pairs, then in trios, then
 in sets of four, etc, and count the occurrences:

 A00096:A00096
 3
 A00096:A02178
 1
 A02178:A02178
 1
 A02178:A07776
 1
 A00096:A00096:A00096
 2
 A00096:A00096:A02178
 1
 A00096:A02178:A02178
 1
 A02178:A02178:A07776
 1
 A00096:A00096:A00096:A00096
 1
 A00096:A00096:A00096:A02178
 1
 A00096:A00096:A02178:A02178
 1
 A00096:A02178:A02178:A07776
 1
 A00096:A00096:A00096:A00096:A02178
 1
 A00096:A00096:A00096:A02178:A02178
 1
 A00096:A00096:A02178:A02178:A07776
 1
 A00096:A00096:A00096:A00096:A02178:A02178
 1
 A00096:A00096:A00096:A02178:A02178:A07776
 1
 A00096:A00096:A00096:A00096:A02178:A02178:A07776
 1




 On Fri, Apr 17, 2009 at 1:04 PM, jim holtman jholt...@gmail.com wrote:

 Can you provide the output that you would expect from the data you
 gave.  I am not sure what you mean by a 'subvector'.

 On Fri, Apr 17, 2009 at 5:25 AM, Albert Vilella avile...@gmail.com
 wrote:
  Hi,
 
  I've got a list of ~2 elements that look like this:
 
  [1]
  A00096:A00096:A00096:A00096:A02178:A02178:A07776
 
  [2]
  A00046:A00076:A01101:A04146:A05671:A07169
 
  [3]
 
  A00038:A00932:A02185:A02370:A02818:A02818:A02818:A02818:A04732:A07142:A07142
 
  [4]
  A00096:A01352:A01352:A02023:A05001:A05001:A07776
 
  [5]
 
  A00036:A00047:A00059:A00503:A00904:A00904:A00904:A01023:A01023:A01399:A02029:A03941:A07679
  [6]
 
  A00041:A00533:A00855:A02178:A02178:A02178:A05671:A05671:A05671:A05671:A05671:A05671:A05671
  ...
 
  And I would like to have a table with the frequency of occurrences for
  matching subvectors in all elements, i.e., not
  only the number of times a vector is found but also how many times a
  subvector (of at least 2 ids) is found.
 
  How can I do that?
  Thanks in advance,
  Albert.
 
         [[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.
 



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?





-- 
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] Using trace

2009-04-17 Thread Stavros Macrakis
Yes, that is similar to the solution in my original posting, but
doesn't solve the problem I was having with that solution, namely
reporting on the return value.

   -s

On Fri, Apr 17, 2009 at 11:28 AM, ronggui ronggui.hu...@gmail.com wrote:
 Here is a partial solution:

 trace(fact,quote({cat(sprintf(x= %i\n,x));return}),print=T)
 [1] fact
 fact(4)
 Tracing fact(4) on entry
 x= 4
 Tracing fact(x - 1) on entry
 x= 3
 Tracing fact(x - 1) on entry
 x= 2
 Tracing fact(x - 1) on entry
 x= 1
 Tracing fact(x - 1) on entry
 x= 0
 [1] 24


 2009/4/17 Stavros Macrakis macra...@alum.mit.edu:
 Well, yes, of course I could add the code to the function by hand.  I
 could also calculate square roots by hand.  But -- as in every other
 basic programming environment -- there exists an R function 'trace'
 which appears to automate the process, and I can't figure out how to
 use it to handle this most elementary and standard case.  Clearly I'm
 missing something.

              -s

 On Thu, Apr 16, 2009 at 9:26 PM, ronggui ronggui.hu...@gmail.com wrote:
 Can you just print what you need to know? For example:

 fact - function(x) {
 + if(x1) ans - 1 else ans - x*fact(x-1)
 + print(sys.call())
 + cat(sprintf(X is %i\n,x))
 + print(ans)
 + }
 fact(4)
 fact(x - 1)
 X is 0
 [1] 1
 fact(x - 1)
 X is 1
 [1] 1
 fact(x - 1)
 X is 2
 [1] 2
 fact(x - 1)
 X is 3
 [1] 6
 fact(4)
 X is 4
 [1] 24


 2009/4/13 Stavros Macrakis macra...@alum.mit.edu:
 I would like to trace functions, displaying their arguments and return
 value, but I haven't been able to figure out how to do this with the
 'trace' function.

 After some thrashing, I got as far as this:

    fact - function(x) if(x1) 1 else x*fact(x-1)
    tracefnc - function() dput(as.list(parent.frame()),  #
 parent.frame() holds arg list
                                                control=NULL)
    trace(fact,tracer=tracefnc,print=FALSE)

 but I couldn't figure out how to access the return value of the
 function in the 'exit' parameter.  The above also doesn't work for
 ... arguments.  (More subtly, it forces the evaluation of promises
 even if they are otherwise unused -- but that is, I suppose, a weird
 and obscure case.)

 Surely someone has solved this already?

 What I'm looking for is something very simple, along the lines of
 old-fashioned Lisp trace:

 defun fact (i) (if ( i 1) 1 (* i (fact (+ i -1)
 FACT
 (trace fact)
 (FACT)
 (fact 3)
  1 (FACT 3)
    2 (FACT 2)
      3 (FACT 1)
        4 (FACT 0)
        4 (FACT 1)
      3 (FACT 1)
    2 (FACT 2)
  1 (FACT 6)
 6

 Can someone help? Thanks,

         -s

 __
 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.




 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html





 --
 HUANG Ronggui, Wincent
 PhD Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html


__
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] Create histogram from data matrix

2009-04-17 Thread stephen sefick
It would be easier if you were to make a data frame of fake values to
illustrate your point, so that we could just copy it into an R session
and see if we can't get it to work.  So, a stab in the dark would to
look at ggplot2 specifically the hist argument in qplot and the
facets, the lattice package, or reshape to change the format of your
data. If you want me to fool around with it use dput and take a small
subset of your data or make up data to be able to be copied into an R
session.
hope that helps,

Stephen

On Fri, Apr 17, 2009 at 10:59 AM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:
 Hello!
  Thanks for reading this request for assistance. I have a question regarding
 creating a histogram-like figure from data that are not currently in the
 correct format for the hist command.
  Specifically, my data have been processed and are in a matrix with columns
 containing the variables of interest and separate columns containing the
 number of times this variable was observed (counts). This data frame/matrix
 is rather large (1600 rows), and there are multiple rows corresponding to
 the same variable level (e.g., temperature=8, 5 observations in one row,
 then the next: temperature=8, 9 observations, and so on). In other words,
 the data are not one long vector R can read and plot as a histogram, nor are
 they condensed. My goal is to create a figure in which one axis is bins
 (e.g., temperature values) and the other is number of observations in this
 bin (e.g., number of organisms seen).
  My question is: Is there a way R can be told to read my data to create a
 plot like that I desire? So far I have tried several options, including bar
 plots with no success.

  If there is no way to do this with my data as the are currently arrange, is
 there an efficient way to re-arrange them?

 Thanks a lot for any assistance or advice!

 Sincerely,
 Paul Simonin


 --
 Paul W. Simonin
 Graduate Research Assistant, MS Program
 Vermont Cooperative Fish and Wildlife Research Unit
 The Rubenstein School of Environment and Natural Resources
 University of Vermont
 81 Carrigan Dr.
 Burlington, VT 05405
 Ph:802-656-3153

 __
 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.




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
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] numbers loop in R

2009-04-17 Thread David Winsemius
I would have expected to see the assignment to B[k,] inside the loops.  
And to see some connection with the k index in the inner loops if you  
did not want all of the rows to be similar. Because the assignment is  
outside the loops, it happens only once.


-- David Winsemius


On Apr 17, 2009, at 11:11 AM, emj83 wrote:



I would like to create a matrix in R that looks similar to this:

[,1] [,2] [,3] [,4]
[1,]  NaN  1  2  3
[2,]  NaN  1  2  4
[3,]  NaN   1  2  5
[4,]  NaN  2  3  4
[5,]  NaN  2  3  5
[6,]  NaN345

I have the loop below:

where A for example is 5

matrixx-function(A){
B=matrix(NaN,nrow=(A+1),ncol=4)
   for(k in 1:(A+1)){
for(i in 1:(A-2)){
 for(j in (i+2):A){ 
 }  
}   
  }
B[k,]=c(NaN,i,(i+1),j)
print(B)
}

But it only prints the final line in:


matrixx(5)

[,1] [,2] [,3] [,4]
[1,]  NaN  NaN  NaN  NaN
[2,]  NaN  NaN  NaN  NaN
[3,]  NaN  NaN  NaN  NaN
[4,]  NaN  NaN  NaN  NaN
[5,]  NaN  NaN  NaN  NaN
[6,]  NaN345

Could anyone give me a hand? Would be much appreciated.

Thanks Emma

--
View this message in context: 
http://www.nabble.com/numbers-loop-in-R-tp23099591p23099591.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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] numbers loop in R

2009-04-17 Thread jim holtman
try this:

 matrixx-function(A){
+ B=matrix(NaN,nrow=(A+1),ncol=4)
+ k - 1
+ for (i in 3:A){
+ for (j in i:A) {
+ B[k,] - c(NaN, i-2, i-1, j)
+ k - k + 1
+ }
+ }
+ B
+ }
 matrixx(5)
 [,1] [,2] [,3] [,4]
[1,]  NaN123
[2,]  NaN124
[3,]  NaN125
[4,]  NaN234
[5,]  NaN235
[6,]  NaN345



On Fri, Apr 17, 2009 at 11:11 AM, emj83 stp08...@shef.ac.uk wrote:

 I would like to create a matrix in R that looks similar to this:

     [,1] [,2] [,3] [,4]
 [1,]  NaN  1  2  3
 [2,]  NaN  1  2  4
 [3,]  NaN   1  2  5
 [4,]  NaN  2  3  4
 [5,]  NaN  2  3  5
 [6,]  NaN    3    4    5

 I have the loop below:

 where A for example is 5

 matrixx-function(A){
 B=matrix(NaN,nrow=(A+1),ncol=4)
        for(k in 1:(A+1)){
                for(i in 1:(A-2)){
                     for(j in (i+2):A){
                     }
                }
       }
 B[k,]=c(NaN,i,(i+1),j)
 print(B)
 }

 But it only prints the final line in:

 matrixx(5)
     [,1] [,2] [,3] [,4]
 [1,]  NaN  NaN  NaN  NaN
 [2,]  NaN  NaN  NaN  NaN
 [3,]  NaN  NaN  NaN  NaN
 [4,]  NaN  NaN  NaN  NaN
 [5,]  NaN  NaN  NaN  NaN
 [6,]  NaN    3    4    5

 Could anyone give me a hand? Would be much appreciated.

 Thanks Emma

 --
 View this message in context: 
 http://www.nabble.com/numbers-loop-in-R-tp23099591p23099591.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.




-- 
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] Create histogram from data matrix

2009-04-17 Thread hadley wickham
On Fri, Apr 17, 2009 at 9:59 AM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:
 Hello!
  Thanks for reading this request for assistance. I have a question regarding
 creating a histogram-like figure from data that are not currently in the
 correct format for the hist command.
  Specifically, my data have been processed and are in a matrix with columns
 containing the variables of interest and separate columns containing the
 number of times this variable was observed (counts). This data frame/matrix
 is rather large (1600 rows), and there are multiple rows corresponding to
 the same variable level (e.g., temperature=8, 5 observations in one row,
 then the next: temperature=8, 9 observations, and so on). In other words,
 the data are not one long vector R can read and plot as a histogram, nor are
 they condensed. My goal is to create a figure in which one axis is bins
 (e.g., temperature values) and the other is number of observations in this
 bin (e.g., number of organisms seen).
  My question is: Is there a way R can be told to read my data to create a
 plot like that I desire? So far I have tried several options, including bar
 plots with no success.

  If there is no way to do this with my data as the are currently arrange, is
 there an efficient way to re-arrange them?

In fact, this is very easy to do with ggplot2:

install.packages(ggplot2)
library(ggplot2)

qplot(value, weight = numofobservations, data = mydf, geom=histogram)

Hadley

-- 
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] R on Windows and RMySQL

2009-04-17 Thread Duncan Murdoch

On 4/17/2009 12:26 PM, Duncan Murdoch wrote:
On 4/17/2009 12:26 PM, Duncan Murdoch wrote:

On 4/17/2009 6:48 AM, s...@access.unizh.ch wrote:


I have successfully installed R (version 2.8.1) and RMySQL (version 0.7-4) 
on my PC (Windows). Now I have a problem running RMySQL on R. I constantly 
receive the following error-message:


Error in utils::readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 
2) :

   Registry-Schlüssel 'S' nicht gefunden
Error : .onLoad in 'loadNamespace' für 'RMySQL' fehlgeschlagen
Fehler: Laden von Paket/Namensraum für 'RMySQL' fehlgeschlagen

Does anyone have a clue what I should do? I don`t have any experience in 
such issues. I have not installed MySQL on my PC. Could this be the solution 
to my problem? Is it true that RMySQL does work properly on R only if you 
first install MySQL?


That's what it looks like.  I'm not sure why it is reporting 'S' as a 
problem, but when I execute that line I see


  readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 2)
$`MySQL Server 5.0`
$`MySQL Server 5.0`$Location
[1] F:\\Program Files\\MySQL\\MySQL Server 5.0\\

$`MySQL Server 5.0`$Version
[1] 5.0.22


and when I change the key to a nonexistent one I see

  readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2)
Error in readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2) :
   Registry key 'S' not found

I'll take a look at readRegistry and try to improve the error message.

Duncan Murdoch




On 4/17/2009 6:48 AM, s...@access.unizh.ch wrote:


I have successfully installed R (version 2.8.1) and RMySQL (version 0.7-4) 
on my PC (Windows). Now I have a problem running RMySQL on R. I constantly 
receive the following error-message:


Error in utils::readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 
2) :

   Registry-Schlüssel 'S' nicht gefunden
Error : .onLoad in 'loadNamespace' für 'RMySQL' fehlgeschlagen
Fehler: Laden von Paket/Namensraum für 'RMySQL' fehlgeschlagen

Does anyone have a clue what I should do? I don`t have any experience in 
such issues. I have not installed MySQL on my PC. Could this be the solution 
to my problem? Is it true that RMySQL does work properly on R only if you 
first install MySQL?


That's what it looks like.  I'm not sure why it is reporting 'S' as a 
problem, but when I execute that line I see


  readRegistry(SOFTWARE\\MySQL AB, hive = HLM, maxdepth = 2)
$`MySQL Server 5.0`
$`MySQL Server 5.0`$Location
[1] F:\\Program Files\\MySQL\\MySQL Server 5.0\\

$`MySQL Server 5.0`$Version
[1] 5.0.22


and when I change the key to a nonexistent one I see

  readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2)
Error in readRegistry(SOFTWARE\\foobar, hive = HLM, maxdepth = 2) :
   Registry key 'S' not found

I'll take a look at readRegistry and try to improve the error message.


The problem with the error message was simply a typo in the format 
string.  Easy to fix.


Your problem is the lack of MySQL on your system.  Also easy to fix?

Duncan Murdoch

__
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] numbers loop in R

2009-04-17 Thread hadley wickham
On Fri, Apr 17, 2009 at 12:19 PM, jim holtman jholt...@gmail.com wrote:
 try this:

 matrixx-function(A){
 +     B=matrix(NaN,nrow=(A+1),ncol=4)
 +     k - 1
 +     for (i in 3:A){
 +         for (j in i:A) {
 +             B[k,] - c(NaN, i-2, i-1, j)
 +             k - k + 1
 +         }
 +     }
 +     B
 + }
 matrixx(5)
     [,1] [,2] [,3] [,4]
 [1,]  NaN    1    2    3
 [2,]  NaN    1    2    4
 [3,]  NaN    1    2    5
 [4,]  NaN    2    3    4
 [5,]  NaN    2    3    5
 [6,]  NaN    3    4    5

Here's a solution without the loop.  I think it illustrates the intent
of the algorithm more clearly.

candidates - t(combn(5,3))
firstdiff - candidates[,2] - candidates[, 1]
cbind(NaN, candidates[firstdiff == 1, ])

Hadley

-- 
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.


[R] Margins in lattice and device resolution

2009-04-17 Thread Gustaf Rydevik
Hi all,

I believe I've run into this before, but I seem to have totally
forgotten. No headway in the last couple of hours either. How do I
make sure that points and margins remain the same absolute size as I
change
the resolution of a device?
(I'm running 2.9.1 patched, on a Win XP-machine)

Many thanks in advance,

Gustaf

Ps: As an afterthought, might it be that this behaviour is related to
the receng grid-bug for text size in lattice when changing resolution?


Example:
.

###This give a totally squished graph, where the actual plotting area is minimal
CairoPNG(example.png,width = 480, height = 480,
 dpi=600,
 pointsize = 12, bg = white)
bwplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   panel = panel.superpose,
   panel.groups = panel.linejoin,
   xlab = treatment,
   key = list(lines = Rows(trellis.par.get(superpose.line),
  c(1:7, 1)),
  text = list(lab = as.character(unique(OrchardSprays$rowpos))),
  columns = 4, title = Row position))
dev.off()


### This gives a more norma looking graph
CairoPNG(example2.png,width = 480, height = 480,
 dpi=20,
 pointsize = 12, bg = white)
bwplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
   panel = panel.superpose,
   panel.groups = panel.linejoin,
   xlab = treatment,
   key = list(lines = Rows(trellis.par.get(superpose.line),
  c(1:7, 1)),
  text = list(lab = as.character(unique(OrchardSprays$rowpos))),
  columns = 4, title = Row position))
dev.off()

-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
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] Create histogram from data matrix

2009-04-17 Thread jim holtman
here is one way:

 mydata - data.frame(observ=sample(1:10,20,TRUE), value=sample(1:6,20,TRUE))

 mydata
   observ value
1   3 6
2   4 2
3   6 4
4  10 1
5   3 2
6   9 3
7  10 1
8   7 3
9   7 6
10  1 3
11  3 3
12  2 4
13  7 3
14  4 2
15  8 5
16  5 5
17  8 5
18 10 1
19  4 5
20  8 3

 hist(rep(mydata$value, mydata$observ))


On Fri, Apr 17, 2009 at 10:59 AM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:
 Hello!
  Thanks for reading this request for assistance. I have a question regarding
 creating a histogram-like figure from data that are not currently in the
 correct format for the hist command.
  Specifically, my data have been processed and are in a matrix with columns
 containing the variables of interest and separate columns containing the
 number of times this variable was observed (counts). This data frame/matrix
 is rather large (1600 rows), and there are multiple rows corresponding to
 the same variable level (e.g., temperature=8, 5 observations in one row,
 then the next: temperature=8, 9 observations, and so on). In other words,
 the data are not one long vector R can read and plot as a histogram, nor are
 they condensed. My goal is to create a figure in which one axis is bins
 (e.g., temperature values) and the other is number of observations in this
 bin (e.g., number of organisms seen).
  My question is: Is there a way R can be told to read my data to create a
 plot like that I desire? So far I have tried several options, including bar
 plots with no success.

  If there is no way to do this with my data as the are currently arrange, is
 there an efficient way to re-arrange them?

 Thanks a lot for any assistance or advice!

 Sincerely,
 Paul Simonin


 --
 Paul W. Simonin
 Graduate Research Assistant, MS Program
 Vermont Cooperative Fish and Wildlife Research Unit
 The Rubenstein School of Environment and Natural Resources
 University of Vermont
 81 Carrigan Dr.
 Burlington, VT 05405
 Ph:802-656-3153

 __
 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] Lattice xyplot with text under x-axis

2009-04-17 Thread kate.m

Still on this question, I'm having problems with displaying the text when
repeated values are present. For example:

library(lattice)
year-c(2001,2002,2003,2001,2002,2003,2001,2002,2003,2001,2002,2003)
fac-c(arts,arts,arts,arts,arts,arts,sci,sci,sci,sci,sci,sci)
type-c(est,est,est,early,early,early,est,est,est,early,early,early)
staff-c(95,98,99,32,31,36,57,52,55,24,23,26)
part-c(32,31,33,15,16,14,40,41,43,15,17,19)
df1-data.frame(year,fac,type, staff,part)

n.val.text-paste(n = , df1$staff, sep = )

xyplot(part~year | type+fac, as.table=TRUE, type=o,
between=list(x=1,y=1),xlab=,ylab=,
scales = list(relation = free, x = list(at = year, labels =paste(year,
n.val.text, sep = \n 

This attempts to place all the values of staff under each year. Is there a
any way to correct this?

http://www.nabble.com/file/p23103168/lattice_xyplot_with_axis_text.png 


Deepayan Sarkar wrote:
 
 On Wed, Apr 15, 2009 at 8:59 AM, kate.m katherine...@gmail.com wrote:

 Hi All,

 I have a data set which I need to plot and show the values of one of the
 variables as a second x-axis.

 library(lattice)
 year-c(2001,2002,2003,2004,2005,2006)
 fac-c(arts,arts,arts,sci,sci,sci)
 staff-c(95,98,99,32,31,36)
 part-c(32,31,33,15,16,14)
 df1-data.frame(year,fac,staff,part)

 xyplot(part~year, type=o, xlab=, ylab=)

 n.val.text-paste(n = , df1$staff, sep = )
 mtext(n.val.text, side = 1, line = 3, at = axTicks(1), cex = 0.9)

 This works OK.
 
 Not really...
 
 The problem comes in when I plot the data in panels.

 xyplot(part~year | fac, as.table=TRUE, type=o, between=list(x=1,y=1),
 xlab=, ylab=,
 scales=list(x=list(alternating=3),y=list(alternating=3),
 relation=free))

 The mtext code doesn't work anymore. I think it needs some sort of panel
 function (panel.groups?) which would tell it to show the appropriate
 values
 of staff under their respective year for each fac and each panel.
 
 Something like
 
 xyplot(part~year | fac, as.table=TRUE, type=o, between=list(x=1,y=1),
scales = list(relation = free, x = list(at = year, labels =
 paste(year, n.val.text, sep = \n
 
 -Deepayan
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Lattice-xyplot-with-text-under-x-axis-tp23061842p23103168.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] From daily series to monthly and viceversa

2009-04-17 Thread manta

any update anybody? I'm really stucked!
-- 
View this message in context: 
http://www.nabble.com/From-daily-series-to-monthly-and-viceversa-tp23064454p23103052.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] Monotone Transformation

2009-04-17 Thread Feng Jingyu

Hi, I am trying to use R to mimic what I did in SAS.

proc transreg data=x ;
model identity(GSI)=monotone(group1);
 output out=d2 pprefix=M;
run; 

Accroding to SAS documentation, the MONOTONE transfomation algorithm comes
from (Kruskal 1964, secondary approach to ties). I have tried ace. it does
provide some kind of monotone transformation, but it is not what I expected.

Here is how sas output look like:

Obs  GSITGSI group1Tgroup1

 1 0.813010.81301   1  1.55594
 2 0.793590.79359   2  1.55594
 3 1.269001.26900   3  2.59702
 4 2.026802.02680   4  4.29111

group1 is the inital value. Tgroup1 is the monotone transformed value.

Here is how Transformed value output from ace:

$tx
   [,1]
[1,] -0.5698602
[2,] -0.1899534
[3,]  0.1899534
[4,]  0.5698602

Does anybody have any idea whether I could do the similar thing in R? If I
can do it, which function I should use?

Thanks,
Jingyu 
-- 
View this message in context: 
http://www.nabble.com/Monotone-Transformation-tp23103202p23103202.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] Create histogram from data matrix

2009-04-17 Thread Paul Warren Simonin

Thank you all for your advice.
  I have received some good tips, but it was suggested I write back  
with a small simulated data set to better illustrate my needs. So,  
currently my data frame looks something like:


ID (date)  Temperature  Number of fish
200706183   5   456
200706183   5   765
200706183   4   567
200706183   3   876
200706183   3   888
200706183   2   111
200706184   8   2345
200706184   8   654
200706184   8   7786
200706184   7   345
200706184   6   234
200706184   6   123


I need to create a plots for each ID (date) of the number of fish  
observed at each temperature. Obviously my data frame is much larger.  
These plots do not have to be in a specific histogram format, but it  
seems this may be appropriate.
Thanks for any additional advice as to how this may be done, either  
using plot commands or reformatting my data.


It seemed the ggplot2 options may be good but so far I have tried  
qplot with no success:


my most recent code looks like:

qplot(temp,number of fish, geom=histogram,binwidth=1)

I have tried various tweaks of this, but no success.

Thanks for any advice!
-Paul Simonin


Quoting stephen sefick ssef...@gmail.com:


It would be easier if you were to make a data frame of fake values to
illustrate your point, so that we could just copy it into an R session
and see if we can't get it to work.  So, a stab in the dark would to
look at ggplot2 specifically the hist argument in qplot and the
facets, the lattice package, or reshape to change the format of your
data. If you want me to fool around with it use dput and take a small
subset of your data or make up data to be able to be copied into an R
session.
hope that helps,

Stephen

On Fri, Apr 17, 2009 at 10:59 AM, Paul Warren Simonin
paul.simo...@uvm.edu wrote:

Hello!
 Thanks for reading this request for assistance. I have a question regarding
creating a histogram-like figure from data that are not currently in the
correct format for the hist command.
 Specifically, my data have been processed and are in a matrix with columns
containing the variables of interest and separate columns containing the
number of times this variable was observed (counts). This data frame/matrix
is rather large (1600 rows), and there are multiple rows corresponding to
the same variable level (e.g., temperature=8, 5 observations in one row,
then the next: temperature=8, 9 observations, and so on). In other words,
the data are not one long vector R can read and plot as a histogram, nor are
they condensed. My goal is to create a figure in which one axis is bins
(e.g., temperature values) and the other is number of observations in this
bin (e.g., number of organisms seen).
 My question is: Is there a way R can be told to read my data to create a
plot like that I desire? So far I have tried several options, including bar
plots with no success.

 If there is no way to do this with my data as the are currently arrange, is
there an efficient way to re-arrange them?

Thanks a lot for any assistance or advice!

Sincerely,
Paul Simonin


--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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.





--
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis





--
Paul W. Simonin
Graduate Research Assistant, MS Program
Vermont Cooperative Fish and Wildlife Research Unit
The Rubenstein School of Environment and Natural Resources
University of Vermont
81 Carrigan Dr.
Burlington, VT 05405
Ph:802-656-3153

__
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] changing Swaeve output settings for .pdf and .eps - is there a way?

2009-04-17 Thread cameron.bracken



Duncan Murdoch-2 wrote:
 
 There are other ways to control the size:  it isn't always 80%.  I
 normally use something like \setkeys{Gin}{width=0.75\textwidth} to control
 it.  You can reset this a 
 number of times in the same document.  (Read the LaTeX docs for graphicx
 to see the other 
 keys that can be set.)
 

The reason I suggested using the nogin option is because the default
behavior has always seemed very unintuitive to me.  It seems that setting a
width and/or height parameter should be the only thing that needs to be done
to determine the size of the graphic.  I know this is documented but I think
it is overly confusing to a new user.   I know the first time I set width=3
and the plot still spanned 80% of the page threw me off. 
-- 
View this message in context: 
http://www.nabble.com/changing-Swaeve-output-settings-for-.pdf-and-.eps---is-there-a-way--tp23078496p23104267.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] Separating variables in read.table

2009-04-17 Thread Richardson, Patrick
If I have a table (we'll call it, test) containing two columns (as below):

i   x1  x2  x3  x4  x5  y
0   1.125   0.232   7.160   0.0859 8.905 1.5563
7   0.920   0.268   8.804   0.0865 7.388 0.8976
15  0.835   0.271   8.108   0.0852 5.348 0.7482
22  1.000   0.237   6.370   0.0838 8.056 0.7160
29  1.150   0.192   6.441   0.0821 6.960 0.3130
37  0.990   0.202   5.154   0.0792 5.690 0.3617
44  0.840   0.184   5.896   0.0812 6.932 0.1139
58  0.650   0.200   5.336   0.0806 5.400 0.1139


Is there a simple command to break this table into individual variables without 
having to code:

i - test$i
x1 - test$x1
x2 - test$x2
.
.
.
And so on. . 

Many Thank for any assistance.

Patrick
This email message, including any attachments, is for th...{{dropped:6}}

__
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] Matrix package,solve() errors and crashes

2009-04-17 Thread Surendar Swaminathan
Hello All,

  I am working on graph object using IGRAPH package wanted to do Bonacich
Power.  This is my graph object.

The file 'Graph.RData' (4.2 MB) is available for download at
http://dropbox.unl.edu/uploads/20090424/cfe4fcb854bb17f2/Graph.RData

Graph size

Vertices: 20984
Edges: 326033
Directed: FALSE
No graph attributes.
Vertex attributes: name.
No edge attributes.

When I use bonacich power it goes out of memory

Error in get.adjacency.dense(graph, type = type, attr = attr, names =
names,  :
  At vector.pmt:409 : cannot reserve space for vector, Out of memory

I got help from IGRAPH community to use sparse Matrix

http://igraph.wikidot.com/r-recipes#toc6


bonpow.sparse - function(graph, nodes=V(graph), loops=FALSE,
  exponent=1, rescale=FALSE, tol=1e-07) {

  ## remove loops if requested
  if (!loops) {
graph - simplify(graph, remove.multiple=FALSE, remove.loops=TRUE)
  }

  ## sparse adjacency matrix
  d - get.adjacency(graph, sparse=TRUE)

  ## sparse identity matrix
  id - spMatrix(vcount(graph), vcount(graph),
 i=1:vcount(graph), j=1:vcount(graph),
 x=rep(1, vcount(graph)))
  id - as(id, dgCMatrix)

  ## solve it
  ev - solve(id - exponent * d, tol=tol) %*% degree(graph, mode=out)

  if (rescale) {
ev - ev/sum(ev)
  } else {
ev - ev * sqrt(vcount(graph)/sum((ev)^2))
  }

  ev[as.numeric(nodes) + 1]
}

## test graph
test.g - simplify(ba.game(1000,m=2))

## test run
system.time(bp1 - bonpow(test.g))
system.time(bp2 - bonpow.sparse(test.g))

## check that they are the same
max(abs(bp1-bp2))



I get following error and sometime it crashes.

In solve(id - exponent * d, tol = tol) :
Reached total allocation of 1535Mb: see help(memory.size).I increased the
memory size and still it is not helpful

Help on this would be great.

These are steps I followed

1. Created graph object using Igraph version 0.6 on R 2.8.1 windows XP
2. Bonpow(g)
3. Bonpow.sparse function

sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
other attached packages:
[1] Matrix_0.999375-23 lattice_0.17-20igraph_0.6
loaded via a namespace (and not attached):
[1] grid_2.8.1

Thanks in advance

Nathan

[[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] Generate bivariate binomial data

2009-04-17 Thread Charles C. Berry

On Fri, 17 Apr 2009, ONKELINX, Thierry wrote:


Dear all,

Could someone point me to a function or algorithm to generate random
bivariate binomial data?

Some details about what I'm trying to do. I have a dataset of trees who
were categorised as not damaged or damaged. Each tree is measured twice
(once in two consecutive years). The trees can recover from the damage
but the data is clearly correlated. As a (un)damaged tree is more likely
to stay (un)damaged. A GEE-model indicates a correlation of about 0.6
between the measures on the same tree.


The commonly used sampling models for such count data (see Bishop, 
Fienberg, and Holland, Discrete Multivariate Analysis, 1975.) involve four 
parameters. There are various parameterizations.


In your case, the total sample size (N), the proportion of 
undamaged trees at the first (pr.undam.1), and the proportions at the 
second time conditional on the first (p.undam.2.undam.1, p.undam.2.dam.1) 
seems like reasonable way to parameterize the problem to do your 
simulation.


If you have the marginal counts and the correlation, you can transform 
them to the above parameterization by hacking through the algebra to find 
the expected 2 by 2 table of counts as a function of the latter 
parameters.


Then

y - rbinom( N, 1, pr.undam.1 )
x - rbinom( N, 1, ifelse(y==1, pr.undam.2.undam.1, pr.undam.2.dam.1 )

table(x,y)

should get you started

HTH,

Chuck


I need to simulate similar dataset to do some power calculations.

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and 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

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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Separating variables in read.table

2009-04-17 Thread Richardson, Patrick
If I have a table (we'll call it, test) containing seven columns (as below):

i   x1  x2  x3  x4  x5  y
0   1.125   0.232   7.160   0.0859 8.905 1.5563
7   0.920   0.268   8.804   0.0865 7.388 0.8976
15  0.835   0.271   8.108   0.0852 5.348 0.7482
22  1.000   0.237   6.370   0.0838 8.056 0.7160
29  1.150   0.192   6.441   0.0821 6.960 0.3130
37  0.990   0.202   5.154   0.0792 5.690 0.3617
44  0.840   0.184   5.896   0.0812 6.932 0.1139
58  0.650   0.200   5.336   0.0806 5.400 0.1139


Is there a simple command to break this table into individual variables without 
having to code:

i - test$i
x1 - test$x1
x2 - test$x2
.
.
.
And so on. . 

Many Thank for any assistance.

Patrick
This email message, including any attachments, is for th...{{dropped:6}}

__
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] Separating variables in read.table

2009-04-17 Thread Jorge Ivan Velez
Dear Patrick,

Perhaps attach might be what you are looking for.
attach(test)
i
x1
x2
.
.
.
y

HTH,

Jorge


On Fri, Apr 17, 2009 at 3:23 PM, Richardson, Patrick 
patrick.richard...@vai.org wrote:

 If I have a table (we'll call it, test) containing two columns (as
 below):

 i   x1  x2  x3  x4  x5  y
 0   1.125   0.232   7.160   0.0859 8.905 1.5563
 7   0.920   0.268   8.804   0.0865 7.388 0.8976
 15  0.835   0.271   8.108   0.0852 5.348 0.7482
 22  1.000   0.237   6.370   0.0838 8.056 0.7160
 29  1.150   0.192   6.441   0.0821 6.960 0.3130
 37  0.990   0.202   5.154   0.0792 5.690 0.3617
 44  0.840   0.184   5.896   0.0812 6.932 0.1139
 58  0.650   0.200   5.336   0.0806 5.400 0.1139


 Is there a simple command to break this table into individual variables
 without having to code:

 i - test$i
 x1 - test$x1
 x2 - test$x2
 .
 .
 .
 And so on. .

 Many Thank for any assistance.

 Patrick
 This email message, including any attachments, is for ...{{dropped:13}}

__
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] ColorRamp different from ColorRampPalette

2009-04-17 Thread Etienne B. Racine

I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient), but
it seems there is a nuance that I've missed.

pal.crp-colorRampPalette( c(blue, white, red), space = rgb)
plot(rep(0,40),pch=16,col=pal.crp(40))
# is great

But, using the same gradient with colorRamp is giving erratic colors.

pal.cr-colorRamp( c(blue, white, red), space = rgb)
plot(rep(0,40),pch=16,col=pal.cr((0:40)/40))
# is not great

From the help : colorRamp returns a function that maps values between 0 and
1 to colors ...colors I guess taken from the gradient, but I don't get the
gradient.

Etienne

-- 
View this message in context: 
http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.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] Separating variables in read.table

2009-04-17 Thread Etienne Bellemare Racine
see ?attach

Etienne

Richardson, Patrick a écrit :
 If I have a table (we'll call it, test) containing two columns (as below):

 i x1  x2  x3  x4  x5  y
 0 1.125   0.232   7.160   0.0859 8.905 1.5563
 7 0.920   0.268   8.804   0.0865 7.388 0.8976
 150.835   0.271   8.108   0.0852 5.348 0.7482
 221.000   0.237   6.370   0.0838 8.056 0.7160
 291.150   0.192   6.441   0.0821 6.960 0.3130
 370.990   0.202   5.154   0.0792 5.690 0.3617
 440.840   0.184   5.896   0.0812 6.932 0.1139
 580.650   0.200   5.336   0.0806 5.400 0.1139


 Is there a simple command to break this table into individual variables 
 without having to code:

 i - test$i
 x1 - test$x1
 x2 - test$x2
 .
 .
 .
 And so on. . 

 Many Thank for any assistance.

 Patrick
 This email message, including any attachments, is for ...{{dropped:12}}

__
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] real numeric variable transforms into factor:

2009-04-17 Thread Aldi Kraja
Hi
Test made in: R in windows Vista OS, R version 2.8.1
 From FAQ: 
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f
It may happen that when reading numeric data into R (usually, when 
reading in a file), they come in as factors. If |f| is such a factor 
object, you can use as.numeric(as.character(f)) to get the numbers back.

1: Why it may happen? Why R transforms x1 from real numeric with decimal 
values into factor???
2: Doesn't it look strange to get internal numbers when one applies 
as.numeric(x$x1)?
3. What are the internal numbers mentioned in the FAQ?
Why is needed to write:
as.numeric(as.character(x$x1)) to get finally the right numbers I read 
with read.table?
Are the missing values shown as dot to force R (or the programmer who 
wrote the function read.table) to consider x1 as factor?

Is it possible who is maintaining the read.table function to improve it 
to recognize numbers with decimal places as numeric and not as factors 
and dots as missing values which transform into NA?

The data file saved as text:
test.txt
ob,x1,y1
1,1.1,1/1
2,2.1,1/2
3,3.2,2/2
4,.,0/0
5,4.5,1/1
6,5.1,0/0
7,6.3,1/1
8,.,1/2
reading it from d directory:
x-read.table(file=d:\\test\\test.txt,header=T,sep=',')
  x
  ob  x1  y1
1  1 1.1 1/1
2  2 2.1 1/2
3  3 3.2 2/2
4  4   . 0/0
5  5 4.5 1/1
6  6 5.1 0/0
7  7 6.3 1/1
8  8   . 1/2
  as.numeric(x$x1)
[1] 2 3 4 1 5 6 7 1

  as.numeric(as.character(x$x1))
[1] 1.1 2.1 3.2  NA 4.5 5.1 6.3  NA
Warning message:
NAs introduced by coercion

Thanks,

Aldi



[[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] ColorRamp different from ColorRampPalette

2009-04-17 Thread hadley wickham
Look at the output of pal.cr((0:40)/40)
Hadley

On Fri, Apr 17, 2009 at 2:42 PM, Etienne B. Racine etienn...@gmail.com wrote:

 I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient), but
 it seems there is a nuance that I've missed.

 pal.crp-colorRampPalette( c(blue, white, red), space = rgb)
 plot(rep(0,40),pch=16,col=pal.crp(40))
 # is great

 But, using the same gradient with colorRamp is giving erratic colors.

 pal.cr-colorRamp( c(blue, white, red), space = rgb)
 plot(rep(0,40),pch=16,col=pal.cr((0:40)/40))
 # is not great

 From the help : colorRamp returns a function that maps values between 0 and
 1 to colors ...colors I guess taken from the gradient, but I don't get the
 gradient.

 Etienne

 --
 View this message in context: 
 http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.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.




-- 
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] ColorRamp different from ColorRampPalette

2009-04-17 Thread Etienne B. Racine

Thanks Hadley,

Is it the solution you would recommend ?
rgb(pal.cr((0:40)/40), maxColorValue=255)

Etienne


hadley wrote:
 
 Look at the output of pal.cr((0:40)/40)
 Hadley
 
 On Fri, Apr 17, 2009 at 2:42 PM, Etienne B. Racine etienn...@gmail.com
 wrote:

 I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient),
 but
 it seems there is a nuance that I've missed.

 pal.crp-colorRampPalette( c(blue, white, red), space = rgb)
 plot(rep(0,40),pch=16,col=pal.crp(40))
 # is great

 But, using the same gradient with colorRamp is giving erratic colors.

 pal.cr-colorRamp( c(blue, white, red), space = rgb)
 plot(rep(0,40),pch=16,col=pal.cr((0:40)/40))
 # is not great

 From the help : colorRamp returns a function that maps values between 0
 and
 1 to colors ...colors I guess taken from the gradient, but I don't get
 the
 gradient.

 Etienne

 --
 View this message in context:
 http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.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.

 
 
 
 -- 
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23105080.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] Separating variables in read.table

2009-04-17 Thread Phil Spector

Patrick -
   There's no simple way to do what you want, because
R discourages you from having lots of separate
related objects.  Instead, you are encouraged to store
your objects in an organized form, such as a list, 
data frame  or matrix.  For your example, I'm assuming 
you are using the word table to describe a data.frame. 
If this is the case , you can refer to the individual

columns of test as

test[,1]
test[,2]
  etc.

or

test$x1
test$x2
  etc.

or

test[,'x1']
test[,'x2']

Also remember that R has functions that can operate on
each row or column of a matrix or data frame.  So if you 
wanted the means of each column of test, you could write


apply(test,2,mean)
   - Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Fri, 17 Apr 2009, Richardson, Patrick wrote:


If I have a table (we'll call it, test) containing two columns (as below):

i   x1  x2  x3  x4  x5  y
0   1.125   0.232   7.160   0.0859 8.905 1.5563
7   0.920   0.268   8.804   0.0865 7.388 0.8976
15  0.835   0.271   8.108   0.0852 5.348 0.7482
22  1.000   0.237   6.370   0.0838 8.056 0.7160
29  1.150   0.192   6.441   0.0821 6.960 0.3130
37  0.990   0.202   5.154   0.0792 5.690 0.3617
44  0.840   0.184   5.896   0.0812 6.932 0.1139
58  0.650   0.200   5.336   0.0806 5.400 0.1139


Is there a simple command to break this table into individual variables without 
having to code:

i - test$i
x1 - test$x1
x2 - test$x2
.
.
.
And so on. .

Many Thank for any assistance.

Patrick
This email message, including any attachments, is for th...{{dropped:6}}

__
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] real numeric variable transforms into factor:

2009-04-17 Thread Marc Schwartz

On Apr 17, 2009, at 2:52 PM, Aldi Kraja wrote:


Hi
Test made in: R in windows Vista OS, R version 2.8.1
From FAQ:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f
It may happen that when reading numeric data into R (usually, when
reading in a file), they come in as factors. If |f| is such a factor
object, you can use as.numeric(as.character(f)) to get the numbers  
back.


1: Why it may happen? Why R transforms x1 from real numeric with  
decimal

values into factor???
2: Doesn't it look strange to get internal numbers when one applies
as.numeric(x$x1)?
3. What are the internal numbers mentioned in the FAQ?
Why is needed to write:
as.numeric(as.character(x$x1)) to get finally the right numbers I read
with read.table?
Are the missing values shown as dot to force R (or the programmer who
wrote the function read.table) to consider x1 as factor?

Is it possible who is maintaining the read.table function to improve  
it

to recognize numbers with decimal places as numeric and not as factors
and dots as missing values which transform into NA?

The data file saved as text:
test.txt
ob,x1,y1
1,1.1,1/1
2,2.1,1/2
3,3.2,2/2
4,.,0/0
5,4.5,1/1
6,5.1,0/0
7,6.3,1/1
8,.,1/2
reading it from d directory:
x-read.table(file=d:\\test\\test.txt,header=T,sep=',')

x

 ob  x1  y1
1  1 1.1 1/1
2  2 2.1 1/2
3  3 3.2 2/2
4  4   . 0/0
5  5 4.5 1/1
6  6 5.1 0/0
7  7 6.3 1/1
8  8   . 1/2

as.numeric(x$x1)

[1] 2 3 4 1 5 6 7 1


as.numeric(as.character(x$x1))

[1] 1.1 2.1 3.2  NA 4.5 5.1 6.3  NA
Warning message:
NAs introduced by coercion

Thanks,

Aldi


Looks like you are taking data from SAS perhaps, where the missing  
value indicator is '.'.  In R, where type.convert() is used to  
determine the data types for incoming text data, you get:


 type.convert(.)
[1] .
Levels: .

That is, a factor.

What you want to do is to set the 'na.strings' argument to  
read.table() to '.' rather than the default 'NA', so that the periods  
are interpreted as missing values and set to NA during import. Thus:


# Create from your data in the clipboard (on OSX)
DF - read.table(pipe(pbpaste), header = TRUE, sep = ,, na.strings  
= .)


 DF
  ob  x1  y1
1  1 1.1 1/1
2  2 2.1 1/2
3  3 3.2 2/2
4  4  NA 0/0
5  5 4.5 1/1
6  6 5.1 0/0
7  7 6.3 1/1
8  8  NA 1/2

 str(DF)
'data.frame':   8 obs. of  3 variables:
 $ ob: int  1 2 3 4 5 6 7 8
 $ x1: num  1.1 2.1 3.2 NA 4.5 5.1 6.3 NA
 $ y1: Factor w/ 4 levels 0/0,1/1,1/2,..: 2 3 4 1 2 1 2 3

This is now because:

 type.convert(., na.strings = .)
[1] NA


See ?read.table and ?type.convert for more information.

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.


Re: [R] Separating variables in read.table

2009-04-17 Thread Johannes Huesing
Richardson, Patrick patrick.richard...@vai.org [Fri, Apr 17, 2009 at 
09:31:35PM CEST]:
 If I have a table (we'll call it, test) containing seven columns (as below):
 
 i x1  x2  x3  x4  x5  y
 0 1.125   0.232   7.160   0.0859 8.905 1.5563
 7 0.920   0.268   8.804   0.0865 7.388 0.8976
 150.835   0.271   8.108   0.0852 5.348 0.7482
 221.000   0.237   6.370   0.0838 8.056 0.7160
 291.150   0.192   6.441   0.0821 6.960 0.3130
 370.990   0.202   5.154   0.0792 5.690 0.3617
 440.840   0.184   5.896   0.0812 6.932 0.1139
 580.650   0.200   5.336   0.0806 5.400 0.1139
 
 
 Is there a simple command to break this table into individual variables 
 without having to code:
 
 i - test$i
 x1 - test$x1
 x2 - test$x2

?attach

Does this do what you want?


-- 
Johannes Hüsing   There is something fascinating about science. 
  One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.  
  
http://derwisch.wikidot.com (Mark Twain, Life on the Mississippi)

__
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   >