Re: [R] Problem with retreaving numeric data

2010-02-11 Thread Dieter Menne


dvkirankumar wrote:
 
 I am trying to get a value from a dataset in data set its stored as  001
 but while i am trying to retreave it its giving as 1 can any one help me
 to retreave it  as 001
 

I have to guess if you used a boomerang or a sling to retrieve your data. My
blind guess is you used read.table, or odbc.

Assuming read.table: use the parameter colClasses to force that column to be
read in as a string instead of a number. The function uses the first few
lines to guess the data type, which can be wrong.

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Problem-with-retreaving-numeric-data-tp1476934p1476943.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] Running rscript in windows

2010-02-11 Thread Peter Ehlers

How did you change directory? Does dir() show that your
directory is the desktop? Presumably the desktop folder
is something like C:/Users/someone/Desktop. Sourcing
test.R from there should work. But the simplest way is

 source(file.choose())

and then navigate to where test.R is located.

 -Peter Ehlers

vikrant wrote:

Hi,

I saved the function in test.R file on Desktop. Then after starting R I
changed my directory to desktop.
and tried the command source(test.R) it gave me following error



Error in file(file, r, encoding = encoding) : 
  cannot open the connection

In addition: Warning message:
In file(file, r, encoding = encoding) :
  cannot open file 'test.R': No such file or directory


--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Proxy settings

2010-02-11 Thread Van Wyk, Jaap
Thanks, especially to Greg for the help with the proxy settings required for 
Windows.
I have managed to solve the problem, with Greg's latest suggestion.
Jacob


Jacob L van Wyk
Department of Statistics
University of Johannesburg (APK)
PO Box 524, Auckland Park, 2006
Office ph: 011 559 3080
Fax: 011 559 2499



This email and all contents are subject to the following disclaimer:

http://www.uj.ac.za/UJ_email_legal_disclaimer.htm

[[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] question about boxplot,does it accept ad hoc data

2010-02-11 Thread Dieter Menne


Guanhua Chen wrote:
 
 
 I have a question about boxplot(), does it accept ad hoc data , for
 example,
 I only provide quartile information to the function,but get the boxplot as
 usual, is it possible , or if there is any other function can do this.
 Thank
 you very much!
 

boxplot calls bxp which is documented and accepts the summary data for
plotting.

Dieter


-- 
View this message in context: 
http://n4.nabble.com/question-about-boxplot-does-it-accept-ad-hoc-data-tp1476784p1476949.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] Problem with retreaving numeric data

2010-02-11 Thread Daniel Malter
My guess is that you cannot keep it numeric, but that you have to convert it
to a string (the gurus may know better).

x=001
x

x=001
x

Daniel

-
cuncta stricte discussurus
-
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of venkata kirankumar
Sent: Thursday, February 11, 2010 2:47 AM
To: r-help@r-project.org
Subject: [R] Problem with retreaving numeric data

Hi all,
I am trying to get a value from a dataset
in data set its stored as  001
but while i am trying to retreave it its giving as 1
can any one help me to retreave it  as 001

thanks in advance
kiran

[[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] Question about rank() function

2010-02-11 Thread Daniel Malter
To follow up on Moshe's post, do 

rank(fmodel)
rank(round(fmodel,4))
rank(fmodel)==rank(round(fmodel,4))

If the two are not identical, you have the explanation Moshe suggested, just
that this approach is somewhat more comprehensive as it works on the entire
fmodel vector. See the example below:

x=c(1.0001,1.0002,1.0003,1.0004,2.0001,2.0002,2.0003,3.0001,3.0002,4)

rank(x)
rank(round(x,2))
rank(x)==rank(round(x,2))

HTH,
Daniel



-
cuncta stricte discussurus
-

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Something Something
Sent: Thursday, February 11, 2010 2:23 AM
To: r-help@r-project.org
Subject: [R] Question about rank() function

Hello,

I am trying to get the 'rank' function to work for me, but not sure what I
am doing wrong.  Please help.

I ran the following commands:

data = read.table(test1.csv, head=T, as.is=T, na.string=., row.nam=NULL)
X1 = as.factor(data[[3]])
X2 = as.factor(data[[4]])
X3 = as.factor(data[[5]])
Y = data[[2]]
model = lm(Y ~ X1*X2*X3, na.action = na.exclude)
fmodel = fitted(model)
fmodel
(First line is shown below.)


   12345678
   9   10   11   12   13   14   15   16
17
180.3763 180.3763 180.3763 180.3763 180.4546 180.3763 177.9245 177.9245
181.3859 180.3763   NA 180.4546 180.3763 180.4546 180.3763 180.3763
180.4546

Then I run:
fmodel.rank = rank(fmodel)
fmodel.rank
(First line is shown below)

1 2 3 4 5 6 7 8 9101112
 13141516171819202122232425
   26
375.0 222.0  68.5  68.5 402.5 222.0  33.5  33.5 465.5 222.0 500.0 402.5
222.0 402.5 222.0 222.0 378.5 222.0 222.0 222.0 222.0 222.0 402.5 222.0
 33.5 222.0


As you can see, first 4 values of 'fmodel' are 180.3763, so after running
rank(fmodel) I expected the ranks of first 4 to be the same, but they are
not.  What am I doing wrong?  Please let me know.  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.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS and RODBC

2010-02-11 Thread Daniel Nordlund
I am using R-2.10.1 binary from CRAN on a WinXP Pro system.  I also use SAS 
v9.2 on the same box.  I just started using the SAS ODBC driver that comes with 
version 9 of SAS.  I have been able to set up an ODBC source for SAS datasets 
using the driver, and then with RODBC I am able to read a sample SAS dataset.

 library(RODBC)
 ch - odbcConnect('sasodbc', believeNRows=FALSE)
 df - sqlQuery(ch, 'select * from sasodbc.class', as.is=TRUE)
 df
  Name Sex Age Height Weight
1   Alfred   M  14   69.0  112.5
2Alice   F  13   56.5   84.0
3  Barbara   F  13   65.3   98.0
4Carol   F  14   62.8  102.5
5Henry   M  14   63.5  102.5
6James   M  12   57.3   83.0
7 Jane   F  12   59.8   84.5
8Janet   F  15   62.5  112.5
9  Jeffrey   M  13   62.5   84.0
10John   M  12   59.0   99.5
11   Joyce   F  11   51.3   50.5
12Judy   F  14   64.3   90.0
13  Louise   F  12   56.3   77.0
14Mary   F  15   66.5  112.0
15  Philip   M  16   72.0  150.0
16  Robert   M  12   64.8  128.0
17  Ronald   M  15   67.0  133.0
18  Thomas   M  11   57.5   85.0
19 William   M  15   66.5  112.0

 str(df)
'data.frame':   19 obs. of  5 variables:
 $ Name  : chr  Alfred Alice Barbara Carol ...
 $ Sex   : chr  M F F F ...
 $ Age   : num  14 13 13 14 14 12 12 15 13 12 ...
 $ Height: num  69 56.5 65.3 62.8 63.5 57.3 59.8 62.5 62.5 59 ...
 $ Weight: num  112 84 98 102 102 ...


However, I am not able to save a dataframe back to a SAS dataset.  When I try 
to use sqlSave I get the following error.

 sqlSave(ch, df, tablename='sasodbc.class2')
Error in sqlSave(ch, df, tablename = sasodbc.class2) : 0 0 
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE sasodbc.class2  
(rownames varchar(255), Name varchar(255), Sex varchar(255), Age num, 
Height num, Weight num)'


Can anyone suggest how I might go about tracking down the problem?  I don't 
know much about ODBC in general or what RODBC is doing under the hood, or how 
the SAS ODBC driver is written, but it would be useful if I could get R to 
write SAS datasets, and not just read them.

Thanks,

Dan

Daniel Nordlund
Bothell, WA USA
 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ff package: How to save and open ff(df) files.

2010-02-11 Thread daniel castro
Hello to everyone,

I'm a newbie with ff package and I´m starting to use it. I´ve been reading
the ff.pdf guide and another documents and questions , but I´m really
confused about some procedures I can´t see how to do. I´d want to know if
it´s possible (and how)  to save a ffdf file(s) and open it in another
session, via saving it in an permanet location.

Let´s supose we´re reading from a text file to a ffdf object, with
read.table.ffdf and we want to save the files and information in a permanent
path and file. First of all I read about GetOption(fftempdir) but I don´t
know how to change this parameter. I read also about the pattern option, and
I asume that this option changes the prefix of the files created phisically
under the ffdf object. Isn´t it? Can I use this parameter to create a
permanent location (via putting the entire path) for the files? Can I use
this option after reading the file as ffdf , applying the pattern to the
ffdf object I created before?

The next and related quetion is, if I can save the files in a permanent
location , how can I load them? Can I use the generic load of an image of
the R session?

Thanks in advance for reading this question and please apologize if my
english is not very accurate and/or  the question is too simple.

Regards
Daniel.

[[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] Running rscript in windows

2010-02-11 Thread vikrant

Thanks a lot, really. dir() option showd my desktop files and test.R was
shown as test.R.txt
when I run source(test.R.txt) it worked.

Just for your information,
I changed the directory using Menu options File- change dir.
I verified the same using getwd() command in R. '


-- 
View this message in context: 
http://n4.nabble.com/Running-rscript-in-windows-tp1475671p1476962.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] SAS and RODBC

2010-02-11 Thread Prof Brian Ripley

On Thu, 11 Feb 2010, Daniel Nordlund wrote:


I am using R-2.10.1 binary from CRAN on a WinXP Pro system.  I also use SAS 
v9.2 on the same box.  I just started using the SAS ODBC driver that comes with 
version 9 of SAS.  I have been able to set up an ODBC source for SAS datasets 
using the driver, and then with RODBC I am able to read a sample SAS dataset.


library(RODBC)
ch - odbcConnect('sasodbc', believeNRows=FALSE)
df - sqlQuery(ch, 'select * from sasodbc.class', as.is=TRUE)
df

 Name Sex Age Height Weight
1   Alfred   M  14   69.0  112.5
2Alice   F  13   56.5   84.0
3  Barbara   F  13   65.3   98.0
4Carol   F  14   62.8  102.5
5Henry   M  14   63.5  102.5
6James   M  12   57.3   83.0
7 Jane   F  12   59.8   84.5
8Janet   F  15   62.5  112.5
9  Jeffrey   M  13   62.5   84.0
10John   M  12   59.0   99.5
11   Joyce   F  11   51.3   50.5
12Judy   F  14   64.3   90.0
13  Louise   F  12   56.3   77.0
14Mary   F  15   66.5  112.0
15  Philip   M  16   72.0  150.0
16  Robert   M  12   64.8  128.0
17  Ronald   M  15   67.0  133.0
18  Thomas   M  11   57.5   85.0
19 William   M  15   66.5  112.0


str(df)

'data.frame':   19 obs. of  5 variables:
$ Name  : chr  Alfred Alice Barbara Carol ...
$ Sex   : chr  M F F F ...
$ Age   : num  14 13 13 14 14 12 12 15 13 12 ...
$ Height: num  69 56.5 65.3 62.8 63.5 57.3 59.8 62.5 62.5 59 ...
$ Weight: num  112 84 98 102 102 ...


However, I am not able to save a dataframe back to a SAS dataset.  When I try 
to use sqlSave I get the following error.


sqlSave(ch, df, tablename='sasodbc.class2')

Error in sqlSave(ch, df, tablename = sasodbc.class2) : 0 0
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE sasodbc.class2  (rownames varchar(255), Name varchar(255), 
Sex varchar(255), Age num, Height num, Weight num)'


Can anyone suggest how I might go about tracking down the problem? 
I don't know much about ODBC in general or what RODBC is doing under 
the hood, or how the SAS ODBC driver is written, but it would be 
useful if I could get R to write SAS datasets, and not just read 
them.


What 'RODBC is doing under the hood' is in that error message: sending 
an SQL query to create a table.  Unfortunately, the SAS ODBC driver is 
not returning a useful error message, and this really becomes a 
question for SAS support.  Maybe that function is not supported, the 
connection is read-only, the SAS dialect requires different quotes 
(although RODBC asked the driver about quoting) ... only someone 
familiar with the ODBC driver will know.


This is really off-topic here: r-sig-db would be more appropriate but 
only marginally so,



Thanks,

Dan

Daniel Nordlund
Bothell, WA USA


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Regarding a error while plotting R chart using qcc package.

2010-02-11 Thread Luca Scrucca

On 11 Feb 2010, at 06:53, Vikrant Shimpi wrote:


Dear Luka ,
 I am using qcc package in R to plot SPC charts. BUt while plotting  
R  chart I had a error. My question is it necessary while plotting   
R Chart the group sample size must be  25 ?. Because when I took  
group sample size as 1000 it gave me error, till I took group sample  
size as 26, But as sooon as I changed the group sample size to 25  
the R chart was plotted successfully.
I had a discussion in the R forum, at the end of it was suggested to  
write to you regarding the error. I am giving the link for the same.



http://n4.nabble.com/problems-with-SPC-charts-in-R-td1467901.html#a1469800



Also I am attaching the dataset and the code which gave me error  
while plotting R chart.


R code is as follows: -

SAMPLE_SIZE-1000
y-read.csv(data.csv,sep=,,header=TRUE)
y-subset(y, !is.null(y[,1]),)
unique_b_vals = unique(y[,2])
final_set - NULL
for(b_val in unique_b_vals)
{
temp1 = subset(y,week==b_val,)
temp1 = temp1[sample(dim(temp1)[1], SAMPLE_SIZE),]
if (is.null(final_set))
 final_set - temp1
else
 final_set - rbind(final_set,temp1)
print(b_val)
}


First of all, here I got an error:

Error in sample(dim(temp1)[1], SAMPLE_SIZE) :
  cannot take a sample larger than the population when 'replace =  
FALSE'


The final_set matrix has however dimension

 dim(final_set)
[1] 17000 3

and I will continue with this.


library(qcc)
attach(final_set)
a- qcc.groups(ST,week)
dim(a)
obj - qcc(a[,],type=R)

summary(obj)
detach(final_set)


Here I am selecting a sample of size 1000 for each group. And it  
gives me following error



Error in limits.R(center = 62614.0571428571, std.dev = NA_real_,  
sizes = c(1000L,  :

group size must be less than 51 when giving nsigmas



Yes and it must be like that. You shouldn't use R charts for  
monitoring dispersion using sample sizes larger than 20, and for  
sample sizes greater than 25 you get an error. From theory, R chart  
used the distribution of relative range for estimating sigma, which is  
tabulated up to a sample size of 25


 qcc.options(exp.R.unscaled)

The number 51 comes from another tabulated data

 qcc.options(se.R.unscaled)

In this case you must simply use an S chart:

 obj - qcc(a,type=S)


Some sparse notes:
- don't use a[,] to select a whole matrix, simply a, i.e. qcc(a)
- don't use - for assignment (it has another meaning...), - is enough

I hope this help.

Luca Scrucca


--
Luca Scrucca
Dipartimento di Economia, Finanza e Statistica
Sezione di Statistica
Università degli Studi di Perugia
Via A. Pascoli, 20
06123 PERUGIA  (ITALY)
Tel. +39-075-5855233
Fax: +39-075-5855950
E-mail:   l...@stat.unipg.it
Web page: http://www.stat.unipg.it/luca

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] SAS and RODBC

2010-02-11 Thread Gabor Grothendieck
There is a SASxport package on CRAN that may be of interest.

On Thu, Feb 11, 2010 at 3:38 AM, Daniel Nordlund djnordl...@verizon.net wrote:
 I am using R-2.10.1 binary from CRAN on a WinXP Pro system.  I also use SAS 
 v9.2 on the same box.  I just started using the SAS ODBC driver that comes 
 with version 9 of SAS.  I have been able to set up an ODBC source for SAS 
 datasets using the driver, and then with RODBC I am able to read a sample SAS 
 dataset.

 library(RODBC)
 ch - odbcConnect('sasodbc', believeNRows=FALSE)
 df - sqlQuery(ch, 'select * from sasodbc.class', as.is=TRUE)
 df
      Name Sex Age Height Weight
 1   Alfred   M  14   69.0  112.5
 2    Alice   F  13   56.5   84.0
 3  Barbara   F  13   65.3   98.0
 4    Carol   F  14   62.8  102.5
 5    Henry   M  14   63.5  102.5
 6    James   M  12   57.3   83.0
 7     Jane   F  12   59.8   84.5
 8    Janet   F  15   62.5  112.5
 9  Jeffrey   M  13   62.5   84.0
 10    John   M  12   59.0   99.5
 11   Joyce   F  11   51.3   50.5
 12    Judy   F  14   64.3   90.0
 13  Louise   F  12   56.3   77.0
 14    Mary   F  15   66.5  112.0
 15  Philip   M  16   72.0  150.0
 16  Robert   M  12   64.8  128.0
 17  Ronald   M  15   67.0  133.0
 18  Thomas   M  11   57.5   85.0
 19 William   M  15   66.5  112.0

 str(df)
 'data.frame':   19 obs. of  5 variables:
  $ Name  : chr  Alfred Alice Barbara Carol ...
  $ Sex   : chr  M F F F ...
  $ Age   : num  14 13 13 14 14 12 12 15 13 12 ...
  $ Height: num  69 56.5 65.3 62.8 63.5 57.3 59.8 62.5 62.5 59 ...
  $ Weight: num  112 84 98 102 102 ...


 However, I am not able to save a dataframe back to a SAS dataset.  When I try 
 to use sqlSave I get the following error.

 sqlSave(ch, df, tablename='sasodbc.class2')
 Error in sqlSave(ch, df, tablename = sasodbc.class2) : 0 0
 [RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE sasodbc.class2  
 (rownames varchar(255), Name varchar(255), Sex varchar(255), Age num, 
 Height num, Weight num)'


 Can anyone suggest how I might go about tracking down the problem?  I don't 
 know much about ODBC in general or what RODBC is doing under the hood, or how 
 the SAS ODBC driver is written, but it would be useful if I could get R to 
 write SAS datasets, and not just read them.

 Thanks,

 Dan

 Daniel Nordlund
 Bothell, WA USA


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] R2HTML

2010-02-11 Thread Regina Schinner
I am using R 2.10.1 for Mac OS.

But Bart's Tip to use 'HTML(summary(iris))' completely solved the problem.

Thanks to everybody for helping.
Regina



Am 10.02.2010 um 20:01 schrieb Greg Snow:

 When I copy/paste/run your code below I get a file with the summary output in 
 a nice table.  Telling us your version, operating system, and other 
 information requested in the posting guide may help.
 
 -- 
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Regina Schinner
 Sent: Wednesday, February 10, 2010 1:44 AM
 To: r-help@r-project.org
 Subject: [R] R2HTML
 
 I am having difficulties with R2HTML. If I try to generate a HTML file
 with the below code, the titles, horizontal line, and scatter plot are
 there, but the data summary [summary(iris)] is not.
 
 ---
 
 library(R2HTML)
 HTMLStart(file=myreport, extension=html, echo=FALSE,
 HTMLframe=TRUE)
 
 HTML.title(Data Description, HR=3)
 summary(iris)
 
 HTMLhr()
 
 HTML.title(Scatter Plot, HR=3)
 plot(iris$Sepal.Length~iris$Sepal.Width)
 HTMLplot()
 
 HTMLStop()
 
 ---
 
 How do I add summary data to a HTML file?
 
 Thanks for any help you can provide
 Regina Schinner
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] ZOO object colnames refering to Dates

2010-02-11 Thread Research

Hello,

I have  large zoo objects (about 100 or more time series merged next to 
eachother). Example:


X05.Oct.99 X05.Nov.99 X05.Dec.99 X05.Jan.00 X05.Feb.00 X05.Mar.00 
X05.Apr.00 X05.May.00 X05.Jun.00
[1,] 5649.3 5679.4 5679.4 5679.4 5679.4 
5679.4 5679.4 5679.4 5679.4
[2,] 5682.7 5719.2 5719.2 5719.2 5719.2 
5719.2 5719.2 5719.2 5719.2
[3,] 5697.5 5745.5 5745.5 5745.5 5745.5 
5745.5 5745.5 5745.5 5745.5
[4,] 5723.9 5767.8 5767.8 5767.8 5767.8 
5767.8 5767.8 5767.8 5767.8
[5,] 5782.1 5829.8 5829.8 5829.8 5829.8 
5829.8 5829.8 5829.8 5829.8
[6,] 5815.0 5850.9 5850.9 5850.9 5850.9 
5850.9 5850.9 5850.9 5850.9



The column names contain dates, i.e.,  X05.Oct.99 stands for a time 
sequence that was obtained on 05/10/1999. Each column is obtained  month 
+ 1 from the previous one.


Is it possible to access these columns (time series data) via a for/next 
loop (or a while) that uses dates i/o (i in 1:8) in the above example?


Say: if month==Oct and year==1999 choose column X05.Oct.99 ...

Could I also generate automatically a variable, appropriately named from 
the corresponding columns name that would contain the data and access it 
by that date?


Any pointers really appreciated.

Thanks in advance,
Costas


__ Information from ESET Smart Security, version of virus signature 
database 4857 (20100211) __

The message was checked by ESET Smart Security.

http://www.eset.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] Sweve/cacheSweave

2010-02-11 Thread Unger, Kristian
Hi there

I have a problem with using Sweave in combination with the option driver = 
cacheSweave.

Whichever code I try to run  - when it comes to converting the tex file into 
pdf it comes up with the same errors (\csname \endcsname errors). Does anybody 
have an idea what it going wrong?

 Sweave(pgfSweave-example.Rnw,driver  =  cacheSweaveDriver)
Writing to file pgfSweave-example.tex
Processing code chunks ...
 1 : term verbatim (label=setup)
 2 : echo term verbatim (label=data)
 3 : term verbatim eps pdf (label=boxplot)

You can now run LaTeX on 'pgfSweave-example.tex'

 tools::texi2dvi(pgfSweave-example.tex, pdf=TRUE)
Error in tools::texi2dvi(pgfSweave-example.tex, pdf = TRUE) :
  running 'texi2dvi' on 'pgfSweave-example.tex' failed

LaTeX errors:
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: LaTeX E
rror: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H return  for immediate help
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.


C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.

I am running this under Windows XP, R version 2.9.2 (2009-08-24),  
package.version(cacheSweave)
[1] 0.4-3.

Any help or advice on this would be highly appreciated!

Best wishes

Kristian

_

Dr Kristian Unger

Bioinformaticist Chernobyl Tissue Bank

Division of Surgery and Cancer

Imperial College London

Rm G02, Ground floor G Block
Hammersmith Hospital
Du Cane Road,
London W12 0HS

Tel +44-20-8383-2443

Mob +44-795-1080619

Skype kristianunger

http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
http://www.chernobyltissuebank.com


[[alternative HTML version deleted]]

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


[R] Biclustering package

2010-02-11 Thread Alex Roy
Hello,
   I am looking for R package which can perform biclustering a part
from biclust package.

thanks

Alex

[[alternative HTML version deleted]]

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


Re: [R] Sweave, lty = 3 line incorect in pdf output

2010-02-11 Thread Achim Zeileis

Ken,

I can't contribute much, just that I tried to look into it and can't 
replicate it. I tried it both with .Stex and .Rnw yielding identical 
results, just like plotting it interactively (on my default X11) and 
printing it via dev.copy2pdf(). All of the approaches seemed to yield the 
same output which looks ok.


Just for the record...
Z

R sessionInfo()
R version 2.10.1 (2009-12-14)
i486-pc-linux-gnu

locale:
[1] C

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

other attached packages:
[1] fortunes_1.3-7


On Thu, 11 Feb 2010, Ken Knoblauch wrote:


I'm having a problem with dotted lines (lty = 3) in the pdf output
in documents generated with Sweave.  In the displayed pdf, the
dotted line does not show up and in the printed output, it is
there but does not seem to respect the lwd argument, for example, it
is very faint despite using lwd = 3.  The dotted line is correct
in a quartz window and if I save the Quartz window to a pdf
and include it in the tex document, then the dotted line is there
at the correct line width.  Here is a short example, using the Stex
convention for Sweave.  I saved the quartz window in a file called
quartzSave.pdf after running the document through Sweave a first
time without the \includegraphics{quartzSave} line.

\documentclass[10pt]{article}
\usepackage{graphicx}

\begin{document}

Test of lty = 3 argument.

\begin{Scode}{fig=TRUE,eps=FALSE}
x - 1:10
plot(x, type = l, lty = 3, lwd = 3)
lines(x, 0.5 * x, type = l)
\end{Scode}

Saved from Quartz window:

\includegraphics{quartzSave}


\end{document}

I have attached the pdf created by Sweave (which is missing the dotted
lines) in case it can get through the filter to R-help.

sessionInfo()
R version 2.10.1 Patched (2010-02-01 r51089)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

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

Thanks for any help.

Ken

--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.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] Biclustering package

2010-02-11 Thread Gábor Csárdi
Alex, the isa2 package implements the biclustering algorithm discussed in
Bergmann S, Ihmels J, and Barkai N. Iterative signature algorithm for
the analysis of large-scale gene expression data. Phys Rev E Stat
Nonlin Soft Matter Phys 2003 Mar; 67(3 Pt 1) 031902

Best,
Gabor

On Thu, Feb 11, 2010 at 10:51 AM, Alex Roy alexroy2...@gmail.com wrote:
 Hello,
           I am looking for R package which can perform biclustering a part
 from biclust package.

 thanks

 Alex

        [[alternative HTML version deleted]]

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




-- 
Gabor Csardi gabor.csa...@unil.ch UNIL DGM

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected output in first iteration of for-loop

2010-02-11 Thread Chaehan So
Ok, you're right -  may I rephrase:
How should I modify the assignment of result - latentVariableNames
so it produces the output without the first line?
I thought result - NULL should do the job, but it didn't because of the
following names(result) assignment (which I understand, but not how I
can workaround it).

Here's the output and code again:

  latentVariable   Indiv Group
1  rPlanning rIterat  rTDD
2  rPlanning0.79  0.84
3rIterat0.79  0.83
4   rTDD 0.9  0.96
5   rStandup0.83  0.82
6rRetros 0.9  0.95
7rAccess0.91  0.92
8   rAccTest0.87   0.9

#
LV - c(rPlanning, rIterat, rTDD, rStandup, rRetros, rAccess,
rAccTest)
#
loopCronbach - function(latentVariableNames, groupingVariable)
{
result - latentVariableNames
names(result) - c(latentVariable, Indiv, Group)
 for (currentName in latentVariableNames)
{
print(currentName)
print(result)
tmp1 - calculateIndividualCronbach(get(currentName))
tmp2 - calculateGroupCronbach(get(currentName), groupingVariable)
result - rbind(result,data.frame(latentVariable=currentName,
Indiv=tmp1,Group=tmp2))
}
return(result)
}

On Thu, Feb 11, 2010 at 3:31 AM, jim holtman jholt...@gmail.com wrote:

 It doing exactly what you asked it to do.  You have the assignment:

 result - latentVariableNames

 and then you print it out in the loop.  What were you expecting?

 On Wed, Feb 10, 2010 at 9:06 PM, Chaehan So chaehan...@gmail.com wrote:
  Dear r-helpers,
 
  why do I get an output in the first iteration of the for-loop
  which contains the string values of the input vector,
  and how can I avoid that?
 
  Here's the output (only line 1 is wrong)
 
   latentVariable   Indiv Group
  1  rPlanning rIterat  rTDD
  2  rPlanning0.79  0.84
  3rIterat0.79  0.83
  4   rTDD 0.9  0.96
  5   rStandup0.83  0.82
  6rRetros 0.9  0.95
  7rAccess0.91  0.92
  8   rAccTest0.87   0.9
 
  #
  LV - c(rPlanning, rIterat, rTDD, rStandup, rRetros, rAccess,
  rAccTest)
  #
  loopCronbach - function(latentVariableNames, groupingVariable)
  {
  result - latentVariableNames
  names(result) - c(latentVariable, Indiv, Group)
   for (currentName in latentVariableNames)
  {
  print(currentName)
  print(result)
  tmp1 - calculateIndividualCronbach(get(currentName))
  tmp2 - calculateGroupCronbach(get(currentName), groupingVariable)
  result - rbind(result,data.frame(latentVariable=currentName,
  Indiv=tmp1,Group=tmp2))
  }
  return(result)
  }
 
 
  a - loopCronbach(LV, u_proj)
 
 [[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?




-- 
Humboldt University Berlin, Germany
Institute of Psychology
Rudower Chaussee 18, Room 1221
12489 Berlin
Germany
Office: +49 30 2093 - 9337
Mobile: +49 171- 626 9373

[[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] Sweave, lty = 3 line incorect in pdf output

2010-02-11 Thread Ken Knoblauch

Hi Achim,

Thanks for trying.  Maybe, it's a Mac-thing.  I'll wait to
see if I get other replies.  It's strange, as the quartz
graphic is correct but the pdf produced by Sweave doesn't
contain the dotted line, with the caveat, on my Mac for the
moment.

Ken

Quoting Achim Zeileis achim.zeil...@uibk.ac.at:


Ken,

I can't contribute much, just that I tried to look into it and can't
replicate it. I tried it both with .Stex and .Rnw yielding identical
results, just like plotting it interactively (on my default X11) and
printing it via dev.copy2pdf(). All of the approaches seemed to yield
the same output which looks ok.

Just for the record...
Z

R sessionInfo()
R version 2.10.1 (2009-12-14)
i486-pc-linux-gnu

locale:
[1] C

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

other attached packages:
[1] fortunes_1.3-7


On Thu, 11 Feb 2010, Ken Knoblauch wrote:


I'm having a problem with dotted lines (lty = 3) in the pdf output
in documents generated with Sweave.  In the displayed pdf, the
dotted line does not show up and in the printed output, it is
there but does not seem to respect the lwd argument, for example, it
is very faint despite using lwd = 3.  The dotted line is correct
in a quartz window and if I save the Quartz window to a pdf
and include it in the tex document, then the dotted line is there
at the correct line width.  Here is a short example, using the Stex
convention for Sweave.  I saved the quartz window in a file called
quartzSave.pdf after running the document through Sweave a first
time without the \includegraphics{quartzSave} line.

\documentclass[10pt]{article}
\usepackage{graphicx}

\begin{document}

Test of lty = 3 argument.

\begin{Scode}{fig=TRUE,eps=FALSE}
x - 1:10
plot(x, type = l, lty = 3, lwd = 3)
lines(x, 0.5 * x, type = l)
\end{Scode}

Saved from Quartz window:

\includegraphics{quartzSave}


\end{document}

I have attached the pdf created by Sweave (which is missing the dotted
lines) in case it can get through the filter to R-help.

sessionInfo()
R version 2.10.1 Patched (2010-02-01 r51089)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

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

Thanks for any help.

Ken

--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html








--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.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] ZOO object colnames refering to Dates

2010-02-11 Thread Achim Zeileis

On Thu, 11 Feb 2010, Research wrote:


Hello,

I have  large zoo objects (about 100 or more time series merged next to 
eachother). Example:


   X05.Oct.99 X05.Nov.99 X05.Dec.99 X05.Jan.00 X05.Feb.00 X05.Mar.00 
X05.Apr.00 X05.May.00 X05.Jun.00
[1,] 5649.3 5679.4 5679.4 5679.4 5679.4 5679.4 
5679.4 5679.4 5679.4
[2,] 5682.7 5719.2 5719.2 5719.2 5719.2 5719.2 
5719.2 5719.2 5719.2
[3,] 5697.5 5745.5 5745.5 5745.5 5745.5 5745.5 
5745.5 5745.5 5745.5
[4,] 5723.9 5767.8 5767.8 5767.8 5767.8 5767.8 
5767.8 5767.8 5767.8
[5,] 5782.1 5829.8 5829.8 5829.8 5829.8 5829.8 
5829.8 5829.8 5829.8
[6,] 5815.0 5850.9 5850.9 5850.9 5850.9 5850.9 
5850.9 5850.9 5850.9




The column names contain dates, i.e.,  X05.Oct.99 stands for a time sequence 
that was obtained on 05/10/1999. Each column is obtained  month + 1 from the 
previous one.


Is it possible to access these columns (time series data) via a for/next loop 
(or a while) that uses dates i/o (i in 1:8) in the above example?


Say: if month==Oct and year==1999 choose column X05.Oct.99 ...


You can switch back and forth between character representations and 
timedate representations using strptime() and format() along with 
formatting strings, e.g.,


R strptime(X05.Oct.99, X%d.%b.%y)
[1] 1999-10-05

R format(strptime(X05.Oct.99, X%d.%b.%y), X%d.%b.%y)
[1] X05.Oct.99

R 
format(strptime(X05.Oct.99, X%d.%b.%y), %d/%m/%Y)

[1] 05/10/1999

And so on. See

  Grothendieck G, Petzoldt T (2004). R Help Desk: Date and Time
  Classes in R. R News, 4(1), 29­32.
  URL http://www.R-project.org/doc/Rnews/Rnews_2004-1.pdf

for more details.

I wonder why you have the time information in the columns rather than in 
the rows though... If your measurements on that day represent intra-day 
measurements, simply use some time/date class, e.g., POSIXct (or chron or 
timeDate) for that. If the measurements correspond to some replications 
they can just go into the columns rather than the rows of the series.


For examples in zoo, see the vignettes of the package.

hth,
Z

Could I also generate automatically a variable, appropriately named from the 
corresponding columns name that would contain the data and access it by that 
date?


Any pointers really appreciated.

Thanks in advance,
Costas


__ Information from ESET Smart Security, version of virus signature 
database 4857 (20100211) __


The message was checked by ESET Smart Security.

http://www.eset.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] gdata

2010-02-11 Thread Casimir

Hi

Using R 2.10.1 on a mac os 10.6.2, I have have a problem with gdata package.

When I use the command read.xls, I get this error-message:

Erreur dans xls2sep(xls, sheet, verbose = verbose, ..., method = method,  : 
  Unable to read translated csv file
'/var/folders/gb/gbzQ4sqTF-KK3D5m6v-IJE+++TI/-Tmp-//Rtmp3Hprw9/file10d63af1.csv'.
Erreur dans file.exists(tfn) : argument 'file' incorrect
dyld: lazy symbol binding failed: Symbol not found: _Perl_Tstack_sp_ptr
  Referenced from:
/Library/Frameworks/R.framework/Resources/library/gdata/perl/darwin-thread-multi-2level/auto/Compress/Raw/Zlib/Zlib.bundle
  Expected in: dynamic lookup

dyld: Symbol not found: _Perl_Tstack_sp_ptr
  Referenced from:
/Library/Frameworks/R.framework/Resources/library/gdata/perl/darwin-thread-multi-2level/auto/Compress/Raw/Zlib/Zlib.bundle
  Expected in: dynamic lookup

I never had this problem with the previous version of R...

Could somebody help me?

Thank you!

Guillaume
-- 
View this message in context: http://n4.nabble.com/gdata-tp1477079p1477079.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] ZOO object colnames refering to Dates

2010-02-11 Thread Gabor Grothendieck
Here are a few more examples:

 ym - seq(from = as.Date(1999-10-05), to = as.Date(2000-06-05),
+ by = month)

 z - zoo(matrix(seq_len(length(ym) * 5), 5))
 colnames(z) - format(ym, X%d.%b.%y)
 z
  X05.Oct.99 X05.Nov.99 X05.Dec.99 X05.Jan.00 X05.Feb.00 X05.Mar.00 X05.Apr.00
1  1  6 11 16 21 26 31
2  2  7 12 17 22 27 32
3  3  8 13 18 23 28 33
4  4  9 14 19 24 29 34
5  5 10 15 20 25 30 35
  X05.May.00 X05.Jun.00
1 36 41
2 37 42
3 38 43
4 39 44
5 40 45

 to.header - function(month, year) {
+ d - as.Date(paste(year, month, 5, sep = -), %Y-%b-%d)
+ format(d, X%d.%b.%y)
+ }

 to.header(Oct, 1999)
[1] X05.Oct.99

 for(j in 1:NCOL(z)) print(z[,j])
1 2 3 4 5
1 2 3 4 5
 1  2  3  4  5
 6  7  8  9 10
 1  2  3  4  5
11 12 13 14 15
 1  2  3  4  5
16 17 18 19 20
 1  2  3  4  5
21 22 23 24 25
 1  2  3  4  5
26 27 28 29 30
 1  2  3  4  5
31 32 33 34 35
 1  2  3  4  5
36 37 38 39 40
 1  2  3  4  5
41 42 43 44 45
 for(nm in colnames(z)) print(z[,nm])
1 2 3 4 5
1 2 3 4 5
 1  2  3  4  5
 6  7  8  9 10
 1  2  3  4  5
11 12 13 14 15
 1  2  3  4  5
16 17 18 19 20
 1  2  3  4  5
21 22 23 24 25
 1  2  3  4  5
26 27 28 29 30
 1  2  3  4  5
31 32 33 34 35
 1  2  3  4  5
36 37 38 39 40
 1  2  3  4  5
41 42 43 44 45


On Thu, Feb 11, 2010 at 5:04 AM, Achim Zeileis achim.zeil...@uibk.ac.at wrote:
 On Thu, 11 Feb 2010, Research wrote:

 Hello,

 I have  large zoo objects (about 100 or more time series merged next to
 eachother). Example:

   X05.Oct.99 X05.Nov.99 X05.Dec.99 X05.Jan.00 X05.Feb.00 X05.Mar.00
 X05.Apr.00 X05.May.00 X05.Jun.00
 [1,]     5649.3     5679.4     5679.4     5679.4     5679.4     5679.4
 5679.4     5679.4     5679.4
 [2,]     5682.7     5719.2     5719.2     5719.2     5719.2     5719.2
 5719.2     5719.2     5719.2
 [3,]     5697.5     5745.5     5745.5     5745.5     5745.5     5745.5
 5745.5     5745.5     5745.5
 [4,]     5723.9     5767.8     5767.8     5767.8     5767.8     5767.8
 5767.8     5767.8     5767.8
 [5,]     5782.1     5829.8     5829.8     5829.8     5829.8     5829.8
 5829.8     5829.8     5829.8
 [6,]     5815.0     5850.9     5850.9     5850.9     5850.9     5850.9
 5850.9     5850.9     5850.9


 The column names contain dates, i.e.,  X05.Oct.99 stands for a time
 sequence that was obtained on 05/10/1999. Each column is obtained  month + 1
 from the previous one.

 Is it possible to access these columns (time series data) via a for/next
 loop (or a while) that uses dates i/o (i in 1:8) in the above example?

 Say: if month==Oct and year==1999 choose column X05.Oct.99 ...

 You can switch back and forth between character representations and timedate
 representations using strptime() and format() along with formatting strings,
 e.g.,

 R strptime(X05.Oct.99, X%d.%b.%y)
 [1] 1999-10-05

 R format(strptime(X05.Oct.99, X%d.%b.%y), X%d.%b.%y)
 [1] X05.Oct.99

 R format(strptime(X05.Oct.99, X%d.%b.%y), %d/%m/%Y)
 [1] 05/10/1999

 And so on. See

  Grothendieck G, Petzoldt T (2004). R Help Desk: Date and Time
  Classes in R. R News, 4(1), 29­32.
  URL http://www.R-project.org/doc/Rnews/Rnews_2004-1.pdf

 for more details.

 I wonder why you have the time information in the columns rather than in the
 rows though... If your measurements on that day represent intra-day
 measurements, simply use some time/date class, e.g., POSIXct (or chron or
 timeDate) for that. If the measurements correspond to some replications they
 can just go into the columns rather than the rows of the series.

 For examples in zoo, see the vignettes of the package.

 hth,
 Z

 Could I also generate automatically a variable, appropriately named from
 the corresponding columns name that would contain the data and access it by
 that date?

 Any pointers really appreciated.

 Thanks in advance,
 Costas


 __ Information from ESET Smart Security, version of virus
 signature database 4857 (20100211) __

 The message was checked by ESET Smart Security.

 http://www.eset.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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read

Re: [R] Sweave, lty = 3 line incorect in pdf output

2010-02-11 Thread Ken Knoblauch

Some follow-up after Achim's message,

If I open the Sweave created pdf, lty3Test-001.pdf, attached
to the first mail, with the display command from imageMagick,
indeed, the dotted line is present, but faintly, as with the
hardcopy printout, i.e., not respecting the lwd = 3 argument.
But, the dotted line is absent if viewed with Mac's Preview.app
and the pdf viewer of TeXShop.  I don't have acrobat on my
Mac to test that, but it seems to in part, at least, viewer related.
Still, it would be good to track this down and ideally solve
it.

Thanks.

Ken


Quoting Achim Zeileis achim.zeil...@uibk.ac.at:


Ken,

I can't contribute much, just that I tried to look into it and can't
replicate it. I tried it both with .Stex and .Rnw yielding identical
results, just like plotting it interactively (on my default X11) and
printing it via dev.copy2pdf(). All of the approaches seemed to yield
the same output which looks ok.

Just for the record...
Z

R sessionInfo()
R version 2.10.1 (2009-12-14)
i486-pc-linux-gnu

locale:
[1] C

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

other attached packages:
[1] fortunes_1.3-7


On Thu, 11 Feb 2010, Ken Knoblauch wrote:


I'm having a problem with dotted lines (lty = 3) in the pdf output
in documents generated with Sweave.  In the displayed pdf, the
dotted line does not show up and in the printed output, it is
there but does not seem to respect the lwd argument, for example, it
is very faint despite using lwd = 3.  The dotted line is correct
in a quartz window and if I save the Quartz window to a pdf
and include it in the tex document, then the dotted line is there
at the correct line width.  Here is a short example, using the Stex
convention for Sweave.  I saved the quartz window in a file called
quartzSave.pdf after running the document through Sweave a first
time without the \includegraphics{quartzSave} line.

\documentclass[10pt]{article}
\usepackage{graphicx}

\begin{document}

Test of lty = 3 argument.

\begin{Scode}{fig=TRUE,eps=FALSE}
x - 1:10
plot(x, type = l, lty = 3, lwd = 3)
lines(x, 0.5 * x, type = l)
\end{Scode}

Saved from Quartz window:

\includegraphics{quartzSave}


\end{document}

I have attached the pdf created by Sweave (which is missing the dotted
lines) in case it can get through the filter to R-help.

sessionInfo()
R version 2.10.1 Patched (2010-02-01 r51089)
i386-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

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

Thanks for any help.

Ken

--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html








--
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.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] gdata

2010-02-11 Thread Gabor Grothendieck
The most recent version of gdata uses certain perl packages not used
by the older versions and perhaps that is causing the problem.  You
could try installing the latest version of active perl or if that
fails you could try an older version of gdata:

http://www.activestate.com/activeperl/

http://cran.r-project.org/src/contrib/Archive/gdata/


On Thu, Feb 11, 2010 at 5:06 AM, Casimir gcar...@gmail.com wrote:

 Hi

 Using R 2.10.1 on a mac os 10.6.2, I have have a problem with gdata package.

 When I use the command read.xls, I get this error-message:

 Erreur dans xls2sep(xls, sheet, verbose = verbose, ..., method = method,  :
  Unable to read translated csv file
 '/var/folders/gb/gbzQ4sqTF-KK3D5m6v-IJE+++TI/-Tmp-//Rtmp3Hprw9/file10d63af1.csv'.
 Erreur dans file.exists(tfn) : argument 'file' incorrect
 dyld: lazy symbol binding failed: Symbol not found: _Perl_Tstack_sp_ptr
  Referenced from:
 /Library/Frameworks/R.framework/Resources/library/gdata/perl/darwin-thread-multi-2level/auto/Compress/Raw/Zlib/Zlib.bundle
  Expected in: dynamic lookup

 dyld: Symbol not found: _Perl_Tstack_sp_ptr
  Referenced from:
 /Library/Frameworks/R.framework/Resources/library/gdata/perl/darwin-thread-multi-2level/auto/Compress/Raw/Zlib/Zlib.bundle
  Expected in: dynamic lookup

 I never had this problem with the previous version of R...

 Could somebody help me?

 Thank you!

 Guillaume
 --
 View this message in context: 
 http://n4.nabble.com/gdata-tp1477079p1477079.html
 Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] AFTREG with ID argument

2010-02-11 Thread Philipp Rappold

Göran, thanks!

One more thing that I found: As soon as you have at least one NA in 
the independent vars, the trick that you mentioned does not work 
anymore. Example:


 testdata
  start stop censor groupvar  var1
1 01  01 0.1284928
2 12  01 0.4896125
3 23  01 0.7012899
4 34  01NA
5 01  02 0.7964361
6 12  02 0.8466039
7 23  12 0.2234271

 aftreg(Surv(start, stop, censor)~var1, data=testdata, 
id=testdata$groupvar)
Error in order(id, Y[, 1]) : Different length of arguments (* I 
translated this from the German Output *)


Do you think there is a simple hack which excludes all subjects that 
have at least on NA in their independent vars? If it was only one 
dependent var it would probably be easy by just using subset, but I 
have lots of different combinations of vars that I'd like to test ;)


Best
Philipp

PS: Conerning the benmark: For a large dataset (~ 1600 observations 
on ~300 subjects) processing takes about 40 seconds (core 2 duo @ 
2.46 GHz, T9300). Interestingly, processing the testdata-set above 
with only 7 observations on 2 subjects takes 2 minutes...


Göran Broström wrote:

Philipp Rappold wrote:

Dear all,

I have some trouble using the id-argument with aftreg (accelerated 
failure time regression analysis from the eha library).


As far as I understand it, the id argument is used to group 
individuals together if there are time-varying covariates and the data 
is arranged in counting process style.


Unfortunately, i cannot figure out how to use the id-argument. The 
most straight-forward way would be to simply state the grouping 
variable, but it throws an error. I've included an example below: the 
dataframe for regression is called test, with the grouping variable 
person.


  test
  start end censor person var1
1 0   1  0  1  0.5
2 1   2  0  1  0.4
3 2   3  0  1  0.6
4 3   4  1  1 -0.3
5 0   1  0  2  0.6
6 1   2  0  2  0.7
7 2   3  0  2  0.6

  fit - aftreg(Surv(start, end, censor)~var1, data=test, id=person)
Error in order(id, Y[, 1]) : argument 1 is not a vector


You have caught the _function_ 'person' (package: utils) instead of the 
variable 'person' in the data frame. That explains the odd error 
message. If you change the variable name to, e.g., ID, you'll get the 
error message


Error in order(id, Y[, 1]) : object 'id' not found

which would hint you in the right direction. You need to specify  'id' 
by a full name, in your case 'test$person'. This is of course a 
deficiency in the interface of aftreg. I will fix it asap.


So the temporary fix is 'id = test$person'.

Thanks for the report,

Göran




  fit - aftreg(Surv(start, end, censor)~var1, data=test, 
id=test[person])

Error in `[.data.frame`(id, ord) : undefined columns selected



What would be the correct way to fit this example model?

Thanks + all the best
Philipp




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 wiki link ?

2010-02-11 Thread Martin Maechler
 PhGr == Philippe Grosjean phgrosj...@sciviews.org
 on Mon, 08 Feb 2010 19:55:08 +0100 writes:

PhGr Prof. John C Nash wrote:
 Is this a transient problem, or has the link to the R wiki on the R home 
 page (www.r-project.org) to http://wiki.r-project.org/ been corrupted? I 
 can find
 http://rwiki.sciviews.org that works.

PhGr Yes, the problem is known. I have to fix it.

and it has been fixed, late yesterday, thanks to Stefan
Theussl's kind and swift cooperation.

Martin Maechler, ETH Zurich

PhGr Best,
PhGr Philippe Grosjean

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweve/cacheSweave

2010-02-11 Thread Duncan Murdoch

Unger, Kristian wrote:

Hi there

I have a problem with using Sweave in combination with the option driver = 
cacheSweave.

Whichever code I try to run  - when it comes to converting the tex file into 
pdf it comes up with the same errors (\csname \endcsname errors). Does anybody 
have an idea what it going wrong?

  

Sweave(pgfSweave-example.Rnw,driver  =  cacheSweaveDriver)


Writing to file pgfSweave-example.tex
Processing code chunks ...
 1 : term verbatim (label=setup)
 2 : echo term verbatim (label=data)
 3 : term verbatim eps pdf (label=boxplot)

You can now run LaTeX on 'pgfSweave-example.tex'

  

tools::texi2dvi(pgfSweave-example.tex, pdf=TRUE)


Error in tools::texi2dvi(pgfSweave-example.tex, pdf = TRUE) :
  running 'texi2dvi' on 'pgfSweave-example.tex' failed

LaTeX errors:
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: LaTeX E
rror: Missing \begin{document}.
  


I think this is the important error:  it looks as though your .tex file 
isn't a complete LaTeX document.  The other errors likely follow from this.


Duncan Murdoch

See the LaTeX manual or LaTeX Companion for explanation.
Type  H return  for immediate help
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.


C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.

I am running this under Windows XP, R version 2.9.2 (2009-08-24),  
package.version(cacheSweave)
[1] 0.4-3.

Any help or advice on this would be highly appreciated!

Best wishes

Kristian

_

Dr Kristian Unger

Bioinformaticist Chernobyl Tissue Bank

Division of Surgery and Cancer

Imperial College London

Rm G02, Ground floor G Block
Hammersmith Hospital
Du Cane Road,
London W12 0HS

Tel +44-20-8383-2443

Mob +44-795-1080619

Skype kristianunger

http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
http://www.chernobyltissuebank.com


[[alternative HTML version deleted]]

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running rscript in windows

2010-02-11 Thread Duncan Murdoch

vikrant wrote:

Thanks a lot, really. dir() option showd my desktop files and test.R was
shown as test.R.txt
when I run source(test.R.txt) it worked.

Just for your information,
I changed the directory using Menu options File- change dir.
I verified the same using getwd() command in R. '


  
This is due to the bizarre default in Windows of suppressing file 
extensions.  Turn that off, so you can see what files are really named, 
and you will not be confused by secret renamings like this one.


Duncan Muroch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweve/cacheSweave

2010-02-11 Thread Duncan Murdoch

On 11/02/2010 6:06 AM, Duncan Murdoch wrote:

Unger, Kristian wrote:

Hi there

I have a problem with using Sweave in combination with the option driver = 
cacheSweave.

Whichever code I try to run  - when it comes to converting the tex file into 
pdf it comes up with the same errors (\csname \endcsname errors). Does anybody 
have an idea what it going wrong?

  

Sweave(pgfSweave-example.Rnw,driver  =  cacheSweaveDriver)


Writing to file pgfSweave-example.tex
Processing code chunks ...
 1 : term verbatim (label=setup)
 2 : echo term verbatim (label=data)
 3 : term verbatim eps pdf (label=boxplot)

You can now run LaTeX on 'pgfSweave-example.tex'

  

tools::texi2dvi(pgfSweave-example.tex, pdf=TRUE)


Error in tools::texi2dvi(pgfSweave-example.tex, pdf = TRUE) :
  running 'texi2dvi' on 'pgfSweave-example.tex' failed

LaTeX errors:
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: LaTeX E
rror: Missing \begin{document}.
  


I think this is the important error:  it looks as though your .tex file 
isn't a complete LaTeX document.  The other errors likely follow from this.


From an offline followup:  the .tex was complete, but it included a 
path to Sweave.sty that contained TeX-special characters, and that was 
the source of the error.  See ?RweaveLatex for a discussion of how to 
avoid this.


Duncan Murdoch



Duncan Murdoch

See the LaTeX manual or LaTeX Companion for explanation.
Type  H return  for immediate help
C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.


C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Missing
 \endcsname inserted
The control sequence marked to be read again should
not appear between \csname and \endcsname.

C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: Extra \
endcsname
I'm ignoring this, since I wasn't doing a \csname.

I am running this under Windows XP, R version 2.9.2 (2009-08-24),  
package.version(cacheSweave)
[1] 0.4-3.

Any help or advice on this would be highly appreciated!

Best wishes

Kristian

_

Dr Kristian Unger

Bioinformaticist Chernobyl Tissue Bank

Division of Surgery and Cancer

Imperial College London

Rm G02, Ground floor G Block
Hammersmith Hospital
Du Cane Road,
London W12 0HS

Tel +44-20-8383-2443

Mob +44-795-1080619

Skype kristianunger

http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
http://www.chernobyltissuebank.com


[[alternative HTML version deleted]]

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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ACF and PACF

2010-02-11 Thread sathiya_mtm

Hi helpers,

can you help me in plotting acf and pacf functions in R. 
I am using the code

acf(variable name)

but it is not working.

Expecting your reply.
Thanks
-- 
View this message in context: 
http://n4.nabble.com/ACF-and-PACF-tp1477149p1477149.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] (linux) display messages in R startup screen

2010-02-11 Thread Wolfgang Raffelsberger

Dear guRus,

I'm maintaining central R installation (Linux) for our institute.  The 
startup screen of R traditionally echoes some messages (starting with R 
version ...Copyright (C).. The R Foundation for Statistical 
Computing...) and  I'd like to display for example right after these 
messages some other messages about our specific setup, how to contact me 
etc ...

What would be the best place to add this ?

I've been looking into the bin/ directory (ie /linux/local/lib64/R/bin) 
but I'm not shure about the best place/way for such messages.
On Windows I've used the etc/Rprofile.site for somehow similar issues, 
but I haven't seen any equivalent on our linux installation.


Any suggestions ?

Thank's in advance
Wolfgang

For completeness:
 sessionInfo()
R version 2.10.0 (2009-10-26)
x86_64-unknown-linux-gnu

locale:
[1] C

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



. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
CNRS UMR7104, IGBMC,  
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France

Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
wolfgang.raffelsberger (at) igbmc.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.


[R] Coda or R or input error? (Error in lowess(xp, yp[, k]) :...)

2010-02-11 Thread Raisinmeister
I have been using R with the packages locfit and coda to analyse
output from a population genetics program (msvar) which I have been
running on an external server (http://cbsuapps.tc.cornell.edu/
index.aspx).

One of the first steps is to read the msvar output tables into R and
then use coda to analyse the MCMC object.  Sometimes, this works
perfectly and sometimes, when I try to plot the output, it does not!
The error message I get is-
Error in lowess(xp, yp[, k]) :
 NA/NaN/Inf in foreign function call (arg 2)

Someone mentioned that this may be because R is very memory hungry and
it may be too much for my laptop to cope with.  So I tried running it
on another computer and this time I cannot even get as far as creating
the MCMC object, I get a message telling me that there are non-numeric
values:
Error in mcmc(data = D1) : Data frame contains non-
numeric values

I find it difficult to believe that there are any non-numeric values
as I have run the msvar analysis on 5 different projects and treated
the outputs in exactly the same way; 2 have worked perfectly but the
other 3 all produce these same messages.  I have checked for empty
lines at the end of the files.

Is it likely to be because the files are too large?  Any help or
suggestions would be gratefully received.

Many thanks



I have pasted the R transcripts below, just in case anyone fancies a
read!

Laptop- Lowess error

A1-read.table(file=hparsA1.dat,sep= )
A2-read.table(file=hparsA2.dat,sep= )
A3-read.table(file=hparsA3.dat,sep= )
dim(A1)
[1] 20 11
dim(A2)
[1] 20 11
dim(A3)
[1] 20 11
mcmc.A1-mcmc(data=A1)
mcmc.A2-mcmc(data=A2)
mcmc.A3-mcmc(data=A3)
plot(mcmc.A1)
Error in lowess(xp, yp[, k]) :
  NA/NaN/Inf in foreign function call (arg 2)
plot(mcmc.A2)
Error in lowess(xp, yp[, k]) :
  NA/NaN/Inf in foreign function call (arg 2)
plot(mcmc.A3)
Error in lowess(xp, yp[, k]) :
  NA/NaN/Inf in foreign function call (arg 2)


Desktop- Non-numeric error

D1-read.table(file=hparsD1.dat,sep= )
D2-read.table(file=hparsD2.dat,sep= )
D3-read.table(file=hparsD3.dat,sep= )
mcmc.D1-mcmc(data=D1)
Error in mcmc(data = D1) : Data frame contains non-numeric values
mcmc.D2-mcmc(data=D2)
Error in mcmc(data = D2) : Data frame contains non-numeric values
mcmc.D3-mcmc(data=D3)
Error in mcmc(data = D3) : Data frame contains non-numeric values

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Zero-inflated Negat. Binom. model

2010-02-11 Thread Luciano La Sala
Dear R crew: 
 
I am sorry this question has been posted before, but I can't seem to solve
this problem yet. 
I have a simple dataset consisting of two variables: cestode intensity and
chick size (defined as CAPI). 
Intensity is a count and clearly overdispersed, with way too many zeroes. 
I'm interested in looking at the association between these two variables,
i.e. how well does chick size predict tape intensity?
 
Since I have a small sample size, I fit a zero inflated negat. Binomial (not
Poisson) model using the pscl package. 
 
I built tried two models and got the outputs below. 
 
 model - zeroinfl(Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)
 
Call:
zeroinfl(formula = Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)
 
Count model coefficients (negbin with log link):
(Intercept) CAPI  
   -2.99182  0.06817  
Theta = 0.4528 
 
Zero-inflation model coefficients (binomial with logit link):
(Intercept) CAPI  
12.1364  -0.1572  
 
 summary(model)
 
Call:
zeroinfl(formula = Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)
 
Pearson residuals:
 Min   1Q   Median   3Q  Max 
-0.62751 -0.38842 -0.21303 -0.06899  7.29566 
 
Count model coefficients (negbin with log link):
Estimate Std. Error z value Pr(|z|)  
(Intercept) -2.991823.39555  -0.881   0.3783  
CAPI 0.068170.04098   1.664   0.0962 .
Log(theta)  -0.792220.45031  -1.759   0.0785 .
 
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(|z|)   
(Intercept) 12.136363.71918   3.263  0.00110 **
CAPI-0.157200.04989  -3.151  0.00163 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
 
Theta = 0.4528 
Number of iterations in BFGS optimization: 1 
Log-likelihood: -140.2 on 5 Df
  
QUESTIONS
 
1. Is my model adequately specified?
 
2. CAPI is included in blocks 1 of output containing negative binomial
regression coefficients for CAPI, and is also included also in block 2
corresponding to the inflation model. Does this make sense?  
 
If I specify my model slightly differently, I get what I believe is more
reasonable results:
 
 model12 - zeroinfl(Int_Cesto ~ 1|CAPI, dist = negbin, EM = TRUE)
 model12
 
Call:
zeroinfl(formula = Int_Cesto ~ 1 | CAPI, dist = negbin, EM = TRUE)
 
Count model coefficients (negbin with log link):
(Intercept)  
  2.692  
Theta = 0.4346 
 
Zero-inflation model coefficients (binomial with logit link):
(Intercept) CAPI  
13.2476  -0.1708  
 
 summary(model12)
 
Call:
zeroinfl(formula = Int_Cesto ~ 1 | CAPI, dist = negbin, EM = TRUE)
 
Pearson residuals:
 Min   1Q   Median   3Q  Max 
-0.61616 -0.36902 -0.19466 -0.0  4.85481 
 
Count model coefficients (negbin with log link):
Estimate Std. Error z value Pr(|z|)
(Intercept)   2.6924 0.3031   8.883   2e-16 ***
Log(theta)   -0.8334 0.4082  -2.042   0.0412 *  
 
Zero-inflation model coefficients (binomial with logit link):
Estimate Std. Error z value Pr(|z|)
(Intercept) 13.247573.64531   3.634 0.000279 ***
CAPI-0.170780.04921  -3.471 0.000519 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
 
Theta = 0.4346 
Number of iterations in BFGS optimization: 1 
Log-likelihood: -141.9 on 4 Df
 
QUESTION:
 
1.Is this model specification and output more reasonable?
2.CAPI appears only in the second block that corresponds to the
inflation model.
 
 
Thanks in advance!
Luciano  
 

 

 

 


[[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] (linux) display messages in R startup screen

2010-02-11 Thread Dirk Eddelbuettel

On 11 February 2010 at 12:08, Wolfgang Raffelsberger wrote:
| I'm maintaining central R installation (Linux) for our institute.  The 
| startup screen of R traditionally echoes some messages (starting with R 
| version ...Copyright (C).. The R Foundation for Statistical 
| Computing...) and  I'd like to display for example right after these 
| messages some other messages about our specific setup, how to contact me 
| etc ...
| What would be the best place to add this ?
| 
| I've been looking into the bin/ directory (ie /linux/local/lib64/R/bin) 
| but I'm not shure about the best place/way for such messages.
| On Windows I've used the etc/Rprofile.site for somehow similar issues, 
| but I haven't seen any equivalent on our linux installation.

You can use the same file -- $(R_HOME)/etc/Rprofile.site -- see help(Startup).

For Debian/Ubuntu we also store it in /etc/R/Rprofile.site and soft-link it
back to $(R_HOME)/etc but R only knows the latter location.

Hth, Dirk

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] cluster/distance large matrix

2010-02-11 Thread Bart Thijs

Hi all,

I've stumbled upon some memory limitations for the analysis that I want to
run.

I've a matrix of distances between 38000 objects. These distances were
calculated outside of R. 
I want to cluster these objects.

For smaller sets (egn=100) this is how I proceed:
A-matrix(scan(file, n=100*100),100,100, byrow=TRUE)
ad-as.dist(A)
ahc-hclust(ad,method=ward,members=NULL)


However if I try this with the real dataset I end up with memory problems.
I've the 64bit version of R installed on a machine with 40Gb RAM (Windows
2003 64bit version).

I'm thinking about using only the lower triangle of the matrix but I can't
create a distance object for the clustering from the lower.tri

Can someone help me with a suggestion for which way to go?

Best Regards
Bart Thijs
-- 
View this message in context: 
http://n4.nabble.com/cluster-distance-large-matrix-tp1477237p1477237.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] GWRM package

2010-02-11 Thread Antonio José Sáez Castillo
I'd like to announce the availability of the GWRM package. It provides a
set of functions for fitting Generalized Waring Regression Models. It also
includes the dataset and the example of Rodriguez-Avi, J; Conde-Sanchez,
A; Saez-Castillo, A.J., Olmo-Jimenez, M. J. and Martinez Rodriguez, A.
M.(2009). A generalized Waring regression model for count data.
Computational Statistics and Data Analysis, 53, pp. 3717-3725. The package
has been uploaded to CRAN and is now available under the GPL-2 license.

Antonio Jose Saez-Castillo, Ph.D.

___
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] Sweve/cacheSweave

2010-02-11 Thread Unger, Kristian
Thank you very much Duncan! Adding the line \usepackage{Sweave} fixed the 
problem.

Best wishes

Kristian
_ 

Dr Kristian Unger

Bioinformaticist Chernobyl Tissue Bank

Division of Surgery and Cancer

Imperial College London

Rm G02, Ground floor G Block
Hammersmith Hospital
Du Cane Road, 
London W12 0HS

Tel +44-20-8383-2443

Mob +44-795-1080619

Skype kristianunger

http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
http://www.chernobyltissuebank.com

-Original Message-
From: Duncan Murdoch [mailto:murd...@stats.uwo.ca] 
Sent: 11 February 2010 12:06
To: Unger, Kristian
Cc: 'r-help@r-project.org'
Subject: Re: [R] Sweve/cacheSweave

On 11/02/2010 6:06 AM, Duncan Murdoch wrote:
 Unger, Kristian wrote:
 Hi there

 I have a problem with using Sweave in combination with the option driver = 
 cacheSweave.

 Whichever code I try to run  - when it comes to converting the tex file into 
 pdf it comes up with the same errors (\csname \endcsname errors). Does 
 anybody have an idea what it going wrong?

   
 Sweave(pgfSweave-example.Rnw,driver  =  cacheSweaveDriver)
 
 Writing to file pgfSweave-example.tex
 Processing code chunks ...
  1 : term verbatim (label=setup)
  2 : echo term verbatim (label=data)
  3 : term verbatim eps pdf (label=boxplot)

 You can now run LaTeX on 'pgfSweave-example.tex'

   
 tools::texi2dvi(pgfSweave-example.tex, pdf=TRUE)
 
 Error in tools::texi2dvi(pgfSweave-example.tex, pdf = TRUE) :
   running 'texi2dvi' on 'pgfSweave-example.tex' failed

 LaTeX errors:
 C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
 Missing
  \endcsname inserted
 The control sequence marked to be read again should
 not appear between \csname and \endcsname.

 C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
 LaTeX E
 rror: Missing \begin{document}.
   
 
 I think this is the important error:  it looks as though your .tex file 
 isn't a complete LaTeX document.  The other errors likely follow from this.

 From an offline followup:  the .tex was complete, but it included a 
path to Sweave.sty that contained TeX-special characters, and that was 
the source of the error.  See ?RweaveLatex for a discussion of how to 
avoid this.

Duncan Murdoch

 
 Duncan Murdoch
 See the LaTeX manual or LaTeX Companion for explanation.
 Type  H return  for immediate help
 C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
 Extra \
 endcsname
 I'm ignoring this, since I wasn't doing a \csname.


 C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
 Missing
  \endcsname inserted
 The control sequence marked to be read again should
 not appear between \csname and \endcsname.

 C:/Imperial/Sileida/DOUBLECHECK/ALL/eval_amps/pgfSweave-example.tex:10: 
 Extra \
 endcsname
 I'm ignoring this, since I wasn't doing a \csname.

 I am running this under Windows XP, R version 2.9.2 (2009-08-24),  
 package.version(cacheSweave)
 [1] 0.4-3.

 Any help or advice on this would be highly appreciated!

 Best wishes

 Kristian

 _

 Dr Kristian Unger

 Bioinformaticist Chernobyl Tissue Bank

 Division of Surgery and Cancer

 Imperial College London

 Rm G02, Ground floor G Block
 Hammersmith Hospital
 Du Cane Road,
 London W12 0HS

 Tel +44-20-8383-2443

 Mob +44-795-1080619

 Skype kristianunger

 http://www1.imperial.ac.uk/medicine/about/divisions/is/histo/
 http://www.chernobyltissuebank.com


  [[alternative HTML version deleted]]

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

 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] cluster/distance large matrix

2010-02-11 Thread Christian Hennig

Dear Bart,

a strange thing in your question is that the term Ward's method 
usually refers to a method based on the k-means criterion, which, in its 
standard form, is not based on dissimilarities, but on 
objects*variables-data.
So I wonder how and why you want to use Ward's method on a dissimilarity 
matrix in the first place (I know that the k-means criterion 
can in principle be translated to dissimilarity data - this is probably 
what hclust's method=ward does if fed with a dissimilarity matrix, but 
I'm not sure -, but then it loses its justification).


One thing you could think about is using the function pam in library 
cluster. Chances are that this won't work on 38,000 cases either, but you 
may cluster a subsample of, say, 2,000 cases and assign all further 
objects to the most similar cluster medoid.


It is well know that hierarchical methods are problematic with too large 
dissimilarity matrices; even if you resolve the memory problem, the number 
of operations required is enormous.


Hope this helps,
Christian


On Thu, 11 Feb 2010, Bart Thijs wrote:



Hi all,

I've stumbled upon some memory limitations for the analysis that I want to
run.

I've a matrix of distances between 38000 objects. These distances were
calculated outside of R.
I want to cluster these objects.

For smaller sets (egn=100) this is how I proceed:
A-matrix(scan(file, n=100*100),100,100, byrow=TRUE)
ad-as.dist(A)
ahc-hclust(ad,method=ward,members=NULL)


However if I try this with the real dataset I end up with memory problems.
I've the 64bit version of R installed on a machine with 40Gb RAM (Windows
2003 64bit version).

I'm thinking about using only the lower triangle of the matrix but I can't
create a distance object for the clustering from the lower.tri

Can someone help me with a suggestion for which way to go?

Best Regards
Bart Thijs
--
View this message in context: 
http://n4.nabble.com/cluster-distance-large-matrix-tp1477237p1477237.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.



*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ACF and PACF

2010-02-11 Thread Uwe Ligges

On 11.02.2010 12:48, sathiya_mtm wrote:


Hi helpers,

can you help me in plotting acf and pacf functions in R.
I am using the code

acf(variable name)



but it is not working.



For me it is, hence citing the footer of al R-help messages:

PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html and provide commented, 
minimal, self-contained, reproducible code.


Uwe Ligges



Expecting your reply.
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.


[R] WMF conversion

2010-02-11 Thread Terry Therneau
Could you save the original graphics as a pdf, and include the pdf in
Powerpoint?  
 
-- begin included message --

Unfortunately, after placed in the PowerPoint and the PowerPoint is
converted to PDF via MS Office's built in conversion utility, the
resulting image have diagonal streaks across them from the y-axis down
to the x-axis.  The rest of the document is perfect, but the WMF images
now have streaks across them.  It looks like it may be caused, somehow,
by the dotted grid.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Total least squares linear regression

2010-02-11 Thread Terry Therneau
This is also called Deming regression and perhaps many other things.
It is a lively topic in the validation of competing assay methods in the
laboratory.  I have a function 'deming.R' that does a generalized form
of this, based on the (very nice) article below, the code is attached.
(The attachments will be stripped by R-help, but the original requestor
will get them.)  If someone thinks this to be of general enough interest
to package up on CRAN I'm happy donate the code to them -- I won't have
the time for some while.
   Terry T.

 BD Ripley and M Thompson, Regression techniques for the detection
of analytical bias, Analyst 112:377-383, 1987.
 
- begin included message ---
After a thorough research, I still find myself unable to find a
function 
that does linear regression of 2 vectors of data using the total least 
squares, also called orthogonal regression (see : 
http://en.wikipedia.org/wiki/Total_least_squares) instead of the 
ordinary least squares method. Indeed, the lm function has a 
method argument but the manual says that there is only one option so
far.
However, since the samples I am studying have the type of relationship 
that requires orthogonal regression, I am bound to use it.

x se.x y se.y
871 192 735 207
701 156 792 223
328 76 340 096 
560 126 544 153
155 39 207 59 
175 43 229 65 
73 22 66 19
366 84 343 97
90 25 125 36
939 207 658 185
439 100 331 93
369 84 272 77
34 13 232 66
194 47 150 43
207 50 350 99
138 36 117 33
181 45 231 66
127 33 188 54
82 23 44 13
188 46 137 40
566 127 704 198
0 06 0 1
0 6 49 15
40 15 129 37
0 6 37 12
198 48 216 62
1021 224 1253 351
464 105 390 110
566 127 466 131
1925 418 1586 445
\name{deming}
\alias{deming}
\title{Fit a generalized Deming regression}
\description{
 Find the MLE line relating x and y when both are measured with
error.  When the variances are constant and equal, this is the
special case of Deming regression.
For laboratory analytes this is rarely true, however.
}
\usage{
ripleyfit(x, y, xstd, ystd, jackknife = TRUE, dfbeta = FALSE, scale=T)
}
\arguments{
  \item{x}{A numeric vector}
  \item{y}{A numeric vector}
  \item{xstd}{Either a numeric vector of the same length as \code{x}
giving the standard error for each of the elements, or a vector of
length 2 giving the error formula.}
  \item{ystd}{Either a numeric vector of the same length as \code{y}
giving the standard error for each of the elements, or a vector of
length 2 giving the error formula.}
  \item{jackknife}{Produce jackknife estimates of standard error.}
  \item{dfbeta}{Return the dfbeta matrix}
  \item{scale}{Compute an estimate of residual variance or scale.  
  If FALSE, the estimates of variance \code{xstd} and \code{ystd} are
  assumed to be perfectly calibrated.}
}
\details{
The \code{xstd} specification can be a pair of
values a, b; if so then the standard deviation of \code{x} is assumed
to be \code{a + b*x}; similarly for \code{ystd}.
An assumption of constant variance (homoscedasticity) correponds to \code{b=0}.
If \code{b} is 0 for both \code{x} and \code{y}, 
then the result depends only on the 
ratio of the \code{a} values, which is the ratio of the variances.
To fit a Deming regression for instance use \code{c(1,0)} for 
both specifications.  (Use of (k,0) for both would give the same answer
for any value k).

When \code{a} is zero this is a model assuming constant coefficient of
variation.  
Values of stdx= (0,k) and stdy = (0,1) correspond to the case of contant
proportional errors discussed by Linnet.

The most realistic case is where both \code{a} and \code{b} are
non-zero and have been estimated from prior data.
}
\value{
  If \code{jackknife} is FALSE the result is a vector containing the
intercept and the slope, otherwise it is a list with components:
  \item{coefficient}{The coefficient vector, containing the intercept and 
slope.}
  \item{variance}{The jackknife estimate of variance}
  \item{dfbeta}{Optionally, the dfbeta residuals.  A 2 column matrix,
each row is the change in the coefficient vector if that observation is
removed from the data.}
}
\details{
  The standard printout includes test of intercept=0 and of slope=1.}
\references{
 BD Ripley and M Thompson, Regression techniques for the detection
of analytical bias, Analyst 112:377-383, 1987.

 K Linnet, Estimation of the linear relationship between the
measurements of two methods with proportional errors.  
Statistics in Medicine 9:1463-1473, 1990.
}
\author{Terry Therneau}
\examples{
# Data from Ripley
arsenic - data.frame( 
  x=c(871, 701, 328, 560, 155, 175, 73, 366, 90, 939, 439, 369, 34, 194, 
  207, 138, 181, 127, 82, 188, 566, 0, 0, 40, 0, 198, 1021, 464, 566, 
  1925)/100,
  y=c(735, 792, 340, 544, 207, 229, 66, 343, 125, 658, 331, 272, 232, 150, 
  350, 117, 231, 188, 44, 137, 704, 0, 49, 129, 37, 216, 1253, 390, 
  466, 1586)/100,
  se.x=c(192, 156, 76, 126, 39, 43, 22, 84, 25, 207, 100, 84, 13, 47, 
  50, 36, 45, 33, 23, 46, 

[R] Odp: Simplify the code

2010-02-11 Thread Petr PIKAL
Hi

I did not see the answer yet, probably nobody is much interested in such 
function, so I will try. 

r-help-boun...@r-project.org napsal dne 10.02.2010 21:57:42:

 Hi all,
I wrote the following code for the function that is attached.
 I want to simply the code. 

Why. If it works there is no problem until you encounter performance 
issues. If it does not work you shall specify what is wrong with it.

Many functions are vectorised (including choose and beta) so you could 
probably get rid of nested cycles but I am far from elaborating how to 
change your code and make it simpler (shorter, quicker ???)

Regards
Petr

 Can some one give me some help?
 
 
 The function is attached and the following is the code:
 
 ## f1 is the function calculate the value outside the sum
 f1 - function(t, a, b) {t/beta(a, b)}
 ## f2 is the function that calculates the summand
 f2 - function(j, k, t, a, b){choose(j-1,k-1)*(1-t)^(j-1) * beta(a+k, 
b+j-
 k)}
 ## f3 calculates the sum
 f3 - function(n, t, a, b){
 ss - matrix(0, nrow=n, ncol=n)
 for (j in 1:n){
 for (i in 1:j) {
 ss[i,j]- f2(j,i, t, a, b)
 }
 }
 sum - sum(ss)
 return(sum)
 }
 ## f is the final function
 f - function(n,t, a, b) {f1(t,a ,b)*f3(n,t,a,b)}
 
 
##
 
Many thanks!
 
 
 
 
 
 
 
 
  Hannah
 [příloha question to R-heip.pdf odstraněna uživatelem Petr PIKAL/CTCAP] 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] Question re model development

2010-02-11 Thread Stratos Laskarides
Dear Sir/Madam

I'm trying quite a long shot here...

I have used R previously, and would just like to know if any software/model
has been designed which will allow me to project the future risk profile of
a group of insured lives (by factors such as age, gender etc.), based on
past and exisiting risk profiles of the covered lives? If you could point me
in the direction of a similar project or code it would be much appreciated.

Thank you.
Stratos Laskarides

[[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] for loop the can be skipped

2010-02-11 Thread Fabrizio Pollastri

Hello,

there is compact way to skip a for loop when the requested number of 
iterations is 0 ?


For example, something equivalent to the following code:

for (i in some_function(from=1,to=iteration_cycles)) { ... }

Where the loop is skipped when iteration_cycles==0

Thanks in advance.
F: Pollastri

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] for loop the can be skipped

2010-02-11 Thread Duncan Murdoch

On 11/02/2010 9:28 AM, Fabrizio Pollastri wrote:

Hello,

there is compact way to skip a for loop when the requested number of 
iterations is 0 ?


For example, something equivalent to the following code:

for (i in some_function(from=1,to=iteration_cycles)) { ... }

Where the loop is skipped when iteration_cycles==0


Sure:

for (i in seq_len(iteration_cycles)) { ... }

will execute 0 times if requested.

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] Biclustering package

2010-02-11 Thread Alex Roy
Thank you very much Gabor.

Alex

On Thu, Feb 11, 2010 at 10:55 AM, Gábor Csárdi csa...@rmki.kfki.hu wrote:

 Alex, the isa2 package implements the biclustering algorithm discussed in
 Bergmann S, Ihmels J, and Barkai N. Iterative signature algorithm for
 the analysis of large-scale gene expression data. Phys Rev E Stat
 Nonlin Soft Matter Phys 2003 Mar; 67(3 Pt 1) 031902

 Best,
 Gabor

 On Thu, Feb 11, 2010 at 10:51 AM, Alex Roy alexroy2...@gmail.com wrote:
  Hello,
I am looking for R package which can perform biclustering a
 part
  from biclust package.
 
  thanks
 
  Alex
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 Gabor Csardi gabor.csa...@unil.ch UNIL DGM


[[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] cluster/distance large matrix (fwd)

2010-02-11 Thread Thomas Lumley
On Thu, 11 Feb 2010, Christian Hennig wrote:

It is well know that hierarchical methods are problematic with too large 
dissimilarity matrices; even if you resolve the memory problem, the number of 
operations required is enormous.


There is at least one exception to this. Single-linkage hierarchical clustering 
with a convex distance such as Euclidean distance is feasible for quite large 
data sets using algorithms for the Euclidean minimum spanning tree. For tens to 
hundreds of thousands of points (flow cytometry data) the algorithm in the 
nnclust package is competitive in speed with model-based clustering (on a 
32-bit system).  It's slower than pam(), but it is deterministic.

This doesn't apply to the original question, of course.

 -thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Suprising behavior of paste or cat?

2010-02-11 Thread Russell Pierce
If the list would provide additional reports I'd appreciate it.  I
replicated the effect this morning on another Windows XP machine...
R version 2.10.1 (2009-12-14)
i386-pc-mingw32

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

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

loaded via a namespace (and not attached):
[1] tools_2.10.1
...
and I replicated it using the current development build...

R version 2.11.0 Under development (unstable) (2010-02-09 r51113)
i386-pc-mingw32

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

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

In additionally I've determined that when h.long = 150; both cat and
write fail, but when h.long = 100 only the file write with cat fails.

Please advise.

Best,

Russell

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 ANOVA gives diferent results than SPSS

2010-02-11 Thread Protzko

I guess my subject says it all.  But I loaded a dataset in spss and used the
foreign package to read and save it in R.  Running an anova (using the aov
command) gives a different F and p value in R than it does in SPSS.  ANy
idea what is going on?
-- 
View this message in context: 
http://n4.nabble.com/R-ANOVA-gives-diferent-results-than-SPSS-tp1477322p1477322.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] Using Rscript in combination with eval() results in error

2010-02-11 Thread Janko Thyson

Dear List,

I'm having trouble running a .bat file which calls an R-Script via the
command line (using Rscript).

I put the following line in a file called test.bat:

Rscript --vanilla test.R

Then I tried to launch test.bat via Windows' CMD (I plan to make this a
scheduled Windows task).

The actual R-script (test.R) is executed just fine until it gets to a line
containing an eval() expression:

eval(parse(file=C:/temp/another.script.R))

and R (or Windows' CMD, respectively) throws the following error

Error in if (file == ) - stdin() else { : Argument is of length 0
Calls: source - eval.with.vis - eval.wtih.vis - source
Execution stopped

Usually such eval() expressions work just fine in my scripts.

I tried the following already:
1) to.load.file - file(C:/temp/another.script.R, open=rt);
eval(parse(file=to.load.file): No luck
2) Running test.R within a Rterm session: Works fine.
3) Calling the following from within a Rterm session:

system(Rscript C:/temp/test.R, wait=TRUE, invisible=FALSE)

That works too!

Is there something one needs to be aware of regarding eval() or source()
when launching a script via a CMD call to a .bat file?

Im running Windows XP and R-2.10.1

Any hints greatly appreciated!

Thanks,
Janko

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Johan Jackson
Hi all,

First off, it is surprising that there are no examples of how to use
read.table() under ?read.table !

I am trying to read in a flat file of type 'raw'. It has 1000 rows and 600K
columns. I have the RAM to accomplish this, but can't get the data into R
using read.table:

x - read.table(data,header=TRUE,colClasses=rep(,60))
#returns error:  no method or default for coercing character to raw

Then I thought that maybe the colClasses vector needed to actually *be* the
mode needed (here's where an example under ?read.table would help):

x - read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))

I waited on the latter command for a couple of hours before killing the
process. What should the colClasses argument be?

Should I be using another method to read the data into R? Previous
experience using scan() and readLines() showed that read.table() was faster,
at least for those examples, so I've stopped trying to use those other
functions.

Thank you,

JJ

[[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] R ANOVA gives diferent results than SPSS

2010-02-11 Thread Thomas Lumley

On Thu, 11 Feb 2010, Protzko wrote:



I guess my subject says it all.  But I loaded a dataset in spss and used the
foreign package to read and save it in R.  Running an anova (using the aov
command) gives a different F and p value in R than it does in SPSS.  ANy
idea what is going on?


Yes. Either you specified a different model or different tests for the same 
model in the two systems, or you are interpreting the output incorrectly, or 
the results are different.

Without more detail it is hard to be sure, but the first two possibilities seem 
more likely.

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Unexpected output in first iteration of for-loop

2010-02-11 Thread Don MacQueen
You have a mistake in how you're setting up the object named result 
before the loop.


You set result - latentVariableNames. It is a vector of length 6, 
when you call the function with LV. The printout from the first 
iteration shows this.


But then you rbind result with a data frame that has three columns. 
These are basically incompatible, but R (apparently silently) wraps 
the vector of length 6 into two rows of three columns.


Here's an example:


 foo - letters[1:6]
 names(foo) - c('a','b','c')
 foo

   abc NA NA NA
 a  b  c  d  e  f


 rbind(foo, data.frame(a='X', b='Y', c='Z',stringsAsFactors=FALSE))

  a b c
1 a b c
2 X Y Z

What I would do is something like this (untested):

loopCronbach - function(latentVariableNames, groupingVariable) {
  n - length(latentVariableNames)
  tmp1 - tmp2 - numeric(n)

  for (i in 1:n) {
tmp1[i] - calculateIndividualCronbach(get(latentVariableNames[i]))
tmp2[i] - calculateGroupCronbach(get(latentVariableNames[i]), 
groupingVariable)

  }

  result - 
data.frame(latentVariable=latentVariableNames,Indiv=tmp1,Group=tmp2)

  names(result) - c(latentVariable, Indiv, Group)
  result ## no need to use return()
}

Building up a dataframe row by row using rbind() is in general an 
expensive way to do things -- although in this instance it's such a 
small dataframe that it doesn't matter.


-Don

At 10:56 AM +0100 2/11/10, Chaehan So wrote:

Ok, you're right -  may I rephrase:
How should I modify the assignment of result - latentVariableNames
so it produces the output without the first line?
I thought result - NULL should do the job, but it didn't because of the
following names(result) assignment (which I understand, but not how I
can workaround it).

Here's the output and code again:

  latentVariable   Indiv Group
1  rPlanning rIterat  rTDD
2  rPlanning0.79  0.84
3rIterat0.79  0.83
4   rTDD 0.9  0.96
5   rStandup0.83  0.82
6rRetros 0.9  0.95
7rAccess0.91  0.92
8   rAccTest0.87   0.9

#
LV - c(rPlanning, rIterat, rTDD, rStandup, rRetros, rAccess,
rAccTest)
#
loopCronbach - function(latentVariableNames, groupingVariable)
{
result - latentVariableNames
names(result) - c(latentVariable, Indiv, Group)
 for (currentName in latentVariableNames)
{
print(currentName)
print(result)
tmp1 - calculateIndividualCronbach(get(currentName))
tmp2 - calculateGroupCronbach(get(currentName), groupingVariable)
result - rbind(result,data.frame(latentVariable=currentName,
Indiv=tmp1,Group=tmp2))
}
return(result)
}

On Thu, Feb 11, 2010 at 3:31 AM, jim holtman jholt...@gmail.com wrote:


 It doing exactly what you asked it to do.  You have the assignment:

 result - latentVariableNames

 and then you print it out in the loop.  What were you expecting?

 On Wed, Feb 10, 2010 at 9:06 PM, Chaehan So chaehan...@gmail.com wrote:

   Dear r-helpers,
  
   why do I get an output in the first iteration of the for-loop
   which contains the string values of the input vector,
   and how can I avoid that?

 
  Here's the output (only line 1 is wrong)
 
   latentVariable   Indiv Group
  1  rPlanning rIterat  rTDD
  2  rPlanning0.79  0.84
  3rIterat0.79  0.83
  4   rTDD 0.9  0.96
  5   rStandup0.83  0.82
  6rRetros 0.9  0.95
  7rAccess0.91  0.92
  8   rAccTest0.87   0.9
 
  #
  LV - c(rPlanning, rIterat, rTDD, rStandup, rRetros, rAccess,
  rAccTest)
  #
  loopCronbach - function(latentVariableNames, groupingVariable)
  {
  result - latentVariableNames
  names(result) - c(latentVariable, Indiv, Group)
   for (currentName in latentVariableNames)
  {
  print(currentName)
  print(result)
  tmp1 - calculateIndividualCronbach(get(currentName))

   tmp2 - calculateGroupCronbach(get(currentName), groupingVariable)

  result - rbind(result,data.frame(latentVariable=currentName,
  Indiv=tmp1,Group=tmp2))
  }
  return(result)
  }
 
 
  a - loopCronbach(LV, u_proj)
 
 [[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?





--
Humboldt University Berlin, Germany
Institute of Psychology
Rudower Chaussee 18, Room 1221
12489 Berlin
Germany
Office: +49 30 2093 - 9337
Mobile: +49 171- 626 9373

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



--
--
Don 

Re: [R] histogam plots

2010-02-11 Thread li li
Thank you very much for your reply. That was very helpful.
I also want to add two density curves on top of each histgram. One is the
density curve of a standard normal random variable. The other is the
denstity curve according to the histgram.
I was trying to use the function
panel.mathdensity, but not successful.

Can anyone give me some help?

Thank you!
2010/2/11 bill.venab...@csiro.au

 One way round this is to use lattice.  With your matrix 'w' you might

 W - data.frame(w = as.vector(w),
  r = factor(as.vector(row(w))) )

 require(lattice)
 histogram(~w|r, W)

 Identical axis systems will be used for all panels.


 Bill Venables
 CSIRO/CMIS Cleveland Laboratories


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of li li
 Sent: Thursday, 11 February 2010 2:52 PM
 To: r-help
 Subject: [R] histogam plots

 Hi all,
   I want to draw a histgram for each row of a matrix and compare them.
 However the plot I
 got does not have the same y range and x range, which makes it difficult to
 make the comparison.
 Is there a  easy way to fix the x range and y range in a xy plot for
 several
 plots, instead of specifying
 them for each plot.
  The following is my code for generalizing the matrix and draw the
 histogram.


 gen is the function to generate the dta
 gen - function(m, rho) {
 library(MASS)
 set.seed(103)
 theta - 0
 theta1 - 2
 pi0 - 0.9
 mzero - pi0*m
 mean - c(rep(theta, mzero), rep(theta1,m-mzero))
 J - rep(1, m)
 var - function(rho) {(1-rho)*diag(m)+ rho*J%*%t(J)}
 t - mvrnorm(1, mean, var(rho))
 return(t)
}
 ### w is the matrix. A histgram is drawn for each of the rows.
 n - 1000
 r - seq(0,0.9, by=0.1)

 w - matrix(0, ncol=n, nrow=length(r))
 for (i in 1: length(r)){w[i,]- gen(n,r[i])}

 par(mfrow=c(2,5))
 hist(w[1,], breaks=100)
 hist(w[2,], breaks=100)
 hist(w[3,], breaks=100)
 hist(w[4,], breaks=100)
 hist(w[5,], breaks=100)
 hist(w[6,], breaks=100)
 hist(w[7,], breaks=100)
 hist(w[8,], breaks=100)
 hist(w[9,], breaks=100)
 hist(w[10,], breaks=100)

 ##
  Thank you !
  Li

[[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.htmlhttp://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] Creating a new Access database with R

2010-02-11 Thread Ryusuke Kenji

I am facing the same problem as well, I would like to code with following 
concept but wondering how to cope it.

if (*mdb file exist)
{ add new row/col }
else
   { add new *mdb file }

   
--



From: Uri Shimron UriShimron_at_optiver.com


Date: Thu 21 Sep 2006 - 13:27:35 GMT





First of all, since this is my first posting, I would like to thank
anybody who works/has worked on R, and made it such a beautiful open
source package!



My question is: how do I create a new Access database with R? I need a
channel before I can do anything, but if the mdb-file doesn't exist, I
can't connect to it with odbcConnectAccess.



I've looked at the RODBC.pdf on CRAN, searched the mailing-lists, and
looked at test.R file in the package. But probably I've overlooked
something.



It is of course possible to keep a clean new mdb-file somewhere and then
copy it to the required directory with: 
shell(copy EmptyDB.mdb NewLocation.mdb)



But that isn't very elegant...



Thanks in advance,



Uri Shimron



  
_
USB$B%a%b%jBe$o$j$K$*;H$$$/$...@$5$$!#l5na$g;H$($k(B25GB$B!#(B

[[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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Ivan Calandra
Hi!

|colClasses|   character. A vector of classes to be assumed for the 
columns.
I'm not an R expert and I don't know what your flat file raw is, but 
the colClasses argument is to define whether the column will be treated 
as containing factors, logical, integer etc...
For more on read.table, read the manual R Data Import/Export available 
on the R-project website.

I don't know if it helps, but I hope it does!

Ivan

Le 2/11/2010 16:36, Johan Jackson a écrit :
 Hi all,

 First off, it is surprising that there are no examples of how to use
 read.table() under ?read.table !

 I am trying to read in a flat file of type 'raw'. It has 1000 rows and 600K
 columns. I have the RAM to accomplish this, but can't get the data into R
 using read.table:

 x- read.table(data,header=TRUE,colClasses=rep(,60))
 #returns error:  no method or default for coercing character to raw

 Then I thought that maybe the colClasses vector needed to actually *be* the
 mode needed (here's where an example under ?read.table would help):

 x- read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))

 I waited on the latter command for a couple of hours before killing the
 process. What should the colClasses argument be?

 Should I be using another method to read the data into R? Previous
 experience using scan() and readLines() showed that read.table() was faster,
 at least for those examples, so I've stopped trying to use those other
 functions.

 Thank you,

 JJ

   [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R] Simplify the code

2010-02-11 Thread li li
Thank you for your reply. I was just trying to make the code less
complicated.
I got your point.
Thanks!

2010/2/11 Petr PIKAL petr.pi...@precheza.cz

 Hi

 I did not see the answer yet, probably nobody is much interested in such
 function, so I will try.

 r-help-boun...@r-project.org napsal dne 10.02.2010 21:57:42:

  Hi all,
 I wrote the following code for the function that is attached.
  I want to simply the code.

 Why. If it works there is no problem until you encounter performance
 issues. If it does not work you shall specify what is wrong with it.

 Many functions are vectorised (including choose and beta) so you could
 probably get rid of nested cycles but I am far from elaborating how to
 change your code and make it simpler (shorter, quicker ???)

 Regards
 Petr

  Can some one give me some help?
 
 
  The function is attached and the following is the code:
  
  ## f1 is the function calculate the value outside the sum
  f1 - function(t, a, b) {t/beta(a, b)}
  ## f2 is the function that calculates the summand
  f2 - function(j, k, t, a, b){choose(j-1,k-1)*(1-t)^(j-1) * beta(a+k,
 b+j-
  k)}
  ## f3 calculates the sum
  f3 - function(n, t, a, b){
  ss - matrix(0, nrow=n, ncol=n)
  for (j in 1:n){
  for (i in 1:j) {
  ss[i,j]- f2(j,i, t, a, b)
  }
  }
  sum - sum(ss)
  return(sum)
  }
  ## f is the final function
  f - function(n,t, a, b) {f1(t,a ,b)*f3(n,t,a,b)}
 
 
 ##
 
 Many thanks!
 
 
 
 
 
 
 
 
   Hannah
  [pøíloha question to R-heip.pdf odstranìna u¾ivatelem Petr PIKAL/CTCAP]
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://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] Zero-inflated Negat. Binom. model

2010-02-11 Thread Achim Zeileis

On Thu, 11 Feb 2010, Luciano La Sala wrote:


Dear R crew:

I am sorry this question has been posted before, but I can't seem to solve
this problem yet.


Just for the others reader who might not recall that you asked virtually 
the same question last week. This was my reply:

  https://stat.ethz.ch/pipermail/r-help/2010-February/227040.html


I have a simple dataset consisting of two variables: cestode intensity and
chick size (defined as CAPI).
Intensity is a count and clearly overdispersed, with way too many zeroes.
I'm interested in looking at the association between these two variables,
i.e. how well does chick size predict tape intensity?

Since I have a small sample size, I fit a zero inflated negat. Binomial (not
Poisson) model using the pscl package.

I built tried two models and got the outputs below.


model - zeroinfl(Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)


Call:
zeroinfl(formula = Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)

Count model coefficients (negbin with log link):
(Intercept) CAPI
  -2.99182  0.06817
Theta = 0.4528

Zero-inflation model coefficients (binomial with logit link):
(Intercept) CAPI
   12.1364  -0.1572


summary(model)


Call:
zeroinfl(formula = Int_Cesto ~ CAPI, dist = negbin, EM = TRUE)

Pearson residuals:
Min   1Q   Median   3Q  Max
-0.62751 -0.38842 -0.21303 -0.06899  7.29566

Count model coefficients (negbin with log link):
   Estimate Std. Error z value Pr(|z|)
(Intercept) -2.991823.39555  -0.881   0.3783
CAPI 0.068170.04098   1.664   0.0962 .
Log(theta)  -0.792220.45031  -1.759   0.0785 .

Zero-inflation model coefficients (binomial with logit link):
   Estimate Std. Error z value Pr(|z|)
(Intercept) 12.136363.71918   3.263  0.00110 **
CAPI-0.157200.04989  -3.151  0.00163 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Theta = 0.4528
Number of iterations in BFGS optimization: 1
Log-likelihood: -140.2 on 5 Df

QUESTIONS

1. Is my model adequately specified?


See my reply linked above. I guess it's hard to say more than that.


2. CAPI is included in blocks 1 of output containing negative binomial
regression coefficients for CAPI, and is also included also in block 2
corresponding to the inflation model. Does this make sense?


Dito.


If I specify my model slightly differently, I get what I believe is more
reasonable results:


model12 - zeroinfl(Int_Cesto ~ 1|CAPI, dist = negbin, EM = TRUE)
model12


Call:
zeroinfl(formula = Int_Cesto ~ 1 | CAPI, dist = negbin, EM = TRUE)

Count model coefficients (negbin with log link):
(Intercept)
 2.692
Theta = 0.4346

Zero-inflation model coefficients (binomial with logit link):
(Intercept) CAPI
   13.2476  -0.1708


summary(model12)


Call:
zeroinfl(formula = Int_Cesto ~ 1 | CAPI, dist = negbin, EM = TRUE)

Pearson residuals:
Min   1Q   Median   3Q  Max
-0.61616 -0.36902 -0.19466 -0.0  4.85481

Count model coefficients (negbin with log link):
   Estimate Std. Error z value Pr(|z|)
(Intercept)   2.6924 0.3031   8.883   2e-16 ***
Log(theta)   -0.8334 0.4082  -2.042   0.0412 *

Zero-inflation model coefficients (binomial with logit link):
   Estimate Std. Error z value Pr(|z|)
(Intercept) 13.247573.64531   3.634 0.000279 ***
CAPI-0.170780.04921  -3.471 0.000519 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Theta = 0.4346
Number of iterations in BFGS optimization: 1
Log-likelihood: -141.9 on 4 Df

QUESTION:

1.Is this model specification and output more reasonable?
2.CAPI appears only in the second block that corresponds to the
inflation model.


You can apply standard model selection techniques. Hands-on examples for 
that are in the vignette that I pointed you to last week:

  vignette(countreg, package = pscl)

Different model selection strategies may however yield different models. 
AIC will prefer the model with CAPI in the count equation. In contrast, 
a Wald test at 5% level would drop it. You could also look at the BIC and 
at the LR test. My guess is though that the answer will be: CAPI has some 
weak but practically not very relevant influence on the mean in the count 
component.


But I strongly recommend that you try to get more familiar with the 
zero-inflated model and the general model selection strategies. Or you 
could try to get help from a local statistician to obtain an appropriate 
model and interpret its results.


hth,
Z



Thanks in advance!
Luciano









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

Re: [R] trouble with read.table and colClasses='raw'

2010-02-11 Thread Ivan Calandra
Well, it's too complicated for me! Here are what I would do (limited 
since I'm still a newbie)

1) the syntax seems correct, it should work. The problem is somewhere 
else, coming from your own file. Did you try skipping the colClasses 
argument? To see how it looks like... If you can import it that way, try 
str(x) to see what you have. It might help you.
2) I've never had that much data to import, and for me read.table works 
well.

You might want to wait for the experts!

Ivan

Le 2/11/2010 17:14, Johan Jackson a écrit :
 Hi Ivan,

 Thanks for the reply. Damn IT! My original post was screwed up. HERE 
 is what I did:

 x - read.table(data,header=TRUE,colClasses=rep('raw',60))
 #returns error:  no method or default for coercing character to raw

  I've read the ?read.table and the colClasses argument. I'm still unclear:

 1) colClasses is a character vector, is that right? That seems to be 
 what the help says, but I get an error when I do the above.

 2) what is the most efficient way to read in huge amounts of data? In 
 the past I found that scan() and readLines() were slower than read.table.

 Thanks,

 JJ




 On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra 
 ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-hamburg.de 
 wrote:

 Hi!

 |colClasses|   character. A vector of classes to be assumed
 for the
 columns.
 I'm not an R expert and I don't know what your flat file raw is, but
 the colClasses argument is to define whether the column will be
 treated
 as containing factors, logical, integer etc...
 For more on read.table, read the manual R Data Import/Export
 available
 on the R-project website.

 I don't know if it helps, but I hope it does!

 Ivan

 Le 2/11/2010 16:36, Johan Jackson a écrit :
  Hi all,
 
  First off, it is surprising that there are no examples of how to use
  read.table() under ?read.table !
 
  I am trying to read in a flat file of type 'raw'. It has 1000
 rows and 600K
  columns. I have the RAM to accomplish this, but can't get the
 data into R
  using read.table:
 
  x- read.table(data,header=TRUE,colClasses=rep(,60))
  #returns error:  no method or default for coercing character
 to raw
 
  Then I thought that maybe the colClasses vector needed to
 actually *be* the
  mode needed (here's where an example under ?read.table would help):
 
  x- read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))
 
  I waited on the latter command for a couple of hours before
 killing the
  process. What should the colClasses argument be?
 
  Should I be using another method to read the data into R? Previous
  experience using scan() and readLines() showed that read.table()
 was faster,
  at least for those examples, so I've stopped trying to use those
 other
  functions.
 
  Thank you,
 
  JJ
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailto:R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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 mailto:R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] AFTREG with ID argument

2010-02-11 Thread David Winsemius


On Feb 11, 2010, at 5:58 AM, Philipp Rappold wrote:


Göran, thanks!

One more thing that I found: As soon as you have at least one NA in  
the independent vars, the trick that you mentioned does not work  
anymore. Example:


 testdata
 start stop censor groupvar  var1
1 01  01 0.1284928
2 12  01 0.4896125
3 23  01 0.7012899
4 34  01NA
5 01  02 0.7964361
6 12  02 0.8466039
7 23  12 0.2234271

 aftreg(Surv(start, stop, censor)~var1, data=testdata, id=testdata 
$groupvar)
Error in order(id, Y[, 1]) : Different length of arguments (* I  
translated this from the German Output *)


Do you think there is a simple hack which excludes all subjects that  
have at least on NA in their independent vars? If it was only one  
dependent var it would probably be easy by just using subset, but I  
have lots of different combinations of vars that I'd like to test ;)




I don't know if it's a hack, but there are a set of functions that  
perform such subsetting:


?na.omit

There is a parameter that would accomplish that goal inside aftreg.  
You may want to check what your defaults are for na.action.


--
David.


Best
Philipp

PS: Conerning the benmark: For a large dataset (~ 1600 observations  
on ~300 subjects) processing takes about 40 seconds (core 2 duo @  
2.46 GHz, T9300). Interestingly, processing the testdata-set above  
with only 7 observations on 2 subjects takes 2 minutes...


Göran Broström wrote:

Philipp Rappold wrote:

Dear all,

I have some trouble using the id-argument with aftreg  
(accelerated failure time regression analysis from the eha library).


As far as I understand it, the id argument is used to group  
individuals together if there are time-varying covariates and the  
data is arranged in counting process style.


Unfortunately, i cannot figure out how to use the id-argument.  
The most straight-forward way would be to simply state the  
grouping variable, but it throws an error. I've included an  
example below: the dataframe for regression is called test, with  
the grouping variable person.


 test
 start end censor person var1
1 0   1  0  1  0.5
2 1   2  0  1  0.4
3 2   3  0  1  0.6
4 3   4  1  1 -0.3
5 0   1  0  2  0.6
6 1   2  0  2  0.7
7 2   3  0  2  0.6

 fit - aftreg(Surv(start, end, censor)~var1, data=test, id=person)
Error in order(id, Y[, 1]) : argument 1 is not a vector
You have caught the _function_ 'person' (package: utils) instead of  
the variable 'person' in the data frame. That explains the odd  
error message. If you change the variable name to, e.g., ID,  
you'll get the error message

Error in order(id, Y[, 1]) : object 'id' not found
which would hint you in the right direction. You need to specify   
'id' by a full name, in your case 'test$person'. This is of course  
a deficiency in the interface of aftreg. I will fix it asap.

So the temporary fix is 'id = test$person'.
Thanks for the report,
Göran


 fit - aftreg(Surv(start, end, censor)~var1, data=test,  
id=test[person])

Error in `[.data.frame`(id, ord) : undefined columns selected



What would be the correct way to fit this example model?

Thanks + all the best
Philipp




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


[R] Access variables by string

2010-02-11 Thread Philipp Rappold

Dear all,

I have two probably very easy questions:

(1) Is there a way to access certain variables by their string-based 
name representation?


Example:
numbers - c(one, two, three)
varname - numbers
print(varname[2])

(2) I need this functionality for a customized na.exclude() function 
that I am building, which should only exclude rows that have NA in 
certain columns. Maybe there is already a function which does 
exactly what I need, so I'd highly appreciate if someone could point 
me there ;)


My current implementation looks like this:

naexlcude - function(data, varnames)
{
for(v in varnames){
data = subset(data, !is.na(v))
}

data
}

Best
Philipp

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Suprising behavior of paste or cat?

2010-02-11 Thread David Winsemius


On Feb 11, 2010, at 10:17 AM, Russell Pierce wrote:


If the list would provide additional reports I'd appreciate it.  I
replicated the effect this morning on another Windows XP machine...


Worked as expected on a Mac OSX 10.5.8, R 2.10.1, [R.app GUI 1.30  
(5534) x86_64-apple-darwin9.8.0]


--
David.

R version 2.10.1 (2009-12-14)
i386-pc-mingw32

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

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

loaded via a namespace (and not attached):
[1] tools_2.10.1
...
and I replicated it using the current development build...

R version 2.11.0 Under development (unstable) (2010-02-09 r51113)
i386-pc-mingw32

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

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

In additionally I've determined that when h.long = 150; both cat and
write fail, but when h.long = 100 only the file write with cat fails.

Please advise.

Best,

Russell

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Question re model development

2010-02-11 Thread David Winsemius


On Feb 11, 2010, at 9:10 AM, Stratos Laskarides wrote:


Dear Sir/Madam

I'm trying quite a long shot here...

I have used R previously, and would just like to know if any  
software/model
has been designed which will allow me to project the future risk  
profile of
a group of insured lives (by factors such as age, gender etc.),  
based on
past and exisiting risk profiles of the covered lives? If you could  
point me
in the direction of a similar project or code it would be much  
appreciated.



R has been used in actuarial research. There is an actuar package,  
although I do not use it for my work on insurance related topics. I  
have been using survival models and R has a rich set of tools for that  
purpose. Perhaps you could be more specific.




Thank you.
Stratos Laskarides

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


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] Integral of function of dnorm

2010-02-11 Thread Trafim Vanishek
This is exactly what I mean.

I need to find integrate(dnorm(mean=8,sd=1)*log(dnorm(mean=8,sd=1)), -Inf,
Inf)

Which doesn't work like that, because it says:
Error in dnorm(mean = 8, sd = 1) : element 1 is empty;
   the part of the args list of '.Internal' being evaluated was:
   (x, mean, sd, log)

So how can I define x?
THanks a lot


  Dear all,

 How is it possible in R to calculate the following integral:
 Integral(-Inf, Inf)[log(dnorm(mean = 3, sd = 1))]

 how can I define that the density dnorm is taken on (-Inf, Inf)

 Thanks a lot!


 Er, if you mean integral with respect to the x argument in dnorm, then the
 answer is -Inf because log(dnorm(x,...)) goes quadratically to -Inf in both
 directions. If you meant otherwise, please tell us what you meant...


[[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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Don MacQueen
The error message says there is no method for 
converting from 'character' to 'raw'.
Apparently, R is seeing character data in the 
file, and is trying to convert it to raw, since 
you specified raw, and it can't.


See, for example,

 as('aa','raw')

Error in as(aa, raw) :
  no method or default for coercing character to raw

(same error message)

So I would ask, what are your data, really? Why 
are you asking for raw? Have you checked the help 
page for raw to make sure it's what you want?


-Don

At 5:23 PM +0100 2/11/10, Ivan Calandra wrote:

Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Content-length: 3983

Well, it's too complicated for me! Here are what I would do (limited
since I'm still a newbie)

1) the syntax seems correct, it should work. The problem is somewhere
else, coming from your own file. Did you try skipping the colClasses
argument? To see how it looks like... If you can import it that way, try
str(x) to see what you have. It might help you.
2) I've never had that much data to import, and for me read.table works
well.

You might want to wait for the experts!

Ivan

Le 2/11/2010 17:14, Johan Jackson a écrit :

 Hi Ivan,

 Thanks for the reply. Damn IT! My original post was screwed up. HERE
 is what I did:

 x - read.table(data,header=TRUE,colClasses=rep('raw',60))
 #returns error:  no method or default for coercing character to raw

  I've read the ?read.table and the colClasses argument. I'm still unclear:

 1) colClasses is a character vector, is that right? That seems to be
 what the help says, but I get an error when I do the above.

 2) what is the most efficient way to read in huge amounts of data? In
 the past I found that scan() and readLines() were slower than read.table.

 Thanks,

 JJ




 On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra
 ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-hamburg.de
 wrote:

 Hi!

 |colClasses|   character. A vector of classes to be assumed
 for the
 columns.
 I'm not an R expert and I don't know what your flat file raw is, but
 the colClasses argument is to define whether the column will be
 treated
 as containing factors, logical, integer etc...
 For more on read.table, read the manual R Data Import/Export
 available
 on the R-project website.

 I don't know if it helps, but I hope it does!

 
  Ivan
 
  Le 2/11/2010 16:36, Johan Jackson a écrit :
   Hi all,
  
   First off, it is surprising that there are no examples of how to use
   read.table() under ?read.table !

 
  I am trying to read in a flat file of type 'raw'. It has 1000
 rows and 600K
  columns. I have the RAM to accomplish this, but can't get the
 data into R
  using read.table:
 
  x- read.table(data,header=TRUE,colClasses=rep(,60))
  #returns error:  no method or default for coercing character
 to raw
 
  Then I thought that maybe the colClasses vector needed to
 actually *be* the
  mode needed (here's where an example under ?read.table would help):
 
  x- read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))
 
  I waited on the latter command for a couple of hours before
 killing the
  process. What should the colClasses argument be?
 
  Should I be using another method to read the data into R? Previous
  experience using scan() and readLines() showed that read.table()
 was faster,
  at least for those examples, so I've stopped trying to use those
 other
  functions.
 
  Thank you,
 
  JJ
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailto:R-help@r-project.org mailing list

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



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org 

Re: [R] Access variables by string

2010-02-11 Thread Peter Dalgaard
Philipp Rappold wrote:
 Dear all,
 
 I have two probably very easy questions:
 
 (1) Is there a way to access certain variables by their string-based
 name representation?
 
 Example:
 numbers - c(one, two, three)
 varname - numbers
 print(varname[2])
 
 (2) I need this functionality for a customized na.exclude() function
 that I am building, which should only exclude rows that have NA in
 certain columns. Maybe there is already a function which does exactly
 what I need, so I'd highly appreciate if someone could point me there ;)
 
 My current implementation looks like this:
 
 naexlcude - function(data, varnames)
 {
 for(v in varnames){
 data = subset(data, !is.na(v))
 }
 
 data
 }
 

Well, you can use get(varname)[2] or more generally things like
eval(bquote(.(as.name(varname))[2])), but for this particular
application, why not just use the standard indexing techniques?

I think this will do

ix - apply(is.na(data[varnames]), 1, any)
data[!ix,]

e.g.

 table(apply(is.na(airquality[c(Wind,Ozone)]),1, any))

FALSE  TRUE
  11637
 colSums(is.na(airquality))
  Ozone Solar.RWindTemp   Month Day
 37   7   0   0   0   0
 table(apply(is.na(airquality[c(Solar.R,Ozone)]),1, any))

FALSE  TRUE
  11142


(Using functions like subset inside another function often leads to
problems because of the nonstandard evaluation tricks that it uses. It
is mainly useful to save tying on the command line.)

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Access variables by string

2010-02-11 Thread Don MacQueen

For your first question, use the get() function

-Don

At 5:18 PM +0100 2/11/10, Philipp Rappold wrote:

Dear all,

I have two probably very easy questions:

(1) Is there a way to access certain variables by their string-based 
name representation?


Example:
numbers - c(one, two, three)
varname - numbers
print(varname[2])

(2) I need this functionality for a customized na.exclude() function 
that I am building, which should only exclude rows that have NA in 
certain columns. Maybe there is already a function which does 
exactly what I need, so I'd highly appreciate if someone could point 
me there ;)


My current implementation looks like this:

naexlcude - function(data, varnames)
{
for(v in varnames){
data = subset(data, !is.na(v))
}

data
}

Best
Philipp

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



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 ANOVA gives diferent results than SPSS

2010-02-11 Thread Jeremy Miles
I've always found exactly the same results.

If you post code that allows us to reproduce this, I suspect someone
would be able to shed light on it.  And output too.

J





On 11 February 2010 06:47, Protzko prot...@gmail.com wrote:

 I guess my subject says it all.  But I loaded a dataset in spss and used the
 foreign package to read and save it in R.  Running an anova (using the aov
 command) gives a different F and p value in R than it does in SPSS.  ANy
 idea what is going on?
 --
 View this message in context: 
 http://n4.nabble.com/R-ANOVA-gives-diferent-results-than-SPSS-tp1477322p1477322.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.




-- 
Jeremy Miles
Psychology Research Methods Wiki: www.researchmethodsinpsychology.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] Suprising behavior of paste or cat?

2010-02-11 Thread William Dunlap


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Russell Pierce
 Sent: Wednesday, February 10, 2010 9:21 PM
 To: r-help@r-project.org
 Subject: [R] Suprising behavior of paste or cat?
 
 I may be making a simple error, but I've looked at the str() of the
 resulting objects and I can't see any obvious reason I'm having the
 problem I am having, so I am reaching out to the R-help group.  I am
 generating a string in my code.  When I make a slight modification
 (add a comma at the end using my lastcomma function), I can no
 longer successfully write that string to a file.  Specifically, the
 resulting file contains only the ⰱ character.

That character (which prints as an unfilled square when
I look at it in Outlook) is (when I copy and paste it
to R 2.10.0 on Windows): 
ⰱ
   [1] \u2c31
The 2 bytes in it would be comma and one in ascii:
\x2c
   [1] ,
\x31
  [1] 1
It looks like a ascii/UTF-8 mismatch.  Is the square Outlook's
way of saying it is illegal UTF-8?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 This occurs in:
 R version 2.10.0 (2009-10-26)  R version 2.10.1 (2009-12-14)
 i386-pc-mingw32
 locale:
 [1] LC_COLLATE=English_United States.1252
 [2] LC_CTYPE=English_United States.1252
 [3] LC_MONETARY=English_United States.1252
 [4] LC_NUMERIC=C
 [5] LC_TIME=English_United States.1252
 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base
 but not in...
 R version 2.7.1 (2008-06-23)
 x86_64-pc-linux-gnu
 locale:
 LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLA
 TE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=
 en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREME
 NT=en_US.UTF-8;LC_IDENTIFICATION=C
 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base
 Sample code:
 h.long - 150
 task - c(rep(1,h.long),rep(2,h.long))
 ord - sample(1:length(task))
 task - task[ord]
 taskout - paste(task,collapse=,)
 write(file=please.txt,taskout)
 lastcomma - function(x) {return(paste(x,,,collapse=,sep=))}
 res - lastcomma(taskout)
 write(file=fail.txt,res)
 cat(file=catfail.txt,res)
 
 Any ideas as to how to avoid this problem would be appriciated as well
 as suggestions as to whether this is expected behavior, or whether it
 ought to be reported as a bug.
 
 Best,
 
 Russell Pierce
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] R ANOVA gives diferent results than SPSS

2010-02-11 Thread Peter Dalgaard
Thomas Lumley wrote:
 On Thu, 11 Feb 2010, Protzko wrote:
 

 I guess my subject says it all.  But I loaded a dataset in spss and
 used the
 foreign package to read and save it in R.  Running an anova (using the
 aov
 command) gives a different F and p value in R than it does in SPSS.  ANy
 idea what is going on?
 
 Yes. Either you specified a different model or different tests for the
 same model in the two systems, or you are interpreting the output
 incorrectly, or the results are different.

Also beware of unbalanced data sets, aov() will not handle Error() terms
properly in an unbalanced design, and in general tests will be order
dependent (type 1 tests in SAS terminology).

 
 Without more detail it is hard to be sure, but the first two
 possibilities seem more likely.

Yes, many people on the list can probably spot the issue when seeing the
two anova tables.

 
 -thomas
 
 Thomas LumleyAssoc. Professor, Biostatistics
 tlum...@u.washington.eduUniversity of Washington, Seattle
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Integral of function of dnorm

2010-02-11 Thread Charles Annis, P.E.
Here's a suggestion:  Plot the function:

x - seq(3, 13, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

x - seq(7.5, 8.5, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

x - seq(7.9, 8.1, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

This suggests to me that you can integrate over restricted domains of x, and
sum the intermediate results.


Charles Annis, P.E.

charles.an...@statisticalengineering.com
561-352-9699
http://www.StatisticalEngineering.com

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Trafim Vanishek
Sent: Thursday, February 11, 2010 11:49 AM
To: Peter Dalgaard
Cc: r-help@r-project.org
Subject: Re: [R] Integral of function of dnorm

This is exactly what I mean.

I need to find integrate(dnorm(mean=8,sd=1)*log(dnorm(mean=8,sd=1)), -Inf,
Inf)

Which doesn't work like that, because it says:
Error in dnorm(mean = 8, sd = 1) : element 1 is empty;
   the part of the args list of '.Internal' being evaluated was:
   (x, mean, sd, log)

So how can I define x?
THanks a lot


  Dear all,

 How is it possible in R to calculate the following integral:
 Integral(-Inf, Inf)[log(dnorm(mean = 3, sd = 1))]

 how can I define that the density dnorm is taken on (-Inf, Inf)

 Thanks a lot!


 Er, if you mean integral with respect to the x argument in dnorm, then the
 answer is -Inf because log(dnorm(x,...)) goes quadratically to -Inf in
both
 directions. If you meant otherwise, please tell us what you meant...


[[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] Creating a new Access database with R

2010-02-11 Thread Paul-

As a workaround, you can keep an empty mdb file on your filesystem. When you
need a new database, you can copy and rename the empty file.

-- 
View this message in context: 
http://n4.nabble.com/Re-Creating-a-new-Access-database-with-R-tp1477400p1477533.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] aggregate function / custom column names?

2010-02-11 Thread Chuck White
This question is about column names returned by the aggregate function. 
Consider the following example

df - data.frame(
   id = c(rep('11',30),rep('22',30),rep('33',30)),
   value = c(rnorm(30,2,0.5), rnorm(30,3,0.5), rnorm(30,6,0.5))
)

aggregate(df[,c(value),drop=FALSE], by=list(id=df$id), max)
output:
  idvalue
1 11 2.693528
2 22 3.868400
3 33 6.942519

aggregate(df$value, by=list(id=df$id), max)
output:
  idx
1 11 2.693528
2 22 3.868400
3 33 6.942519

(YMMV on output values since data is randomly generated)

I would like to be able to name the output column as max.value.  I realize I 
can add the following statement:
colnames(df)[match(value,colnames(df))] - max.value

Is there a way of having aggregate return computed column names which can be 
specified when calling the function (i.e. aggregate)?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Johan Jackson
Hi Don and all,

I guess we're getting somewhere. Thanks. The file (first three columns,
first five rows) looks like this:

X10 X20 X30
00   0001
00   02   02
00   00  00
00   01  01
00  00  00


I guess R is reading 00 as a character? But here's the weird thing: this
data (a raw matrix in R) was written out by R itself:

write.table(dat,data,col.names=T,row.names=F,quote=F)

*If* I understand correctly, then this seems like very *bad behavior* on R's
part: you should be able to write out a matrix and read it right back into R
without hassles like this (but everytime I blame R, it turns out to be user
error, so...),

JJ



On Thu, Feb 11, 2010 at 9:59 AM, Don MacQueen m...@llnl.gov wrote:

 The error message says there is no method for converting from 'character'
 to 'raw'.
 Apparently, R is seeing character data in the file, and is trying to
 convert it to raw, since you specified raw, and it can't.

 See, for example,

  as('aa','raw')

 Error in as(aa, raw) :

  no method or default for coercing character to raw

 (same error message)

 So I would ask, what are your data, really? Why are you asking for raw?
 Have you checked the help page for raw to make sure it's what you want?

 -Don

 At 5:23 PM +0100 2/11/10, Ivan Calandra wrote:

 Content-Type: text/plain
 Content-Disposition: inline
 Content-Transfer-Encoding: 8bit
 Content-length: 3983


 Well, it's too complicated for me! Here are what I would do (limited
 since I'm still a newbie)

 1) the syntax seems correct, it should work. The problem is somewhere
 else, coming from your own file. Did you try skipping the colClasses
 argument? To see how it looks like... If you can import it that way, try
 str(x) to see what you have. It might help you.
 2) I've never had that much data to import, and for me read.table works
 well.

 You might want to wait for the experts!

 Ivan

 Le 2/11/2010 17:14, Johan Jackson a écrit :

  Hi Ivan,

  Thanks for the reply. Damn IT! My original post was screwed up. HERE
  is what I did:

  x - read.table(data,header=TRUE,colClasses=rep('raw',60))
  #returns error:  no method or default for coercing character to raw

  I've read the ?read.table and the colClasses argument. I'm still
 unclear:

  1) colClasses is a character vector, is that right? That seems to be
  what the help says, but I get an error when I do the above.

  2) what is the most efficient way to read in huge amounts of data? In
  the past I found that scan() and readLines() were slower than
 read.table.

  Thanks,

  JJ




  On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra
  ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-hamburg.de
  wrote:

 Hi!

 |colClasses|   character. A vector of classes to be assumed
 for the
 columns.
 I'm not an R expert and I don't know what your flat file raw is,
 but
 the colClasses argument is to define whether the column will be
 treated
 as containing factors, logical, integer etc...
 For more on read.table, read the manual R Data Import/Export
 available
 on the R-project website.

 I don't know if it helps, but I hope it does!

  
   Ivan
  
   Le 2/11/2010 16:36, Johan Jackson a écrit :
Hi all,
   
First off, it is surprising that there are no examples of how to
 use
read.table() under ?read.table !

 
  I am trying to read in a flat file of type 'raw'. It has 1000
 rows and 600K
  columns. I have the RAM to accomplish this, but can't get the
 data into R
  using read.table:
 
  x- read.table(data,header=TRUE,colClasses=rep(,60))
  #returns error:  no method or default for coercing character
 to raw
 
  Then I thought that maybe the colClasses vector needed to
 actually *be* the
  mode needed (here's where an example under ?read.table would help):
 
  x- read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))
 
  I waited on the latter command for a couple of hours before
 killing the
  process. What should the colClasses argument be?
 
  Should I be using another method to read the data into R? Previous
  experience using scan() and readLines() showed that read.table()
 was faster,
  at least for those examples, so I've stopped trying to use those
 other
  functions.
 
  Thank you,
 
  JJ
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailto:R-help@r-project.org mailing list

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

Re: [R] aggregate function / custom column names?

2010-02-11 Thread Gabor Grothendieck
Try this:

 aggregate(list(Max = df$value), df['id'], max)
  id  Max
1 11 2.610491
2 22 3.796836
3 33 6.562515

or if using value rather than Max is ok then just:

 aggregate(df['value'], df['id'], max)
  idvalue
1 11 2.610491
2 22 3.796836
3 33 6.562515


On Thu, Feb 11, 2010 at 12:18 PM, Chuck White chuckwhi...@charter.net wrote:
 This question is about column names returned by the aggregate function. 
 Consider the following example

 df - data.frame(
   id = c(rep('11',30),rep('22',30),rep('33',30)),
   value = c(rnorm(30,2,0.5), rnorm(30,3,0.5), rnorm(30,6,0.5))
 )

 aggregate(df[,c(value),drop=FALSE], by=list(id=df$id), max)
 output:
  id    value
 1 11 2.693528
 2 22 3.868400
 3 33 6.942519

 aggregate(df$value, by=list(id=df$id), max)
 output:
  id        x
 1 11 2.693528
 2 22 3.868400
 3 33 6.942519

 (YMMV on output values since data is randomly generated)

 I would like to be able to name the output column as max.value.  I realize I 
 can add the following statement:
 colnames(df)[match(value,colnames(df))] - max.value

 Is there a way of having aggregate return computed column names which can be 
 specified when calling the function (i.e. aggregate)?

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Access variables by string

2010-02-11 Thread Benilton Carvalho
On Thu, Feb 11, 2010 at 4:18 PM, Philipp Rappold
philipp.rapp...@gmail.com wrote:
 Dear all,

 I have two probably very easy questions:

 (1) Is there a way to access certain variables by their string-based name
 representation?

 Example:
 numbers - c(one, two, three)
 varname - numbers
 print(varname[2])

print(get(varname)[2])


 (2) I need this functionality for a customized na.exclude() function that I
 am building, which should only exclude rows that have NA in certain columns.
 Maybe there is already a function which does exactly what I need, so I'd
 highly appreciate if someone could point me there ;)

 My current implementation looks like this:

 naexlcude - function(data, varnames)
 {
        for(v in varnames){
                data = subset(data, !is.na(v))
        }

        data
 }

f = function(x, vars) x[complete.cases(x[vars]),]

b


 Best
 Philipp

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Fwd: Recall function: evaluation nested too deeply: infinite recursion / options(expressions=)?

2010-02-11 Thread Allan Clark
hello all
 
i searched the archives and couldn't get a solution to the following question. 
 
i have the following function:
 
F=function(z,v)
{
  if (v==-.5) return(1) else  return(2*v/z + 1/Recall(z,v-1))
}
 
and while testing whether it works (ie F(z,v) is approx =  
besselK(z,1+v)/besselK(z,V). the recursion formula allows one to calculate 
besselK(z,1+v)/besselK(z,V) for large values of z ) i got the following error : 
evaluation nested too deeply: infinite recursion / options(expressions=)?
 
i.e. 
zz=1
nn=1000

R=array(0,dim=nn)
for (i in 1:nn)
{
  print(i)
  R[i]=F(zz,-0.5+(i-1))
}
the error occurs when i==713
but when one evaluates F(1,-.5+(713-1)) i get [1] 1423.001
note also that if v starts getting large, evaluation of F also gives the error. 
e.g. F(1, 713.5)
 
any help?
 
 
seems like looping works nicely here
 
F2=function(z,v)
{
  #check that the v is correct! ie -.5, .5, 3/2, 5/2, .
  
  if (v==-0.5)
  {
return(1)
  }else
  {
ntimes = v+1.5
R=array(0,dim=ntimes)
 
R[1]=1
for (i in 2:ntimes)
{
  R[i]= 2*v/z + 1/R[i-1]
}
return(R[ntimes])
  }
}

 

 
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm
 
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm
 

[[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] Integral of function of dnorm

2010-02-11 Thread Peter Ehlers

Here's another suggestion: evaluate

 -0.5 * (log(2 * pi) + 1)  ## -1.418939

Or you can do the integral:

 f - function(x, mu = 8, s = 1){
 dnorm(x, mu, s) * log(dnorm(x, mu, s))}

 integrate(f, lower = -2, upper = 18)
#-1.418939 with absolute error  2.8e-10

Try other values for lower= and upper= and see
if you can understand why -Inf, Inf won't work.

You can also plot your function with, e.g.

 curve(f, 7, 9)

 -Peter Ehlers

Charles Annis, P.E. wrote:

Here's a suggestion:  Plot the function:

x - seq(3, 13, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

x - seq(7.5, 8.5, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

x - seq(7.9, 8.1, length=101)
plot(x, y=dnorm(x, mean=8,sd=1)*log(dnorm(x,mean=8,sd=1)))

This suggests to me that you can integrate over restricted domains of x, and
sum the intermediate results.


Charles Annis, P.E.

charles.an...@statisticalengineering.com
561-352-9699
http://www.StatisticalEngineering.com

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Trafim Vanishek
Sent: Thursday, February 11, 2010 11:49 AM
To: Peter Dalgaard
Cc: r-help@r-project.org
Subject: Re: [R] Integral of function of dnorm

This is exactly what I mean.

I need to find integrate(dnorm(mean=8,sd=1)*log(dnorm(mean=8,sd=1)), -Inf,
Inf)

Which doesn't work like that, because it says:
Error in dnorm(mean = 8, sd = 1) : element 1 is empty;
   the part of the args list of '.Internal' being evaluated was:
   (x, mean, sd, log)

So how can I define x?
THanks a lot



 Dear all,

How is it possible in R to calculate the following integral:
Integral(-Inf, Inf)[log(dnorm(mean = 3, sd = 1))]

how can I define that the density dnorm is taken on (-Inf, Inf)

Thanks a lot!


Er, if you mean integral with respect to the x argument in dnorm, then the
answer is -Inf because log(dnorm(x,...)) goes quadratically to -Inf in

both

directions. If you meant otherwise, please tell us what you meant...



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




--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Integral of function of dnorm

2010-02-11 Thread Greg Snow
Try:

 tmpfun - function(x) dnorm(x,mean=8,sd=1)*log(dnorm(x,mean=8,sd=1))
 integrate( tmpfun, -Inf, Inf)

Also you may want to look at the log argument to dnorm rather than taking the 
log of the function.

Hope this helps,

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Trafim Vanishek
 Sent: Thursday, February 11, 2010 9:49 AM
 To: Peter Dalgaard
 Cc: r-help@r-project.org
 Subject: Re: [R] Integral of function of dnorm
 
 This is exactly what I mean.
 
 I need to find integrate(dnorm(mean=8,sd=1)*log(dnorm(mean=8,sd=1)), -
 Inf,
 Inf)
 
 Which doesn't work like that, because it says:
 Error in dnorm(mean = 8, sd = 1) : element 1 is empty;
the part of the args list of '.Internal' being evaluated was:
(x, mean, sd, log)
 
 So how can I define x?
 THanks a lot
 
 
   Dear all,
 
  How is it possible in R to calculate the following integral:
  Integral(-Inf, Inf)[log(dnorm(mean = 3, sd = 1))]
 
  how can I define that the density dnorm is taken on (-Inf, Inf)
 
  Thanks a lot!
 
 
  Er, if you mean integral with respect to the x argument in dnorm,
 then the
  answer is -Inf because log(dnorm(x,...)) goes quadratically to -Inf
 in both
  directions. If you meant otherwise, please tell us what you meant...
 
 
   [[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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Johan Jackson
Hi Ivan,

Thanks for the reply. Damn IT! My original post was screwed up. HERE is what
I did:

x - read.table(data,header=TRUE,colClasses=rep('raw',60))
#returns error:  no method or default for coercing character to raw

 I've read the ?read.table and the colClasses argument. I'm still unclear:

1) colClasses is a character vector, is that right? That seems to be what
the help says, but I get an error when I do the above.

2) what is the most efficient way to read in huge amounts of data? In the
past I found that scan() and readLines() were slower than read.table.

Thanks,

JJ




On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra ivan.calan...@uni-hamburg.de
 wrote:

 Hi!

 |colClasses|   character. A vector of classes to be assumed for the
 columns.
 I'm not an R expert and I don't know what your flat file raw is, but
 the colClasses argument is to define whether the column will be treated
 as containing factors, logical, integer etc...
 For more on read.table, read the manual R Data Import/Export available
 on the R-project website.

 I don't know if it helps, but I hope it does!

 Ivan

 Le 2/11/2010 16:36, Johan Jackson a écrit :
  Hi all,
 
  First off, it is surprising that there are no examples of how to use
  read.table() under ?read.table !
 
  I am trying to read in a flat file of type 'raw'. It has 1000 rows and
 600K
  columns. I have the RAM to accomplish this, but can't get the data into R
  using read.table:
 
  x- read.table(data,header=TRUE,colClasses=rep(,60))
  #returns error:  no method or default for coercing character to raw
 
  Then I thought that maybe the colClasses vector needed to actually *be*
 the
  mode needed (here's where an example under ?read.table would help):
 
  x- read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))
 
  I waited on the latter command for a couple of hours before killing the
  process. What should the colClasses argument be?
 
  Should I be using another method to read the data into R? Previous
  experience using scan() and readLines() showed that read.table() was
 faster,
  at least for those examples, so I've stopped trying to use those other
  functions.
 
  Thank you,
 
  JJ
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

[[alternative HTML version deleted]]


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



[[alternative HTML version deleted]]

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


Re: [R] Fwd: Recall function: evaluation nested too deeply: infinite recursion / options(expressions=)?

2010-02-11 Thread jim holtman
You might be impacted by FAQ 7.31.

Your statement  if(v == -.5)

might be suspect.  You might want to use 'all.equal'

On Thu, Feb 11, 2010 at 11:40 AM, Allan Clark allan.cl...@uct.ac.za wrote:
 hello all

 i searched the archives and couldn't get a solution to the following question.

 i have the following function:

 F=function(z,v)
 {
  if (v==-.5) return(1) else  return(2*v/z + 1/Recall(z,v-1))
 }

 and while testing whether it works (ie F(z,v) is approx =  
 besselK(z,1+v)/besselK(z,V). the recursion formula allows one to calculate 
 besselK(z,1+v)/besselK(z,V) for large values of z ) i got the following error 
 : evaluation nested too deeply: infinite recursion / options(expressions=)?

 i.e.
 zz=1
 nn=1000

 R=array(0,dim=nn)
 for (i in 1:nn)
 {
  print(i)
  R[i]=F(zz,-0.5+(i-1))
 }
 the error occurs when i==713
 but when one evaluates F(1,-.5+(713-1)) i get [1] 1423.001
 note also that if v starts getting large, evaluation of F also gives the 
 error. e.g. F(1, 713.5)

 any help?


 seems like looping works nicely here

 F2=function(z,v)
 {
  #check that the v is correct! ie -.5, .5, 3/2, 5/2, .

  if (v==-0.5)
  {
    return(1)
  }else
  {
    ntimes = v+1.5
    R=array(0,dim=ntimes)

    R[1]=1
    for (i in 2:ntimes)
    {
      R[i]= 2*v/z + 1/R[i-1]
    }
    return(R[ntimes])
  }
 }






 Allan Clark
 
 Lecturer in Statistical Sciences Department
 University of Cape Town
 7701 Rondebosch
 South Africa
 TEL (Office): +27-21-650-3228
 FAX: +27-21-650-4773
 http://web.uct.ac.za/depts/stats/aclark.htm



 Allan Clark
 
 Lecturer in Statistical Sciences Department
 University of Cape Town
 7701 Rondebosch
 South Africa
 TEL (Office): +27-21-650-3228
 FAX: +27-21-650-4773
 http://web.uct.ac.za/depts/stats/aclark.htm


        [[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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Greg Snow
The read.table function does not know how to convert the character 
representation that it reads into raw variables.  Try using 'integer' for the 
colClasses to read the data in as integers, then convert those back to raw (if 
that is really what you need).

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Johan Jackson
 Sent: Thursday, February 11, 2010 10:29 AM
 To: Don MacQueen
 Cc: r-help@r-project.org
 Subject: Re: [R] trouble with read.table and colClasses='raw'
 
 Hi Don and all,
 
 I guess we're getting somewhere. Thanks. The file (first three columns,
 first five rows) looks like this:
 
 X10 X20 X30
 00   0001
 00   02   02
 00   00  00
 00   01  01
 00  00  00
 
 
 I guess R is reading 00 as a character? But here's the weird thing:
 this
 data (a raw matrix in R) was written out by R itself:
 
 write.table(dat,data,col.names=T,row.names=F,quote=F)
 
 *If* I understand correctly, then this seems like very *bad behavior*
 on R's
 part: you should be able to write out a matrix and read it right back
 into R
 without hassles like this (but everytime I blame R, it turns out to be
 user
 error, so...),
 
 JJ
 
 
 
 On Thu, Feb 11, 2010 at 9:59 AM, Don MacQueen m...@llnl.gov wrote:
 
  The error message says there is no method for converting from
 'character'
  to 'raw'.
  Apparently, R is seeing character data in the file, and is trying to
  convert it to raw, since you specified raw, and it can't.
 
  See, for example,
 
   as('aa','raw')
 
  Error in as(aa, raw) :
 
   no method or default for coercing character to raw
 
  (same error message)
 
  So I would ask, what are your data, really? Why are you asking for
 raw?
  Have you checked the help page for raw to make sure it's what you
 want?
 
  -Don
 
  At 5:23 PM +0100 2/11/10, Ivan Calandra wrote:
 
  Content-Type: text/plain
  Content-Disposition: inline
  Content-Transfer-Encoding: 8bit
  Content-length: 3983
 
 
  Well, it's too complicated for me! Here are what I would do (limited
  since I'm still a newbie)
 
  1) the syntax seems correct, it should work. The problem is
 somewhere
  else, coming from your own file. Did you try skipping the colClasses
  argument? To see how it looks like... If you can import it that way,
 try
  str(x) to see what you have. It might help you.
  2) I've never had that much data to import, and for me read.table
 works
  well.
 
  You might want to wait for the experts!
 
  Ivan
 
  Le 2/11/2010 17:14, Johan Jackson a écrit :
 
   Hi Ivan,
 
   Thanks for the reply. Damn IT! My original post was screwed up.
 HERE
   is what I did:
 
   x - read.table(data,header=TRUE,colClasses=rep('raw',60))
   #returns error:  no method or default for coercing character to
 raw
 
   I've read the ?read.table and the colClasses argument. I'm still
  unclear:
 
   1) colClasses is a character vector, is that right? That seems to
 be
   what the help says, but I get an error when I do the above.
 
   2) what is the most efficient way to read in huge amounts of data?
 In
   the past I found that scan() and readLines() were slower than
  read.table.
 
   Thanks,
 
   JJ
 
 
 
 
   On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra
   ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-
 hamburg.de
   wrote:
 
  Hi!
 
  |colClasses|   character. A vector of classes to be
 assumed
  for the
  columns.
  I'm not an R expert and I don't know what your flat file raw
 is,
  but
  the colClasses argument is to define whether the column will be
  treated
  as containing factors, logical, integer etc...
  For more on read.table, read the manual R Data Import/Export
  available
  on the R-project website.
 
  I don't know if it helps, but I hope it does!
 
   
Ivan
   
Le 2/11/2010 16:36, Johan Jackson a écrit :
 Hi all,

 First off, it is surprising that there are no examples of
 how to
  use
 read.table() under ?read.table !
 
  
   I am trying to read in a flat file of type 'raw'. It has 1000
  rows and 600K
   columns. I have the RAM to accomplish this, but can't get the
  data into R
   using read.table:
  
   x- read.table(data,header=TRUE,colClasses=rep(,60))
   #returns error:  no method or default for coercing
 character
  to raw
  
   Then I thought that maybe the colClasses vector needed to
  actually *be* the
   mode needed (here's where an example under ?read.table would
 help):
  
   x-
 read.table(data,header=TRUE,colClasses=rep(as.raw(1),60))
  
   I waited on the latter command for a couple of hours before
  killing the
   process. What should the colClasses argument be?
  
   Should I be using another method to read the data into R?
 Previous
 

Re: [R] histogam plots

2010-02-11 Thread Dennis Murphy
Hi:

## Histogram + density plots in lattice and ggplot2

# example data frame
x - data.frame(x = rnorm(600), g = factor(rep(1:6, each = 100)))

# lattice
library(lattice)
histogram(~ x | g, data = dd, type = 'density',
  panel = function(x, subscripts, ...) {
panel.histogram(x, ...)
panel.mathdensity(dnorm, col = 'red', ...)
panel.densityplot(x, plot.points = FALSE, col = 'navy',...)
   } )

# ggplot2
library(ggplot2)
p - ggplot(data = dd, aes(x = x, group = g))
p + geom_histogram(aes(y = ..density..), binwidth = 0.5) +
geom_density(color = 'navy') + stat_function(fun = 'dnorm') +
facet_wrap(~ g, ncol = 3) + ylab(Density)


If you prefer the ordering given by ggplot2, then in the lattice invocation,
addas.table = TRUE, in the line above the panel function call.


HTH,
Dennis

On Thu, Feb 11, 2010 at 7:50 AM, li li hannah@gmail.com wrote:

 Thank you very much for your reply. That was very helpful.
 I also want to add two density curves on top of each histgram. One is the
 density curve of a standard normal random variable. The other is the
 denstity curve according to the histgram.
 I was trying to use the function
 panel.mathdensity, but not successful.

 Can anyone give me some help?

 Thank you!
 2010/2/11 bill.venab...@csiro.au

  One way round this is to use lattice.  With your matrix 'w' you might
 
  W - data.frame(w = as.vector(w),
   r = factor(as.vector(row(w))) )
 
  require(lattice)
  histogram(~w|r, W)
 
  Identical axis systems will be used for all panels.
 
 
  Bill Venables
  CSIRO/CMIS Cleveland Laboratories
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
  On Behalf Of li li
  Sent: Thursday, 11 February 2010 2:52 PM
  To: r-help
  Subject: [R] histogam plots
 
  Hi all,
I want to draw a histgram for each row of a matrix and compare them.
  However the plot I
  got does not have the same y range and x range, which makes it difficult
 to
  make the comparison.
  Is there a  easy way to fix the x range and y range in a xy plot for
  several
  plots, instead of specifying
  them for each plot.
   The following is my code for generalizing the matrix and draw the
  histogram.
 
 
  gen is the function to generate the dta
  gen - function(m, rho) {
  library(MASS)
  set.seed(103)
  theta - 0
  theta1 - 2
  pi0 - 0.9
  mzero - pi0*m
  mean - c(rep(theta, mzero), rep(theta1,m-mzero))
  J - rep(1, m)
  var - function(rho) {(1-rho)*diag(m)+ rho*J%*%t(J)}
  t - mvrnorm(1, mean, var(rho))
  return(t)
 }
  ### w is the matrix. A histgram is drawn for each of the rows.
  n - 1000
  r - seq(0,0.9, by=0.1)
 
  w - matrix(0, ncol=n, nrow=length(r))
  for (i in 1: length(r)){w[i,]- gen(n,r[i])}
 
  par(mfrow=c(2,5))
  hist(w[1,], breaks=100)
  hist(w[2,], breaks=100)
  hist(w[3,], breaks=100)
  hist(w[4,], breaks=100)
  hist(w[5,], breaks=100)
  hist(w[6,], breaks=100)
  hist(w[7,], breaks=100)
  hist(w[8,], breaks=100)
  hist(w[9,], breaks=100)
  hist(w[10,], breaks=100)
 
  ##
   Thank you !
   Li
 
 [[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
 http://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] Recall function: evaluation nested too deeply: infinite recursion / options(expressions=)?

2010-02-11 Thread Allan Clark
hello all
 
i searched the archives and couldn't get a solution to the following question. 
 
i have the following function:
 
F=function(z,v)
{
  if (v==-.5) return(1) else  return(2*v/z + 1/Recall(z,v-1))
}
 
and while testing whether it works (ie F(z,v) is approx =  
besselK(z,1+v)/besselK(z,V). the recursion formula allows one to calculate 
besselK(z,1+v)/besselK(z,V) for large values of z ) i got the following error : 
evaluation nested too deeply: infinite recursion / options(expressions=)?
 
i.e. 
zz=1
nn=1000

R=array(0,dim=nn)
for (i in 1:nn)
{
  print(i)
  R[i]=F(zz,-0.5+(i-1))
}
the error occurs when i==713
but when one evaluates F(1,-.5+(713-1)) i get [1] 1423.001
note also that if v starts getting large, evaluation of F also gives the error. 
e.g. F(1, 713.5)
 
any help?
 
 
seems like looping works nicely here
 
F2=function(z,v)
{
  #check that the v is correct! ie -.5, .5, 3/2, 5/2, .
  
  if (v==-0.5)
  {
return(1)
  }else
  {
ntimes = v+1.5
R=array(0,dim=ntimes)
 
R[1]=1
for (i in 2:ntimes)
{
  R[i]= 2*v/z + 1/R[i-1]
}
return(R[ntimes])
  }
}

 

 
 
 
Allan Clark

Lecturer in Statistical Sciences Department
University of Cape Town
7701 Rondebosch
South Africa
TEL (Office): +27-21-650-3228
FAX: +27-21-650-4773
http://web.uct.ac.za/depts/stats/aclark.htm
 

[[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] R ANOVA gives diferent results than SPSS

2010-02-11 Thread Protzko

a one-way ANOVA should be a one-way ANOVA I guess, model is simple enough I
thought.  The F value seems pretty clear, I'm doing nothing fancy here, just
trying to figure out how to do in R what I'm doing in SPSS.
-- 
View this message in context: 
http://n4.nabble.com/R-ANOVA-gives-diferent-results-than-SPSS-tp1477322p1477468.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] Access variables by string

2010-02-11 Thread Dan davison
Philipp Rappold philipp.rappold at gmail.com writes:

 
 Dear all,
 
[...]
 (2) I need this functionality for a customized na.exclude() function 
 that I am building, which should only exclude rows that have NA in 
 certain columns. Maybe there is already a function which does 
 exactly what I need, so I'd highly appreciate if someone could point 
 me there ;)

I would use something like

naexclude - function(data, varnames)
d[rowSums(is.na(data[,varnames,drop=FALSE])) == 0,]

Dan

 
 My current implementation looks like this:
 
 naexlcude - function(data, varnames)
 {
   for(v in varnames){
   data = subset(data, !is.na(v))
   }
 
   data
 }
 
 Best
 Philipp
 


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dual Category X-Axis (Multi-Level)

2010-02-11 Thread Powell, Eric
Hello,

I was wondering if anyone knows of a way to produce multilevel x-axis groupings 
similar to Excel's pivotcharts.  (If you're not sure what I'm talking about, 
here's an example: 
http://peltiertech.com/WordPress/chart-with-a-dual-category-axis/).

I realize that I could use mtext to manually insert text where desired, but I 
was hoping for a more systematic approach.

Thanks in advance,
-eric


[[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] Creating a new Access database with R

2010-02-11 Thread Dieter Menne


Paul- wrote:
 
 As a workaround, you can keep an empty mdb file on your filesystem. When
 you need a new database, you can copy and rename the empty file.
 
 

Creating a new database is not part of (R)ODBC because there are too many
differences between implementations. You you use some RDCOM method to do
that, though. 

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Re-Creating-a-new-Access-database-with-R-tp1477400p1477613.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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Greg Snow
The other possibility is that you could create the function to convert from 
character to raw (possibly wrapping as.raw around as.integer) so that 
read.table knows what to do.

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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Greg Snow
 Sent: Thursday, February 11, 2010 11:06 AM
 To: Johan Jackson; Don MacQueen
 Cc: r-help@r-project.org
 Subject: Re: [R] trouble with read.table and colClasses='raw'
 
 The read.table function does not know how to convert the character
 representation that it reads into raw variables.  Try using 'integer'
 for the colClasses to read the data in as integers, then convert those
 back to raw (if that is really what you need).
 
 --
 Gregory (Greg) L. Snow Ph.D.
 Statistical Data Center
 Intermountain Healthcare
 greg.s...@imail.org
 801.408.8111
 
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Johan Jackson
  Sent: Thursday, February 11, 2010 10:29 AM
  To: Don MacQueen
  Cc: r-help@r-project.org
  Subject: Re: [R] trouble with read.table and colClasses='raw'
 
  Hi Don and all,
 
  I guess we're getting somewhere. Thanks. The file (first three
 columns,
  first five rows) looks like this:
 
  X10 X20 X30
  00   0001
  00   02   02
  00   00  00
  00   01  01
  00  00  00
 
 
  I guess R is reading 00 as a character? But here's the weird thing:
  this
  data (a raw matrix in R) was written out by R itself:
 
  write.table(dat,data,col.names=T,row.names=F,quote=F)
 
  *If* I understand correctly, then this seems like very *bad behavior*
  on R's
  part: you should be able to write out a matrix and read it right back
  into R
  without hassles like this (but everytime I blame R, it turns out to
 be
  user
  error, so...),
 
  JJ
 
 
 
  On Thu, Feb 11, 2010 at 9:59 AM, Don MacQueen m...@llnl.gov wrote:
 
   The error message says there is no method for converting from
  'character'
   to 'raw'.
   Apparently, R is seeing character data in the file, and is trying
 to
   convert it to raw, since you specified raw, and it can't.
  
   See, for example,
  
as('aa','raw')
  
   Error in as(aa, raw) :
  
no method or default for coercing character to raw
  
   (same error message)
  
   So I would ask, what are your data, really? Why are you asking for
  raw?
   Have you checked the help page for raw to make sure it's what you
  want?
  
   -Don
  
   At 5:23 PM +0100 2/11/10, Ivan Calandra wrote:
  
   Content-Type: text/plain
   Content-Disposition: inline
   Content-Transfer-Encoding: 8bit
   Content-length: 3983
  
  
   Well, it's too complicated for me! Here are what I would do
 (limited
   since I'm still a newbie)
  
   1) the syntax seems correct, it should work. The problem is
  somewhere
   else, coming from your own file. Did you try skipping the
 colClasses
   argument? To see how it looks like... If you can import it that
 way,
  try
   str(x) to see what you have. It might help you.
   2) I've never had that much data to import, and for me read.table
  works
   well.
  
   You might want to wait for the experts!
  
   Ivan
  
   Le 2/11/2010 17:14, Johan Jackson a écrit :
  
Hi Ivan,
  
Thanks for the reply. Damn IT! My original post was screwed up.
  HERE
is what I did:
  
x - read.table(data,header=TRUE,colClasses=rep('raw',60))
#returns error:  no method or default for coercing character
 to
  raw
  
I've read the ?read.table and the colClasses argument. I'm still
   unclear:
  
1) colClasses is a character vector, is that right? That seems
 to
  be
what the help says, but I get an error when I do the above.
  
2) what is the most efficient way to read in huge amounts of
 data?
  In
the past I found that scan() and readLines() were slower than
   read.table.
  
Thanks,
  
JJ
  
  
  
  
On Thu, Feb 11, 2010 at 8:53 AM, Ivan Calandra
ivan.calan...@uni-hamburg.de mailto:ivan.calan...@uni-
  hamburg.de
wrote:
  
   Hi!
  
   |colClasses|   character. A vector of classes to be
  assumed
   for the
   columns.
   I'm not an R expert and I don't know what your flat file
 raw
  is,
   but
   the colClasses argument is to define whether the column will
 be
   treated
   as containing factors, logical, integer etc...
   For more on read.table, read the manual R Data
 Import/Export
   available
   on the R-project website.
  
   I don't know if it helps, but I hope it does!
  

 Ivan

 Le 2/11/2010 16:36, Johan Jackson a écrit :
  Hi all,
 
  First off, it is surprising that there are no examples of
  how to
   use
  read.table() under ?read.table !
  
   
I am trying to read in a flat file of type 'raw'. It has
 1000
   

Re: [R] histogam plots

2010-02-11 Thread Dieter Menne


Dennis Murphy wrote:
 
 
 ## Histogram + density plots in lattice and ggplot2
 
 

There was a typo in your example (should be dd - data.frame), but anyway.
ggplot2 needs 10 times as long. While Bill Venables (?) would argue what
are you going to do with 3 seconds in your life, it adds up in lengthy
Sweave reports (yes... caching would be an option).

Still preferring lattice.

Dieter


# example data frame
library(ggplot2)
library(lattice)

dd - data.frame(x = rnorm(600), g = factor(rep(1:6, each = 100)))

# lattice
system.time(
print(histogram(~ x | g, data = dd, type = 'density',
  panel = function(x, subscripts, ...) {
panel.histogram(x, ...)
panel.mathdensity(dnorm, col = 'red', ...)
panel.densityplot(x, plot.points = FALSE, col = 'navy',...)
   } ))
)
# 0.33 seconds

# ggplot2
system.time(
print( ggplot(data = dd, aes(x = x, group = g)) +
  geom_histogram(aes(y = ..density..), binwidth = 0.5) +
geom_density(color = 'navy') + stat_function(fun = 'dnorm') +
facet_wrap(~ g, ncol = 3) + ylab(Density))
)

# 3.7 seconds

-- 
View this message in context: 
http://n4.nabble.com/histogam-plots-tp1476859p1477632.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] Reading raw intensity data from getGEO's gse object

2010-02-11 Thread Dipen

Hello, I am trying to download a SOFT matrix file for GSE series to extract
raw intensity data.

gse- getGEO('GSE', AnnotGPL=T)

However, I am not able to use the function Table(gse), which returns the
following error

Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function Table, for signature
GSE

If I try to use the GDS file, I get only the adjusted log 2 ratio of
intensities.
Is there any way to get to the raw intensity data contained within GSE
object?

Thanks,
Dipen
-- 
View this message in context: 
http://n4.nabble.com/Reading-raw-intensity-data-from-getGEO-s-gse-object-tp1477633p1477633.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] trouble with read.table and colClasses='raw'

2010-02-11 Thread Peter Ehlers

Johan Jackson wrote:

Hi Don and all,

I guess we're getting somewhere. Thanks. The file (first three columns,
first five rows) looks like this:

X10 X20 X30
00   0001
00   02   02
00   00  00
00   01  01
00  00  00


I guess R is reading 00 as a character? But here's the weird thing: this
data (a raw matrix in R) was written out by R itself:

write.table(dat,data,col.names=T,row.names=F,quote=F)

*If* I understand correctly, then this seems like very *bad behavior* on R's
part: you should be able to write out a matrix and read it right back into R
without hassles like this (but everytime I blame R, it turns out to be user
error, so...),

JJ


Well, R is stupid, of course, so there's not much sense in
blaming R. You could blame the designers/programmers, but I
wouldn't do that - they seem like pretty smart people.

Still, I can sympathize. When I first got my Porsche, I
couldn't figure out how to make it go faster and why it
kept making so much noise. Then someone told me that the
left foot pedal wasn't just a footrest. And thus I discovered
that there are non-automatics in this world. -:)

Anyway, I just read your sample data into R, saved it with
your write() command and read it back with

 dat - read.table(file=data, header=TRUE, colClasses=character)

I suspect that you really don't know what 'raw' type means
and haven't bothered to check ?raw. It's also pretty clear
that you haven't read the colClasses description in
?read.table very carefully. The one thing R help pages are
pretty good at is careful definition of arguments.

I do hope that your day will improve.

 -Peter Ehlers

[..]

--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Suprising behavior of paste or cat?

2010-02-11 Thread Russell Pierce
Thank you for your input so far r-help denizens.  Neither David nor
Peter were able to replicate my result.  Has anybody other than me
been able to generate the failure I'm describing?  So far I've
experienced it on 3 machines, Windows XP/P4/2.1.10, Windows
XP/Atom/2.1.10/2.1.11(release), Windows Vista/Centrino/2.1.10, but
found no problem on linux/2.7.1/x86_64.

Bill's idea is interesting. There may be a mismatch between types
occurring somewhere, but I haven't exactly where yet.  To test our his
idea, I tried changing the order of the values in my vector task so
my output would start off with 2, rather than 1,.  But I did not
observe a change in behavior.

I've generated further sample code to demonstrate the idiosyncraticy
of what I'm observing.

This code segment does not create a failure.
#No failure
lastcomma - function(x) {return(paste(x,,,collapse=,sep=))}
h.long - 150
task1 - c(rep(1,h.long),rep(2,h.long))
task2- c(rep(2,h.long),rep(1,h.long))
res1 - lastcomma(paste(task1,collapse=,))
res2 - lastcomma(paste(task2,collapse=,))
write(file=write-okay1.txt,res1)
cat(file=cat-okay2.txt,res2)

This code segment, where the task vector is reordered using sample as
an index, creates invalid files.
#Failure of write and cat
ord - sample(1:(h.long*2))
task1  - task1[ord]
task2  - task2[ord]
res1.bad - lastcomma(paste(task1,collapse=,))
res2.bad - lastcomma(paste(task2,collapse=,))
write(file=write-bad1.txt,res1.bad)
cat(file=cat-bad2.txt,res2.bad)

This code segment, where the task vector is shorter and reordered,
creates invalid files with cat, but not with write, and only when task
has been passed through my lastcomma function.
#Inconsistent; cat fails but write does not, cat only fails when
string has been passed through lastcomma
h.long - 100
task1 - c(rep(1,h.long),rep(2,h.long))
task2- c(rep(2,h.long),rep(1,h.long))
ord - sample(1:(h.long*2))
task1  - task1[ord]
task2  - task2[ord]
res1.no.lastcomma - paste(task1,collapse=,)
res2.no.lastcomma - paste(task2,collapse=,)
res1.yes.lastcomma - lastcomma(res1.no.lastcomma)
res2.yes.lastcomma - lastcomma(res2.no.lastcomma)
write(file=write-1-nlc.txt,res1.no.lastcomma) #okay
write(file=write-2-nlc.txt,res2.no.lastcomma) #okay
cat(file=cat-1-nlc.txt,res1.no.lastcomma) #okay
cat(file=cat-2-nlc.txt,res2.no.lastcomma) #okay
write(file=write-1-lc.txt,res1.yes.lastcomma) #okay
write(file=write-2-lc.txt,res2.yes.lastcomma) #okay
cat(file=cat-1-lc.txt,res1.yes.lastcomma) #bad
cat(file=cat-2-lc.txt,res2.yes.lastcomma) #bad

Thanks,

Russell

On Thu, Feb 11, 2010 at 9:05 AM, William Dunlap wdun...@tibco.com wrote:


 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Russell Pierce
 Sent: Wednesday, February 10, 2010 9:21 PM
 To: r-help@r-project.org
 Subject: [R] Suprising behavior of paste or cat?

 I may be making a simple error, but I've looked at the str() of the
 resulting objects and I can't see any obvious reason I'm having the
 problem I am having, so I am reaching out to the R-help group.  I am
 generating a string in my code.  When I make a slight modification
 (add a comma at the end using my lastcomma function), I can no
 longer successfully write that string to a file.  Specifically, the
 resulting file contains only the ⰱ character.

 That character (which prints as an unfilled square when
 I look at it in Outlook) is (when I copy and paste it
 to R 2.10.0 on Windows):
    ⰱ
   [1] \u2c31
 The 2 bytes in it would be comma and one in ascii:
    \x2c
   [1] ,
    \x31
  [1] 1
 It looks like a ascii/UTF-8 mismatch.  Is the square Outlook's
 way of saying it is illegal UTF-8?

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 This occurs in:
 R version 2.10.0 (2009-10-26)  R version 2.10.1 (2009-12-14)
 i386-pc-mingw32
 locale:
 [1] LC_COLLATE=English_United States.1252
 [2] LC_CTYPE=English_United States.1252
 [3] LC_MONETARY=English_United States.1252
 [4] LC_NUMERIC=C
 [5] LC_TIME=English_United States.1252
 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base
 but not in...
 R version 2.7.1 (2008-06-23)
 x86_64-pc-linux-gnu
 locale:
 LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLA
 TE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=
 en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREME
 NT=en_US.UTF-8;LC_IDENTIFICATION=C
 attached base packages:
 [1] stats     graphics  grDevices utils     datasets  methods   base
 Sample code:
 h.long - 150
 task - c(rep(1,h.long),rep(2,h.long))
 ord - sample(1:length(task))
 task - task[ord]
 taskout - paste(task,collapse=,)
 write(file=please.txt,taskout)
 lastcomma - function(x) {return(paste(x,,,collapse=,sep=))}
 res - lastcomma(taskout)
 write(file=fail.txt,res)
 cat(file=catfail.txt,res)

 Any ideas as to how to avoid this problem would be appriciated as well
 as suggestions as to whether this is expected 

Re: [R] R ANOVA gives diferent results than SPSS

2010-02-11 Thread Greg Snow
A couple of possibilities:

The data is not the same, e.g. something in the file was interpreted 
differently by the 2 programs, one of the programs may have stopped reading at 
an unrecognized value, while the other skipped it and went on.  Or it used to 
be common to encode missing values as -999, if one program recognizes that as 
missing, but you did not tell the other one too, then it could treat that as a 
legitimate value.

The model is not the same, e.g. one program may be interpreting your grouping 
variable as a continuous variable and the other as categorical, which would 
result in 2 very different models and outcomes.

If you show us your data/code/output as has been requested, then we may be able 
to tell which it is.  Without that information you are expecting either R or 
the members of the list to read your mind.  I keep making notes to my future 
self to use the timetravel package (not written yet, that's why I need my 
future self to use it) to send a copy of the esp package (also not written yet) 
back in time to me so I can use it for situations like this.  But so far that 
has not worked (maybe my future self is even more lazy than my present self, or 
my near future self does something to offend my far future self enough that he 
is unwilling to do this small favor for my current past self, darn, either way 
means I should probably do better on the diet/exercise).  

The short version of the above rambling is that we want to help, but cannot 
help you until you help us to help you.  Show us your data/code/output (or 
data/code/output for simulated/example data if you can't show your real data).




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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Protzko
 Sent: Thursday, February 11, 2010 9:38 AM
 To: r-help@r-project.org
 Subject: Re: [R] R ANOVA gives diferent results than SPSS
 
 
 a one-way ANOVA should be a one-way ANOVA I guess, model is simple
 enough I
 thought.  The F value seems pretty clear, I'm doing nothing fancy here,
 just
 trying to figure out how to do in R what I'm doing in SPSS.
 --
 View this message in context: http://n4.nabble.com/R-ANOVA-gives-
 diferent-results-than-SPSS-tp1477322p1477468.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Find each time a value changes

2010-02-11 Thread Tim Clark
It was brought to my attention that the rle() answer to this question was not 
posted.  The following gives the correct answer once the last value is deleted.

x-seq(1:100)
y1-rep(1,10)
y2-rep(2,10)
y-c(y1,y2,y1,y1,y1,y2,y1,y2,y1,y2)
xy-cbind(x,y)

print(xy)
print(str(xy))

# SEE WHAT RLE GIVES
test - rle(xy[,2])
print(str(test)
  
# USE JIMS TRICK OF CUMULATIVE SUMMING
# TO GET THE LOCATIONS  
result - cumsum(c(1,rle(xy[,2])$lengths))



Tim Clark
Department of Zoology 
University of Hawaii


--- On Wed, 2/10/10, Ben Tupper ben.bigh...@gmail.com wrote:

 From: Ben Tupper ben.bigh...@gmail.com
 Subject: Re: [R] Find each time a value changes
 To: r-help@r-project.org
 Cc: Tim Clark mudiver1...@yahoo.com
 Date: Wednesday, February 10, 2010, 4:16 PM
 Hi,
 
 On Feb 10, 2010, at 8:58 PM, Tim Clark wrote:
 
  Dear List,
 
  I am trying to find each time a value changes in a
 dataset.  The  
  numbers are variables for day vs. night values, so
 what I am really  
  getting is the daily sunrise and sunset.
 
  A simplified example is the following:
 
  x-seq(1:100)
  y1-rep(1,10)
  y2-rep(2,10)
  y-c(y1,y2,y1,y1,y1,y2,y1,y2,y1,y2)
  xy-cbind(x,y)
 
 
  I would like to know each time the numbers change.
  Correct answer should be:
  x=1,11,21,51,61,71,81,91
 
 
 I think this gets close...
 
 which(diff(y) != 0)
 [1] 10 20 50 60 70 80 90
 
 You'll need to fiddle to get exactly what you want.
 
 Cheers,
 Ben
 
 
 
  I would appreciate any help or suggestions.  It
 seems like it should  
  be simple but I’m stuck!
 
  Thanks,
 
  Tim
 
 
  Tim Clark
  Department of Zoology
  University of Hawaii
 
 
 
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/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] Suprising behavior of paste or cat?

2010-02-11 Thread Duncan Murdoch
I don't think you have said how you are examining the output files.  Is 
it possible that your text editor is assuming that the files are UCS-2 
(Unicode), even

though R is writing ASCII?

Duncan Murdoch

On 11/02/2010 1:44 PM, Russell Pierce wrote:

Thank you for your input so far r-help denizens.  Neither David nor
Peter were able to replicate my result.  Has anybody other than me
been able to generate the failure I'm describing?  So far I've
experienced it on 3 machines, Windows XP/P4/2.1.10, Windows
XP/Atom/2.1.10/2.1.11(release), Windows Vista/Centrino/2.1.10, but
found no problem on linux/2.7.1/x86_64.

Bill's idea is interesting. There may be a mismatch between types
occurring somewhere, but I haven't exactly where yet.  To test our his
idea, I tried changing the order of the values in my vector task so
my output would start off with 2, rather than 1,.  But I did not
observe a change in behavior.

I've generated further sample code to demonstrate the idiosyncraticy
of what I'm observing.

This code segment does not create a failure.
#No failure
lastcomma - function(x) {return(paste(x,,,collapse=,sep=))}
h.long - 150
task1 - c(rep(1,h.long),rep(2,h.long))
task2- c(rep(2,h.long),rep(1,h.long))
res1 - lastcomma(paste(task1,collapse=,))
res2 - lastcomma(paste(task2,collapse=,))
write(file=write-okay1.txt,res1)
cat(file=cat-okay2.txt,res2)

This code segment, where the task vector is reordered using sample as
an index, creates invalid files.
#Failure of write and cat
ord - sample(1:(h.long*2))
task1  - task1[ord]
task2  - task2[ord]
res1.bad - lastcomma(paste(task1,collapse=,))
res2.bad - lastcomma(paste(task2,collapse=,))
write(file=write-bad1.txt,res1.bad)
cat(file=cat-bad2.txt,res2.bad)

This code segment, where the task vector is shorter and reordered,
creates invalid files with cat, but not with write, and only when task
has been passed through my lastcomma function.
#Inconsistent; cat fails but write does not, cat only fails when
string has been passed through lastcomma
h.long - 100
task1 - c(rep(1,h.long),rep(2,h.long))
task2- c(rep(2,h.long),rep(1,h.long))
ord - sample(1:(h.long*2))
task1  - task1[ord]
task2  - task2[ord]
res1.no.lastcomma - paste(task1,collapse=,)
res2.no.lastcomma - paste(task2,collapse=,)
res1.yes.lastcomma - lastcomma(res1.no.lastcomma)
res2.yes.lastcomma - lastcomma(res2.no.lastcomma)
write(file=write-1-nlc.txt,res1.no.lastcomma) #okay
write(file=write-2-nlc.txt,res2.no.lastcomma) #okay
cat(file=cat-1-nlc.txt,res1.no.lastcomma) #okay
cat(file=cat-2-nlc.txt,res2.no.lastcomma) #okay
write(file=write-1-lc.txt,res1.yes.lastcomma) #okay
write(file=write-2-lc.txt,res2.yes.lastcomma) #okay
cat(file=cat-1-lc.txt,res1.yes.lastcomma) #bad
cat(file=cat-2-lc.txt,res2.yes.lastcomma) #bad

Thanks,

Russell

On Thu, Feb 11, 2010 at 9:05 AM, William Dunlap wdun...@tibco.com wrote:


 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Russell Pierce
 Sent: Wednesday, February 10, 2010 9:21 PM
 To: r-help@r-project.org
 Subject: [R] Suprising behavior of paste or cat?

 I may be making a simple error, but I've looked at the str() of the
 resulting objects and I can't see any obvious reason I'm having the
 problem I am having, so I am reaching out to the R-help group.  I am
 generating a string in my code.  When I make a slight modification
 (add a comma at the end using my lastcomma function), I can no
 longer successfully write that string to a file.  Specifically, the
 resulting file contains only the ⰱ character.

 That character (which prints as an unfilled square when
 I look at it in Outlook) is (when I copy and paste it
 to R 2.10.0 on Windows):
ⰱ
   [1] \u2c31
 The 2 bytes in it would be comma and one in ascii:
\x2c
   [1] ,
\x31
  [1] 1
 It looks like a ascii/UTF-8 mismatch.  Is the square Outlook's
 way of saying it is illegal UTF-8?

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 This occurs in:
 R version 2.10.0 (2009-10-26)  R version 2.10.1 (2009-12-14)
 i386-pc-mingw32
 locale:
 [1] LC_COLLATE=English_United States.1252
 [2] LC_CTYPE=English_United States.1252
 [3] LC_MONETARY=English_United States.1252
 [4] LC_NUMERIC=C
 [5] LC_TIME=English_United States.1252
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 but not in...
 R version 2.7.1 (2008-06-23)
 x86_64-pc-linux-gnu
 locale:
 LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLA
 TE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=
 en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREME
 NT=en_US.UTF-8;LC_IDENTIFICATION=C
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 Sample code:
 h.long - 150
 task - c(rep(1,h.long),rep(2,h.long))
 ord - sample(1:length(task))
 task - task[ord]
 taskout - paste(task,collapse=,)
 write(file=please.txt,taskout)
 

Re: [R] Creating a new Access database with R

2010-02-11 Thread Barry Rowlingson
On Thu, Feb 11, 2010 at 6:23 PM, Dieter Menne
dieter.me...@menne-biomed.de wrote:


 Paul- wrote:

 As a workaround, you can keep an empty mdb file on your filesystem. When
 you need a new database, you can copy and rename the empty file.



 Creating a new database is not part of (R)ODBC because there are too many
 differences between implementations. You you use some RDCOM method to do
 that, though.

 Create an empty mdb file in the usual way, then read it into R using
a binary file connection, save it as an R object. To create, spew the
raw bytes back out to another connection. Something like:

mdb = readBin(test1.mdb,what=raw,n=7)
 length(mdb)
[1] 65536

Ooh, 64kbytes. If that's too big, run length encoding will shrink it somewhat:

 rle(mdb)
Run Length Encoding
  lengths: int [1:3953] 1 1 2 1 1 1 1 1 1 1 ...
  values : raw [1:3953] 00 01 00 53 ...

 However, I just created two via the MS ODBC dialog, and they aren't
identical. They are wildly different. I suspect it's just creation
dates and times in the system tables. You should be okay.

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.


Re: [R] Dual Category X-Axis (Multi-Level)

2010-02-11 Thread Greg Snow
Using mtext is probably one of the most straight forward ways.  You can also 
use something like:

par(mfrow=c(1,3), mar=c(5.1,0,4.1,0), oma=c(0,4.1,0,1.1))

one - 1:3
two - 2:5
three - 6:4

names(one) - LETTERS[1:3]
names(two) - letters[2:5]
names(three) - state.abb[6:4]

tmp.ylim - range(0,one,two,three)

barplot(one, col='red', bty='n', xlab='one', ylim=tmp.ylim)
barplot(two, col='green', bty='n', xlab='two', ylim=tmp.ylim, ylab='', yaxt='n')
barplot(three, col='blue', xlab='three', bty='n', ylim=tmp.ylim, ylab='', 
yaxt='n')


Or you could put that in a loop.

Hope this helps,


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


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Powell, Eric
 Sent: Thursday, February 11, 2010 9:16 AM
 To: 'r-help@r-project.org'
 Subject: [R] Dual Category X-Axis (Multi-Level)
 
 Hello,
 
 I was wondering if anyone knows of a way to produce multilevel x-axis
 groupings similar to Excel's pivotcharts.  (If you're not sure what I'm
 talking about, here's an example:
 http://peltiertech.com/WordPress/chart-with-a-dual-category-axis/).
 
 I realize that I could use mtext to manually insert text where desired,
 but I was hoping for a more systematic approach.
 
 Thanks in advance,
 -eric
 
 
   [[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] Find each time a value changes

2010-02-11 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Tim Clark
 Sent: Thursday, February 11, 2010 10:53 AM
 To: r-help@r-project.org
 Subject: Re: [R] Find each time a value changes
 
 It was brought to my attention that the rle() answer to this 
 question was not posted.  The following gives the correct 
 answer once the last value is deleted.
 
 x-seq(1:100)
 y1-rep(1,10)
 y2-rep(2,10)
 y-c(y1,y2,y1,y1,y1,y2,y1,y2,y1,y2)
 xy-cbind(x,y)
 
 print(xy)
 print(str(xy))
 
 # SEE WHAT RLE GIVES
 test - rle(xy[,2])
 print(str(test)
   
 # USE JIMS TRICK OF CUMULATIVE SUMMING
 # TO GET THE LOCATIONS  
 result - cumsum(c(1,rle(xy[,2])$lengths))

This cumsum undoes the diff that rle does.
You could do what the first half of rle does with
   isFirstInRun - function(x)c(TRUE, x[-1]!=x[-length(x)]
or 
   isLastInRun - function(x)c(x[-1]!=x[-length(x)], TRUE)
Use as
   which(isFirstInRun(xy[,2]))

 
 
 
 Tim Clark
 Department of Zoology 
 University of Hawaii
 
 
 --- On Wed, 2/10/10, Ben Tupper ben.bigh...@gmail.com wrote:
 
  From: Ben Tupper ben.bigh...@gmail.com
  Subject: Re: [R] Find each time a value changes
  To: r-help@r-project.org
  Cc: Tim Clark mudiver1...@yahoo.com
  Date: Wednesday, February 10, 2010, 4:16 PM
  Hi,
  
  On Feb 10, 2010, at 8:58 PM, Tim Clark wrote:
  
   Dear List,
  
   I am trying to find each time a value changes in a
  dataset.  The  
   numbers are variables for day vs. night values, so
  what I am really  
   getting is the daily sunrise and sunset.
  
   A simplified example is the following:
  
   x-seq(1:100)
   y1-rep(1,10)
   y2-rep(2,10)
   y-c(y1,y2,y1,y1,y1,y2,y1,y2,y1,y2)
   xy-cbind(x,y)
  
  
   I would like to know each time the numbers change.
   Correct answer should be:
   x=1,11,21,51,61,71,81,91
  
  
  I think this gets close...
  
  which(diff(y) != 0)
  [1] 10 20 50 60 70 80 90
  
  You'll need to fiddle to get exactly what you want.
  
  Cheers,
  Ben
  
  
  
   I would appreciate any help or suggestions.  It
  seems like it should  
   be simple but I'm stuck!
  
   Thanks,
  
   Tim
  
  
   Tim Clark
   Department of Zoology
   University of Hawaii
  
  
  
  
   __
   R-help@r-project.org
  mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained,
  reproducible code.
  
  
 
 
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


  1   2   >