[R] Forecast Package: Draw two lines on the same plot

2012-11-13 Thread Leo
Hi,

How is it possible to draw to different data on the same graph using
forecast package? The first is the observed data and the second set is the
fitted values. I want the observed data to show as solid line while the
fitted values to show as dashed or dotted line.

regards
Leo

[[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] Discrete trait Ornstein–Uhlenbeck in R?

2012-11-13 Thread KRAmazon
Is there a package that will allow me to fit Brownian motion and
Ornstein–Uhlenbeck models of evolution for discrete traits? I know that
geiger and ouch have commands for fitting these models for continuous
traits, but these aren't suitable for discrete trait evolution, correct?  




--
View this message in context: 
http://r.789695.n4.nabble.com/Discrete-trait-Ornstein-Uhlenbeck-in-R-tp4649356.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] Discrete trait Ornstein–Uhlenbeck in R?

2012-11-13 Thread Jeff Newmiller
I don't know anything about your subject, but have you reviewed

RSiteSearch(ornstein uhlenbeck) 

?
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

KRAmazon sjda...@alumni.uci.edu wrote:

Is there a package that will allow me to fit Brownian motion and
Ornstein–Uhlenbeck models of evolution for discrete traits? I know that
geiger and ouch have commands for fitting these models for continuous
traits, but these aren't suitable for discrete trait evolution,
correct?  




--
View this message in context:
http://r.789695.n4.nabble.com/Discrete-trait-Ornstein-Uhlenbeck-in-R-tp4649356.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] no y-axis

2012-11-13 Thread Jim Lemon

On 11/13/2012 06:59 AM, Geophagus wrote:

thanks, that works fine! good idea.

I have one last question regarding this problem.
My y-scale now is grouped from 0 - 4000 in 1000.
Is it possible to set the scale into not equal breaks like
5,10,100,1000,5000 ?

My axis now:
axis(2,at=seq(0,4000,1000),col = white, las=1)


Hi GeO,
I would suggest using mtext rather than axis.

mtext(c(5,10,100,1000,5000),at=c(5,10,100,1000,5000),
 side=2,line=1)

You may need to twiddle this a bit to get it right.

Jim

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


[R] help formatting data for clustering

2012-11-13 Thread Raphael Bauduin
Hi,

I'm a R beginner. I have data of this form:

user_id, brand_id1, brand_id2, .

for example:
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45

I'm looking for the right procedure to be able to cluster users. I am
especially interested to know which functions to use at each step.

I am currently able to load the data in a data frame, each row's name being
the user id.

#extract user brands, ie all collumn except the first
user_brands - userclustering[,-1]

# extract user ids, ie the first column
user_ids  - userclustering[,1]

# set user ids as row name
row.names(user_brands) - user_ids

But now I'm stuck replacing the brand ids by a count for each brand the
user ordered, all other brand counters being implicitely 0 for that user.

Then I'll need to be sure I can use it for clustering (normalising, correct
handling of brands absent from a user's list, etc).

thanks in advance for your help!

Raph

[[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] Matrix package will not loead

2012-11-13 Thread Uzuner, Tolga I
Dear Fellow R Users,

I am having a problem with the Matrix package, in Windows XP on  R 2.15.1 .

This is the only package where I experience this. I remove the package first, 
re install, and then when trying to load, get a LoadLibrary failure as below.

Thanks in advance for any assistance.

Regards,
Tolga


 remove.packages(Matrix)
Removing package(s) from 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
 install.packages(Matrix)
Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
trying URL 
'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'
Content type 'application/zip' length 3289545 bytes (3.1 Mb)
opened URL
downloaded 3.1 Mb

package 'Matrix' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages
 library(Matrix)
Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared object 
'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
  LoadLibrary failure:  The specified procedure could not be found.

In addition: Warning message:
package 'Matrix' was built under R version 2.15.2
Error: package/namespace load failed for 'Matrix'




This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
[[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] Matrix package will not loead

2012-11-13 Thread Duncan Murdoch

On 12-11-13 7:06 AM, Uzuner, Tolga I wrote:

Dear Fellow R Users,

I am having a problem with the Matrix package, in Windows XP on  R 2.15.1 .

This is the only package where I experience this. I remove the package first, 
re install, and then when trying to load, get a LoadLibrary failure as below.


I've just installed a binary copy of Matrix 1.0-10 in R 2.15.2 patched, 
and I get an error too on attaching it:  The procedure entry point 
Rf_copyListMatrix could not be located in the dynamic link library 
R.dll.  I'm pretty sure that procedure is available in R.dll currently, 
so I don't know what the real problem is.


I have just rebuilt R, and the same package works fine.  So I'd suggest 
that you download the latest R-patched from CRAN, and hopefully things 
will be fine.


Duncan Murdoch




Thanks in advance for any assistance.

Regards,
Tolga



remove.packages(Matrix)

Removing package(s) from 'H:/R/win-library/2.15'
(as 'lib' is unspecified)

install.packages(Matrix)

Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
trying URL 
'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'
Content type 'application/zip' length 3289545 bytes (3.1 Mb)
opened URL
downloaded 3.1 Mb

package 'Matrix' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages

library(Matrix)

Error in inDL(x, as.logical(local), as.logical(now), ...) :
   unable to load shared object 
'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
   LoadLibrary failure:  The specified procedure could not be found.

In addition: Warning message:
package 'Matrix' was built under R version 2.15.2
Error: package/namespace load failed for 'Matrix'






This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
[[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] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread Haris Rhrlp
Dear R users,

I have this program
aa-array(rep(0,27),dim=c(3,3,3))
a-matrix(rep(1,9),ncol=3)
n-0

for (i in 1:3) {
    
      a[i,]-a[i,]*(-1)
      n-n+1
      aa[,,n]-a[i,]

}

but i real want to multiply each row  with -1 according to for loop and after 
that to put it in the array. 

I will give an example for what excaclty want

-1 -1 -1
 1  1  1
 1  1  1

-1 -1 -1
-1 -1 -1
 1  1  1

-1 -1 -1
-1 -1 -1
-1 -1 -1
[[alternative HTML version deleted]]

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


Re: [R] Bootstrapping issues

2012-11-13 Thread PIKAL Petr
Hi


From: Clive Nicholas [mailto:cliveli...@googlemail.com]
Sent: Tuesday, November 13, 2012 3:12 AM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] Bootstrapping issues

Petr Pikal replied:

[...]

 The following works

 results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)

Actually it does not work either

Correct, but I _did_ get it to work shortly before my initial post (sorry for 
not showing it, but I didn't save the output - silly me).

What seems to happen is that I successfully run the version that _does_ work, 
which I then follow up with successful calls to -plot(results,index=#)- and 
-boot.cihttp://boot.ci(results,type=bca,index=#)-, then I follow up with 
the unsuccessful version of the code, which won't run and produces the error, 
but when I go back to run the original code, this too produces the same error. 
This, to me at least, is very weird behaviour for R.


 results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)
Error in data[indices, ] : incorrect number of dimensions

I am not sure but I suspect your bs function expects some indices vector and it 
is somehow not in accordance with your data.

This code, using different simulated data _does_ run, however:




 mytest-data.frame(Y=rnorm(500, mean=60, sd=1), X1=sample(c(AAA, BBB, 
 CCC, DDD, None, NA), size=500, replace=TRUE), X2=sample(c(0.88, 0.99, 
 1.43, 1.22, 1.1), size=500, replace=TRUE), X3=sample(c(Yes, No), 
 size=500, prob=c(0.6,0.4), replace=TRUE))







 bs - function(formula, data, indices) {

+ mytest - data[indices,]

+ fit - lm(formula, data=mytest)

+ return(coef(fit))

+ }

 results - boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)



Hm. Maybe the difference is in using formula.


 results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)



From help page, the fourth parameter is called sim and shall be character 
vector.



See below.



 results - boot(data=mytest, statistic=bs, R=1000, Y~X1+X2+X3)

Error in data[indices, ] : incorrect number of dimensions

 results - boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)

 results



ORDINARY NONPARAMETRIC BOOTSTRAP





Call:

boot(data = mytest, statistic = bs, R = 1000, formula = Y ~ X1 +

X2 + X3)





Bootstrap Statistics :

   originalbiasstd. error

t1* 59.67822240 -0.0060177161  0.29491879

t2*  0.09745349  0.0004995554  0.15627776

t3*  0.24210280 -0.0047317673  0.15018019

t4* -0.03399254 -0.0046603446  0.15884994

t5*  0.15302117 -0.0038503464  0.14045470

t6*  0.15040121  0.0074829413  0.24225957

t7*  0.18454691 -0.0003127565  0.09321305






snip

Answers please!

Do not shout, please. I presented an answer and if you consulted help page you 
could find out what I also found out.

Regards
Petr

Clive Nicholas (clivenicholas.posterous.comhttp://clivenicholas.posterous.com

[Please DO NOT mail me personally here, but at 
clivenicho...@hotmail.commailto:clivenicho...@hotmail.com. Please respond 
to contributions I make in a list thread here. Thanks!]

My colleagues in the social sciences talk a great deal about methodology. I 
prefer to call it style. -- Freeman J. Dyson

[[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] Matrix package will not loead

2012-11-13 Thread Prof Brian Ripley

You will find the problem and solution in the list archives.

The current version of Matrix can be installed *from source* on R (= 
2.15.0), as it claims.  But if you install it on R = 2.15.2 then it 
uses features of 2.15.2 and hence can only be run on R = 2.15.2. And 
there was a warning about this 


On 13/11/2012 12:38, Duncan Murdoch wrote:

On 12-11-13 7:06 AM, Uzuner, Tolga I wrote:

Dear Fellow R Users,

I am having a problem with the Matrix package, in Windows XP on  R
2.15.1 .

This is the only package where I experience this. I remove the package
first, re install, and then when trying to load, get a LoadLibrary
failure as below.


I've just installed a binary copy of Matrix 1.0-10 in R 2.15.2 patched,
and I get an error too on attaching it:  The procedure entry point
Rf_copyListMatrix could not be located in the dynamic link library
R.dll.  I'm pretty sure that procedure is available in R.dll currently,
so I don't know what the real problem is.


The issue is if it is exported from R.dll, which only happened just 
before 2.15.2.  Works for me with the Matrix binary package on the CRAN 
master and both 2.15.2 and the current R-patched (which in any case 
contains that version).




I have just rebuilt R, and the same package works fine.  So I'd suggest
that you download the latest R-patched from CRAN, and hopefully things
will be fine.

Duncan Murdoch




Thanks in advance for any assistance.

Regards,
Tolga



remove.packages(Matrix)

Removing package(s) from 'H:/R/win-library/2.15'
(as 'lib' is unspecified)

install.packages(Matrix)

Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
trying URL
'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'

Content type 'application/zip' length 3289545 bytes (3.1 Mb)
opened URL
downloaded 3.1 Mb

package 'Matrix' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
 C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages

library(Matrix)

Error in inDL(x, as.logical(local), as.logical(now), ...) :
   unable to load shared object
'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
   LoadLibrary failure:  The specified procedure could not be found.

In addition: Warning message:
package 'Matrix' was built under R version 2.15.2
Error: package/namespace load failed for 'Matrix'






This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
[[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.



--
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] Matrix package will not loead

2012-11-13 Thread Uzuner, Tolga I
Many thanks for your advice and assistance. 

Sadly, I am unable to install from source as my operating environment does 
not have Rtools or a compiler.

Is there an old version compiled somewhere I can use ?



 install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL, 
 type=source)
Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
* installing *source* package 'Matrix' ...
** package 'Matrix' successfully unpacked and MD5 sums checked
** libs
ERROR: compilation failed for package 'Matrix'
* removing 'H:/R/win-library/2.15/Matrix'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-215~1.1/bin/i386/R CMD INSTALL -l 
H:/R/win-library/2.15   H:/Downloads/Matrix_1.0-10.tar.gz' had status 1 
2: In install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL,  :
  installation of package 'H:/Downloads/Matrix_1.0-10.tar.gz' had non-zero exit 
status
 install.packages(Matrix, type=source)
Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
Error in download.file(url, destfile, method, mode = wb, ...) : 
  cannot open URL 
'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
In addition: Warning message:
In download.file(url, destfile, method, mode = wb, ...) :
  cannot open: HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  

-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] 
Sent: 13 November 2012 13:03
To: Duncan Murdoch
Cc: Uzuner, Tolga I; r-help@r-project.org
Subject: Re: [R] Matrix package will not loead

You will find the problem and solution in the list archives.

The current version of Matrix can be installed *from source* on R (= 
2.15.0), as it claims.  But if you install it on R = 2.15.2 then it 
uses features of 2.15.2 and hence can only be run on R = 2.15.2. And 
there was a warning about this 

On 13/11/2012 12:38, Duncan Murdoch wrote:
 On 12-11-13 7:06 AM, Uzuner, Tolga I wrote:
 Dear Fellow R Users,

 I am having a problem with the Matrix package, in Windows XP on  R
 2.15.1 .

 This is the only package where I experience this. I remove the package
 first, re install, and then when trying to load, get a LoadLibrary
 failure as below.

 I've just installed a binary copy of Matrix 1.0-10 in R 2.15.2 patched,
 and I get an error too on attaching it:  The procedure entry point
 Rf_copyListMatrix could not be located in the dynamic link library
 R.dll.  I'm pretty sure that procedure is available in R.dll currently,
 so I don't know what the real problem is.

The issue is if it is exported from R.dll, which only happened just 
before 2.15.2.  Works for me with the Matrix binary package on the CRAN 
master and both 2.15.2 and the current R-patched (which in any case 
contains that version).


 I have just rebuilt R, and the same package works fine.  So I'd suggest
 that you download the latest R-patched from CRAN, and hopefully things
 will be fine.

 Duncan Murdoch



 Thanks in advance for any assistance.

 Regards,
 Tolga


 remove.packages(Matrix)
 Removing package(s) from 'H:/R/win-library/2.15'
 (as 'lib' is unspecified)
 install.packages(Matrix)
 Installing package(s) into 'H:/R/win-library/2.15'
 (as 'lib' is unspecified)
 trying URL
 'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'

 Content type 'application/zip' length 3289545 bytes (3.1 Mb)
 opened URL
 downloaded 3.1 Mb

 package 'Matrix' successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages
 library(Matrix)
 Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
 'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
LoadLibrary failure:  The specified procedure could not be found.

 In addition: Warning message:
 package 'Matrix' was built under R version 2.15.2
 Error: package/namespace load failed for 'Matrix'




 This email is confidential and subject to important disclaimers and
 conditions including on offers for the purchase or sale of
 securities, accuracy and completeness of information, viruses,
 confidentiality, legal privilege, and legal entity disclaimers,
 available at http://www.jpmorgan.com/pages/disclosures/email.
 [[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, 

[R] Quastion

2012-11-13 Thread sisay eshetu
 Hey Dear,
I have  got aproblem with interpolation 2D transmisivity in the datasample= 
data.frame, it is not running  I got  this  (Error in 
as.data.frame.default(x[[i]], optional = TRUE) : 
cannot coerce class 'function' into a data.frame). So, how  shall I manage 
this??
Regards,
Siffan
[[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] Proc Nnpar1way with D option - equivalent in R

2012-11-13 Thread SASandRlearn
Dan

Thank you for your reply. I will try what you recommended. 

yes.. i have a 1 and 0 as binary. 

Here is what i have so far 
d - read.csv(c:/test.csv, header=T)
dlogit - glm(x ~ a + b + c, data = d, family = binomial)
attach(d)
ks.test(x, fitted(values),alternative = c(two.sided),exact = NULL)

I would also like to know how to export the model output from the glm into a
output  dataset with those fitted values and then subset them into the 1's
and 0's. That might work as well ? 





--
View this message in context: 
http://r.789695.n4.nabble.com/Proc-Nnpar1way-with-D-option-equivalent-in-R-tp4649348p4649370.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] Can't get R to recognize Java for rJava installation

2012-11-13 Thread gparab
I had similar issue. This worked for me:
get in as root:

export JAVA_HOME=/usr/java/jdk1.6.0_37/jre
export PATH=$PATH:$JAVA_HOME/bin

ln -sf usr/java/default/bin/javah /usr/bin/javah
ln -sf usr/java/default/bin/javap /usr/bin/javap
(basically make sure you have all java* binaries that you have under
usr/java/default/bin/ are also under /usr/bin/ as link. Follow how javac is
placed under /usr/bin/)

R CMD javareconf

now make sure you still have the JAVA_HOME and PATH variable intact as you
set it. Go to R and try installing rJava package, it should work.




--
View this message in context: 
http://r.789695.n4.nabble.com/Can-t-get-R-to-recognize-Java-for-rJava-installation-tp4553023p4649363.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] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread Jan
Hi,

If it is your objective to get your data in an ffdf, I suggest you look at
the SAS/SPSS/Stata code to see where each column is starting, next try out
the  LaF http://cran.r-project.org/web/packages/LaF/index.html   package
as it allows you to read in large fixed width format files and once you have
this up and running, you can use the laf_to_ffdf function at the  ffbase
http://cran.r-project.org/web/packages/ffbase/index.html   package which
works well with the LaF package and allows you import the flat file
immediately into an ffdf for further transactions.

hope that helps,
Jan



--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-information-encoded-in-a-SAS-SPSS-or-Stata-command-file-into-R-tp4649353p4649367.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] no y-axis

2012-11-13 Thread Geophagus
Hi Jim and thanks for your answer.
It does not work how I want. When I use your proposal, the values are
superimposed like shown on the pic.

pic.png http://r.789695.n4.nabble.com/file/n4649368/pic.png  

Thats my code (what I need is a y-scale with the following interrupts:  
5,10,100,1000,5000):

plot(BE_UK_ABFG$year, BE_UK_ABFG$ammo, 
 type=s, 
 col= #DB270F,
 xaxt=n,
 #yaxt=n,
 ylim=c(0,5000),
 xlab=,
 ylab=,
 main=Ammo Rep 1885b, 
 adj=0,
 las = 1,
 lwd=3,
 bty=n
 )
abline(h=0:0,  lwd=1, col=black)
abline(h=1000:1000,  lwd=0.3, col=darkgray, lty=dashed)
abline(h=2000:2000,  lwd=0.3, col=darkgray, lty=dashed)
abline(h=3000:3000,  lwd=0.3, col=darkgray, lty=dashed)
abline(h=4000:4000,  lwd=0.3, col=darkgray, lty=dashed)
abline(h=5000:5000,  lwd=0.3, col=darkgray, lty=dashed)
lines (BE_UK_AW$year, BE_UK_AW$ammo, type=s, col= #826A9F, lwd=3.5)
axis(1,at=seq(2007,2010))
mtext(c(5,10,100,1000,5000),at=c(5,10,100,1000,5000),side=2,line=1, las=1) 


Thank you and best greetings
GeO



--
View this message in context: 
http://r.789695.n4.nabble.com/no-drawn-y-axis-but-values-tp4649298p4649368.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] Can't remember which package I used. Anyone can help please?

2012-11-13 Thread HJ YAN
Dear R users

 I tried an example earlier to check the results using two different
methods of clustering with same data set, and for both methods, say method
A and method B. Also I decided to have same number of groups/clusters (here
8 was chosen).

I found a good graphical tool in R to compare the distribution of the
number in each group/cluster created by method A and method B, e.g. how
many of the individuals are clustered as 'Group 1' both by method A and B,
and how many are clustered as 'Group 2' both by method A and B and so on.
In this case we have 30 and 28 respectively (please see attached table and
plot).

I lost my code and can not remember which packages/functions I used here?
 Could anyone recognize and give me some clue? I only made a note
'crosstable' if can ring your bell...

Many thanks in advance

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

2012-11-13 Thread R. Michael Weylandt
On Tue, Nov 13, 2012 at 9:57 AM, sisay eshetu s.esh...@yahoo.com wrote:
  Hey Dear,
 I have  got aproblem with interpolation 2D transmisivity in the datasample= 
 data.frame, it is not running  I got  this  (Error in 
 as.data.frame.default(x[[i]], optional = TRUE) :
 cannot coerce class 'function' into a data.frame). So, how  shall I manage 
 this??
 Regards,
 Siffan

Hi Siffan,

Your code is, at the moment, far too generic for us to easily answer
it. I might suggest you read the following and then try to make it a
little easier for us to help you.

 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Cheers,
Michael

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


[R] How to visualize relation between two sets of rel. frequencies?

2012-11-13 Thread Stefan Sobernig
I am looking at a data set containing two variables (x,y), each of which 
represents relative frequencies (rounded):


data.frame(x = c(0.1,0.6,0.2,0.1), y = c(0.5,0.2,0.2,0.1))

  xy
1 0.1 0.5
2 0.6 0.2
3 0.2 0.2
4 0.1 0.1

each of the rows reflects a relation between x and y, for example in 
row 4: 10% of the observations in x account for 10% of the observations 
in y.


I feel embarrassed, but my mind went blank, and I can't think of a 
proper way of visualizing this relation based on the data above (nor 
of the appropriate terminology to phrase my question other than by 
example).


My apologies and thanks for your hints!

//stefan

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


Re: [R] standardized residuals / adjusted residuals

2012-11-13 Thread David Meyer


If I call

chisq.test(x)$residuals ; I get the *standardized* residuals (even
though it's called residuals)
chisq.test(x)$stdres ; I get the *adjusted* standardized residuals (even
though it's called stdres)

Is this correct?


I think, yes - as documented on the man page.

Best
David

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Can't remember which package I used. Anyone can help please?

2012-11-13 Thread Mohammed Ouassou
try :

sessionInfo() 

M.O

On ti., 2012-11-13 at 11:12 +, HJ YAN wrote:
 Dear R users
 
  I tried an example earlier to check the results using two different
 methods of clustering with same data set, and for both methods, say method
 A and method B. Also I decided to have same number of groups/clusters (here
 8 was chosen).
 
 I found a good graphical tool in R to compare the distribution of the
 number in each group/cluster created by method A and method B, e.g. how
 many of the individuals are clustered as 'Group 1' both by method A and B,
 and how many are clustered as 'Group 2' both by method A and B and so on.
 In this case we have 30 and 28 respectively (please see attached table and
 plot).
 
 I lost my code and can not remember which packages/functions I used here?
  Could anyone recognize and give me some clue? I only made a note
 'crosstable' if can ring your bell...
 
 Many thanks in advance
 
 HJ
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Matrix package will not loead

2012-11-13 Thread Duncan Murdoch

On 13/11/2012 8:28 AM, Uzuner, Tolga I wrote:

Many thanks for your advice and assistance.

Sadly, I am unable to install from source as my operating environment does 
not have Rtools or a compiler.

Is there an old version compiled somewhere I can use ?


You might be able to find one on a mirror that isn't up to date, but it 
would be a much better idea to update your R to the latest release.


Duncan Murdoch




 install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL, 
type=source)
Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
* installing *source* package 'Matrix' ...
** package 'Matrix' successfully unpacked and MD5 sums checked
** libs
ERROR: compilation failed for package 'Matrix'
* removing 'H:/R/win-library/2.15/Matrix'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-215~1.1/bin/i386/R CMD INSTALL -l 
H:/R/win-library/2.15   H:/Downloads/Matrix_1.0-10.tar.gz' had status 1
2: In install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL,  :
   installation of package 'H:/Downloads/Matrix_1.0-10.tar.gz' had non-zero 
exit status
 install.packages(Matrix, type=source)
Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
Error in download.file(url, destfile, method, mode = wb, ...) :
   cannot open URL 
'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
In addition: Warning message:
In download.file(url, destfile, method, mode = wb, ...) :
   cannot open: HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
   


-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: 13 November 2012 13:03
To: Duncan Murdoch
Cc: Uzuner, Tolga I; r-help@r-project.org
Subject: Re: [R] Matrix package will not loead

You will find the problem and solution in the list archives.

The current version of Matrix can be installed *from source* on R (=
2.15.0), as it claims.  But if you install it on R = 2.15.2 then it
uses features of 2.15.2 and hence can only be run on R = 2.15.2. And
there was a warning about this 

On 13/11/2012 12:38, Duncan Murdoch wrote:
 On 12-11-13 7:06 AM, Uzuner, Tolga I wrote:
 Dear Fellow R Users,

 I am having a problem with the Matrix package, in Windows XP on  R
 2.15.1 .

 This is the only package where I experience this. I remove the package
 first, re install, and then when trying to load, get a LoadLibrary
 failure as below.

 I've just installed a binary copy of Matrix 1.0-10 in R 2.15.2 patched,
 and I get an error too on attaching it:  The procedure entry point
 Rf_copyListMatrix could not be located in the dynamic link library
 R.dll.  I'm pretty sure that procedure is available in R.dll currently,
 so I don't know what the real problem is.

The issue is if it is exported from R.dll, which only happened just
before 2.15.2.  Works for me with the Matrix binary package on the CRAN
master and both 2.15.2 and the current R-patched (which in any case
contains that version).


 I have just rebuilt R, and the same package works fine.  So I'd suggest
 that you download the latest R-patched from CRAN, and hopefully things
 will be fine.

 Duncan Murdoch



 Thanks in advance for any assistance.

 Regards,
 Tolga


 remove.packages(Matrix)
 Removing package(s) from 'H:/R/win-library/2.15'
 (as 'lib' is unspecified)
 install.packages(Matrix)
 Installing package(s) into 'H:/R/win-library/2.15'
 (as 'lib' is unspecified)
 trying URL
 'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'

 Content type 'application/zip' length 3289545 bytes (3.1 Mb)
 opened URL
 downloaded 3.1 Mb

 package 'Matrix' successfully unpacked and MD5 sums checked

 The downloaded binary packages are in
  C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages
 library(Matrix)
 Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
 'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
LoadLibrary failure:  The specified procedure could not be found.

 In addition: Warning message:
 package 'Matrix' was built under R version 2.15.2
 Error: package/namespace load failed for 'Matrix'




 This email is confidential and subject to important disclaimers and
 conditions including on offers for the purchase or sale of
 securities, accuracy and completeness of information, viruses,
 confidentiality, legal privilege, and legal entity disclaimers,
 available at http://www.jpmorgan.com/pages/disclosures/email.
 [[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] Discrete trait Ornstein–Uhlenbeck in R?

2012-11-13 Thread Ben Bolker
KRAmazon sjdavid at alumni.uci.edu writes:

 Is there a package that will allow me to fit Brownian motion and
 Ornstein–Uhlenbeck models of evolution for discrete traits? I know that
 geiger and ouch have commands for fitting these models for continuous
 traits, but these aren't suitable for discrete trait evolution, correct?  

  I'm not quite sure what the model would be, since Brownian and O-U
models are (as far as I know) explicitly defined as models of continuous
traits. The analogue of Brownian motion would presumably be a continuous-time
neutral Markov chain on a discrete space ... (by discrete do you mean
a trait such as microsatellite length, or a categorical trait, or ... ?)

  Have you checked the Phylogenetics task view
cran.r-project.org/web/views/Phylogenetics.html ?  It says that geiger fits
discrete-trait models.
 
  If you don't get an answer here you might have better luck on the
r-sig-ph...@r-project.org mailing list ...

  Ben Bolker

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread arun
HI,

May be this helps:
list1-lapply(lapply(1:3,function(i) {aa[1:i,,i]-a[1:i,]*-1
 return(aa[,,i])}),function(x) apply(x,2,function(i) ifelse(i==0,1,x)))
res-array(unlist(list1),dim=c(nrow(list1[[1]]),ncol(list1[[1]]),length(list1)))


 res
#, , 1
#
 #    [,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]    1    1    1
#[3,]    1    1    1

#, , 2
#
# [,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]   -1   -1   -1
#[3,]    1    1    1
#
#, , 3

  #   [,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]   -1   -1   -1
#[3,]   -1   -1   -1


A.K.

- Original Message -
From: Haris Rhrlp haris_r_h...@yahoo.com
To: R-help@r-project.org R-help@r-project.org
Cc: 
Sent: Tuesday, November 13, 2012 7:41 AM
Subject: [R] multiply each row in a matrix with the help of the for loop

Dear R users,

I have this program
aa-array(rep(0,27),dim=c(3,3,3))
a-matrix(rep(1,9),ncol=3)
n-0

for (i in 1:3) {
    
      a[i,]-a[i,]*(-1)
      n-n+1
      aa[,,n]-a[i,]

}

but i real want to multiply each row  with -1 according to for loop and after 
that to put it in the array. 

I will give an example for what excaclty want

-1 -1 -1
 1  1  1
 1  1  1

-1 -1 -1
-1 -1 -1
 1  1  1

-1 -1 -1
-1 -1 -1
-1 -1 -1
    [[alternative HTML version deleted]]


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


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] multiply each row in a matrix with the help of the for loop

2012-11-13 Thread D. Rizopoulos
Another alternative is:

aa - array(0, dim = c(3,3,3))
a - matrix(1, 3, )

for (i in 1:3) {
  a[i, ] - -a[i, ]
  aa[, , i] - a
}

aa

I hope it helps.

Best,
Dimitris



From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] on behalf of 
arun [smartpink...@yahoo.com]
Sent: Tuesday, November 13, 2012 15:25
To: Haris Rhrlp
Cc: R help
Subject: Re: [R] multiply each row in a matrix with the help of the for loop

HI,

May be this helps:
list1-lapply(lapply(1:3,function(i) {aa[1:i,,i]-a[1:i,]*-1
 return(aa[,,i])}),function(x) apply(x,2,function(i) ifelse(i==0,1,x)))
res-array(unlist(list1),dim=c(nrow(list1[[1]]),ncol(list1[[1]]),length(list1)))


 res
#, , 1
#
 #[,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]111
#[3,]111

#, , 2
#
# [,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]   -1   -1   -1
#[3,]111
#
#, , 3

  #   [,1] [,2] [,3]
#[1,]   -1   -1   -1
#[2,]   -1   -1   -1
#[3,]   -1   -1   -1


A.K.

- Original Message -
From: Haris Rhrlp haris_r_h...@yahoo.com
To: R-help@r-project.org R-help@r-project.org
Cc:
Sent: Tuesday, November 13, 2012 7:41 AM
Subject: [R] multiply each row in a matrix with the help of the for loop

Dear R users,

I have this program
aa-array(rep(0,27),dim=c(3,3,3))
a-matrix(rep(1,9),ncol=3)
n-0

for (i in 1:3) {

  a[i,]-a[i,]*(-1)
  n-n+1
  aa[,,n]-a[i,]

}

but i real want to multiply each row  with -1 according to for loop and after 
that to put it in the array.

I will give an example for what excaclty want

-1 -1 -1
 1  1  1
 1  1  1

-1 -1 -1
-1 -1 -1
 1  1  1

-1 -1 -1
-1 -1 -1
-1 -1 -1
[[alternative HTML version deleted]]


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


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

2012-11-13 Thread Christopher Desjardins
Hi,
I am running the following code based on the cpm vignette's code. I believe
the code is syntactically correct but it just seems to hang R. I can get
this to run if I set the sims to 100 but with 2000 it just hangs. Any ideas
why?
Thanks,
Chris

library(cpm)
cpmTypes - c(Kolmogorov-Smirnov,Mann-Whitney,Cramer-von-Mises)
changeMagnitudes - c(1, 2, 4, 5)
changeLocations - c(50,100,300)
sims - 2000
ARL0 - 500
startup - 20
results - list()
for (cpmType in cpmTypes) {
  results[[cpmType]] - matrix(numeric(length(changeMagnitudes) *
 length(changeLocations)), nrow =
length(changeMagnitudes))
  for (cm in 1:length(changeMagnitudes)) {
for (cl in 1:length(changeLocations)) {
  print(sprintf(cpm:%s magnitude::%s location:%s,
cpmType, changeMagnitudes[cm], changeLocations[cl]))
  temp - numeric(sims)
  for (s in 1:sims) {
x -c(rchisq(changeLocations[cl], df=3), rchisq(2000,

df=changeMagnitudes[cm]))
temp[s] -detectChangePoint(x, cpmType,
ARL0=ARL0,
startup=startup)$detectionTime
  }
  results[[cpmType]][cm,cl] - mean(temp[temp  changeLocations[cl]]) -
changeLocations[cl]
}
  } }

[[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] How to visualize relation between two sets of rel. frequencies?

2012-11-13 Thread Richard M. Heiberger
This is an interesting exercise.  I see at as an application of
a Likert plot.  I would start with this

tmp - data.frame(x = c(0.1,0.6,0.2,0.1),
  y = c(0.5,0.2,0.2,0.1))


tmp$xx - 1
tmp$yy - tmp$x / tmp$y
tmp$xy - tmp$xx * tmp$x
tmp$xxx - tmp$xx - tmp$xy
tmp$yyy - tmp$yy - tmp$xy
tmp

## install.packages(HH)  ## if necessaruy
require(HH)
likert(tmp[, c(xxx,xy,yyy)],
   xlab=scaled to xxx+xy = 1,
   sub=xxx+xy = 1, xy/(xxx+xy) = x, xy/(xy+yyy) = y)


My guess is that this graph would be more meaningful if it were scaled to
counts rather than to xxx + xy = 1.

Rich

On Tue, Nov 13, 2012 at 7:05 AM, Stefan Sobernig
stefan.sober...@wu.ac.atwrote:

 I am looking at a data set containing two variables (x,y), each of which
 represents relative frequencies (rounded):

 data.frame(x = c(0.1,0.6,0.2,0.1), y = c(0.5,0.2,0.2,0.1))

   xy
 1 0.1 0.5
 2 0.6 0.2
 3 0.2 0.2
 4 0.1 0.1

 each of the rows reflects a relation between x and y, for example in row
 4: 10% of the observations in x account for 10% of the observations in y.

 I feel embarrassed, but my mind went blank, and I can't think of a proper
 way of visualizing this relation based on the data above (nor of the
 appropriate terminology to phrase my question other than by example).

 My apologies and thanks for your hints!

 //stefan

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


Re: [R] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread Ista Zahn
Hi Andrew,

You may be able to run the SPSS syntax file using pspp
(http://www.gnu.org/software/pspp/)

Best,
Ista

On Mon, Nov 12, 2012 at 11:23 PM, andrewH ahoer...@rprogress.org wrote:
 Dear folks –
 I have a large (26 gig) ASCII flat file in fixed-width format with about 10
 million observations of roughly 400 variables.  (It is 51 years of Current
 Population Survey micro data from IPUMS, roughly half the fields for each
 record).  The file was produced by automatic process in response to a data
 request of mine.

 The file is not accompanied by a human-readable file giving the fieldnames
 and starting positions for each field.  Instead it comes with three command
 files that describe the file, one each for SAS SPSS, and Stata. I do not
 have ready access to any of these programs.  I understand that these files
 also include the equivalent of the levels attribute for the coded data.  I
 might be able to hand-extract the information I need from the command files,
 but this would involve days of tedious work that I am hoping to avoid.

 I have read through the R Data Import/Export manual 2 and the foreign
 package documentation and I do not see anything that would allow me to
 extract the necessary information from these command files. Does anyone know
 of any r package or other non-proprietary tools that would allow me to get
 this data set from its current form into any of the following formats:
 SAS, SPSS or Stata binary files read by R.
 A MySQL data base
 An ffdf object readable using the ff package.

 My ultimate goal is to get the data into an ffdf object so that I can
 manipulate it in R, perhaps by way of a database. In allocation I will
 probably be using no more than 20 variables at a time, probably a bit under
 a gig. I am working on a machine with three gig of ram.

 (I have seen some suggestions that data.table also provides a
 memory-efficient way of providing database-like functions, but I am unsure
 whether it would let me cope with an object of this size).

 Any help or suggestions anyone could offer would be very much appreciated.

 Warmest regards, andrewH




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Getting-information-encoded-in-a-SAS-SPSS-or-Stata-command-file-into-R-tp4649353.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] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread Anthony Damico
Hi Andrew, to work with the Current Population Survey with R, your best
best is to use a variant of my SAScii package that works with a SQLite
database (and therefore doesn't overload RAM).

I have written obsessively-documented code about how to work with the CPS
in R here..

http://usgsd.blogspot.com/search/label/current%20population%20survey%20%28cps%29

..but example only loads one year of data at a time.  The function
read.SAScii.sqlite() used in that code can be run on a 51 year data set
just the same.

If you need to generate standard errors, confidence intervals, or
variances, I don't recommend using ffdf for complex sample surveys -- in my
experience it doesn't work well with R's survey package.

These scripts use the Census Bureau version of the CPS, but you can make
some slight changes and get it working on IPUMS files too..  Let me know if
you run into any trouble.  :)

Anthony



On Mon, Nov 12, 2012 at 11:23 PM, andrewH ahoer...@rprogress.org wrote:

 Dear folks –
 I have a large (26 gig) ASCII flat file in fixed-width format with about 10
 million observations of roughly 400 variables.  (It is 51 years of Current
 Population Survey micro data from IPUMS, roughly half the fields for each
 record).  The file was produced by automatic process in response to a data
 request of mine.

 The file is not accompanied by a human-readable file giving the fieldnames
 and starting positions for each field.  Instead it comes with three command
 files that describe the file, one each for SAS SPSS, and Stata. I do not
 have ready access to any of these programs.  I understand that these files
 also include the equivalent of the levels attribute for the coded data.  I
 might be able to hand-extract the information I need from the command
 files,
 but this would involve days of tedious work that I am hoping to avoid.

 I have read through the R Data Import/Export manual 2 and the foreign
 package documentation and I do not see anything that would allow me to
 extract the necessary information from these command files. Does anyone
 know
 of any r package or other non-proprietary tools that would allow me to get
 this data set from its current form into any of the following formats:
 SAS, SPSS or Stata binary files read by R.
 A MySQL data base
 An ffdf object readable using the ff package.

 My ultimate goal is to get the data into an ffdf object so that I can
 manipulate it in R, perhaps by way of a database. In allocation I will
 probably be using no more than 20 variables at a time, probably a bit under
 a gig. I am working on a machine with three gig of ram.

 (I have seen some suggestions that data.table also provides a
 memory-efficient way of providing database-like functions, but I am unsure
 whether it would let me cope with an object of this size).

 Any help or suggestions anyone could offer would be very much appreciated.

 Warmest regards, andrewH




 --
 View this message in context:
 http://r.789695.n4.nabble.com/Getting-information-encoded-in-a-SAS-SPSS-or-Stata-command-file-into-R-tp4649353.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Can't remember which package I used. Anyone can help please?

2012-11-13 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of HJ YAN
 Sent: Tuesday, November 13, 2012 12:12 PM
 To: r-help@r-project.org
 Subject: [R] Can't remember which package I used. Anyone can help
 please?
 
 Dear R users
 
  I tried an example earlier to check the results using two different
 methods of clustering with same data set, and for both methods, say
 method A and method B. Also I decided to have same number of
 groups/clusters (here
 8 was chosen).
 
 I found a good graphical tool in R to compare the distribution of the
 number in each group/cluster created by method A and method B, e.g. how
 many of the individuals are clustered as 'Group 1' both by method A and
 B, and how many are clustered as 'Group 2' both by method A and B and
 so on.
 In this case we have 30 and 28 respectively (please see attached table
 and plot).
 
 I lost my code and can not remember which packages/functions I used
 here?
  Could anyone recognize and give me some clue? I only made a note
 'crosstable' if can ring your bell...

If you did not save history of your commands you need to search in clustering 
packages e.g. from CRAN Task View. If you saved history, you could look to 
.Rhistory file.

Regards
Petr

 
 Many thanks in advance
 
 HJ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Extract cell of many values from dataframe cells and sample from them.

2012-11-13 Thread Jean V Adams
Ben,

Yes, lists can be used any time you have unequal row or column size.

Matrices and arrays always have the same number of elements in each 
dimension.

You'd have to provide an example for me to say how the indexing would 
work.

Jean



Benjamin Ward (ENV) b.w...@uea.ac.uk wrote on 11/11/2012 05:16:51 AM:
 
 Hi, 
 
 Thank you for your suggestion, this works a treat.
 
 For my understanding and future reference, this would also work for 
 something like 2D matrices of unequal row size? As far as I 
 understand it would not be possible to make a 3D array jagged like 
 this because the rows would need to be of equal number for the array
 function, yet in a list there is not such requirement, and 
 operations on matrices can target elements in specific matrices by 
[[,]][,] ? 
 
 Best Wishes,
 
 Ben W.
 
 UEA (ENV)  The Sainsbury Laboratory.
 
 From: Jean V Adams [jvad...@usgs.gov]
 Sent: 08 November 2012 19:59
 To: r-help@r-project.org
 Cc: Benjamin Ward (ENV)
 Subject: Re: [R] Extract cell of many values from dataframe cells 
 and sample from them.

 Ben, 
 
 I think you would find lists a helpful way to arrange your data. 
 They do not require equal lengths of data in each element.  Check 
 out the code below for a smaller version of the example you provided
 (with only 5 individuals rather than 500). 
 
 # An alternative way to arrange your data, as a list 
 # Each element of the list is an individual, with all its effector genes 

 ID.unique - formatC(0001:0005, width=4, flag=0) 
 No_of_Effectors - sample(1:550, length(ID.unique), replace=TRUE) 
 Effectors - split(sample(1:1, sum(No_of_Effectors), 
 replace=TRUE), rep(ID.unique, No_of_Effectors)) 
 Effectors 
 
 # Now take a random sample of effectors from each individual 
 Expressed_Genes - lapply(Effectors, function(x) sample(x, sample
 (1:length(x), 1))) 
 Expressed_Genes 
 
 Jean 
 
 
 
 Benjamin Ward (ENV) b.w...@uea.ac.uk wrote on 11/08/2012 10:00:57 
AM:
  
  Hi, 
  
  First my apologies for a non-working piece of code in a previous 
  submission, I have corrected this error. 
  
  I'm doing is individual based modelling of a pathogen and it's host.
  The way I've thought of doing this is with two dataframes, one of 
  the pathogen and it's genes and effector genes, and one of the host 
  and it's resistance genes. During the simulation, these things can 
  be pulled out of the dataframes and operated on, before being stored
  again in the dataframes. 
  
  Below is how I've created my dataframe and stored my effector genes.
  In this model, effector genes are numerical values between 1 and 
1. 
  
  Path_Number - 0500 
  inds - data.frame(ID=formatC
  
 
(0001:Path_Number,width=4,flag=0),No_of_Effectors=,No_Expressed_Effectors=)
  inds$No_of_Effectors - round(as.numeric(lapply(1:nrow
  (inds),function(x) runif(1, min=1, max=550 
  Effectors - lapply(1:nrow(inds),function(x) sample(1:1,inds
  $No_of_Effectors,replace=TRUE)) 
  inds - data.frame(inds,Effectors=as.character(Effectors)) 
  Ind_Genes - strsplit(as.character(inds[1,4]),,) 
  
  What I'm trying to do is: 
  1). For each individual (row) in my database, extract the values in 
  the Effectors cell to an object. 
  2). Sample a number of those values and assign them to a new object 
  called Expressed_Effectors 
  3). Storing it in the Expressed_Effectors cell, in much the same 
  manner as I stored the Effectors object in the Effectors cell. 
  
  My example attempt (for the first row/individual in my dataset) is 
below: 
  
  (step by step, I didn't put this in a loop until I know it works for 1 
row)
  
  Extract the values (effector genes) for the first individual, from 
  the Effectors Cell in the dataframe, to Ind_Effectors object. 
  Ind_Effectors - strsplit(as.character(inds[1,4]),,) 
  
  Randomly dictate how many values (effectors) will be sampled 
  n-round(runif(1, min=10, max=50)) 
  
  Sample n values (effector genes) from Ind_Effectors, not replacing 
  Expressed_Genes - sample(Ind_Effectors,n,replace=F) 
  
  If I run this I receive the error: 
  Error in sample(Ind_Effectors, n, replace = F) : 
cannot take a sample larger than the population when 'replace = 
FALSE' 
  
  What I think this means is rather than picking out n values from the
  whole set of values in Ind_Effectors it's trying to sample the 
  whole lot n times, which it cannot do because replace=F. This is not
  what I need, what I need is n values sampled from Ind_Effectors, 
  not all values from Ind_Effectors sampled n times. 
  
  I hope this clears up the confusion with what I'm trying to do. It 
  may very well be I'm not instructing R to sample as a require 
  properly. Sadly my previous experience with R amounts to loading in 
  dataframes from experiment and doing stat analysis  model fitting, 
  not simulations or individual based models. 
  
  Best wishes, 
  
  Ben W. 
  UEA (ENV)  The Sainsbury Laboratory. 
  
  P.S. As an aside I've been thinking about doing this model 

[R] Tukey test for subgroups in a data frame

2012-11-13 Thread raz
Hello,

I have a data frame with the following columns: date,name,value
the name is the same for each date
I would like to get TukeyHSD p-value for the differences of value between
names in each date separately I tried different ANOVA (aov()) but can
only get either tukey by name or by data but not name by date

any suggestions?

Thanks

-- 
\m/

[[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] Restricted Domain Optimization Problem

2012-11-13 Thread McGehee, Robert
Hello,
I'm hoping for some help implementing a general optimization problem in R. I'd 
like to write a program that for a vector of non-negative input values, x, 
returns a non-negative normalized vector y such that sum(y)==1, and y = maxx 
(vector of maximum values), and for which sum((x-y)^2) is minimized. 
Additionally, I'd like to remove (0,minx) from the domain of each y such that 
any y value may be zero or it may be minx = y = maxx, but it may not be 0  y 
 minx. Thus small, non-zero values are removed.

The last criteria is that the solution must be very fast to compute (e.g. 1/3 
second for vector of 5000).

I coded something up using the L-BFGS-B method of optim where I penalized 
values between (0, minx) with a parabolic cost function. While reasonably fast 
and accurate, I occasionally get the message ERROR: 
ABNORMAL_TERMINATION_IN_LNSRCH. I believe this is because the gradient is 
discontinuous at 'minx', so optim finds the gradient calculation unsatisfactory 
around that value. Not supplying the gradient avoids the error (by using a 
finite-difference model), but is unacceptably slow.

Does anyone have an idea for a more clever way to preform what is effectively a 
simple quadratic programming problem on a discontinuous domain: {0, [minp, 
maxp]}?

Thanks, Robert


Robert McGehee, CFA
Geode Capital Management, LLC
One Post Office Square, 28th Floor | Boston, MA | 02109
Direct: (617)392-8396

This e-mail, and any attachments hereto, are intended fo...{{dropped:10}}

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

2012-11-13 Thread Sonia Amin
Dear friends,
I have written the following lines in R console wich already exist in pdf
file systemfit:
data( GrunfeldGreene )
library( plm )
GGPanel - plm.data( GrunfeldGreene, c( firm, year ) )
greeneSur - systemfit( invest ~ value + capital, method = SUR,
+ data = GGPanel )
greenSur

I have obtained the following incomplete results in wich standard errors of
the estimates and their student statistics didn't appear:
systemfit results
method: SUR

Coefficients:
Chrysler_(Intercept)   Chrysler_value
Chrysler_capital General.Electric_(Intercept)
   0.5043036
0.06954560.3085445  -22.4389132
  General.Electric_value General.Electric_capital
General.Motors_(Intercept) General.Motors_value
   0.03729140.1307830
-162.36410520.1204930
  General.Motors_capital US.Steel_(Intercept)
US.Steel_value US.Steel_capital
   0.3827462
85.42325480.10147820.314
Westinghouse_(Intercept)   Westinghouse_value
Westinghouse_capital
   1.0888770
0.05700910.0415065
but when I wrote the following lines:
summary(greeneSur)

I obtained the following results:
systemfit results
method: SUR

 N DFSSR detRCov   OLS-R2 McElroy-R2
system 100 85 347048 1.39234e+14 0.844042   0.868682

  N DF   SSR   MSE RMSE   R2   Adj R2
Chrysler 20 17   3056.98   179.823  13.4098 0.911862 0.901493
General.Electric 20 17  14009.12   824.066  28.7065 0.687636 0.650887
General.Motors   20 17 144320.88  8489.463  92.1383 0.920742 0.911417
US.Steel 20 17 183763.01 10809.589 103.9692 0.421959 0.353954
Westinghouse 20 17   1898.25   111.662  10.5670 0.726429 0.694244

The covariance matrix of the residuals used for estimation
  Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  176.3203 -25.1478   -332.655   491.857
15.6552
General.Electric  -25.1478 777.4463714.745  1064.649
207.5871
General.Motors   -332.6546 714.7449   8423.875 -2614.188
148.4426
US.Steel  491.85721064.6491  -2614.188 10466.371
642.5712
Westinghouse   15.6552 207.5871148.443   642.571
104.3079

The covariance matrix of the residuals
   Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  179.82262  2.40867   -369.063   535.399
19.6007
General.Electric2.40867824.06559712.161  1440.477
235.6662
General.Motors   -369.06303712.16059   8489.463 -3160.609
152.8077
US.Steel  535.39937   1440.47700  -3160.609 10809.589
767.9016
Westinghouse   19.60073235.66620152.808   767.902
111.6617

The correlations of the residuals
Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  1.   0.00625711  -0.298702  0.384018
0.138324
General.Electric  0.00625711   1.   0.269251  0.482637
0.776898
General.Motors   -0.29870209   0.26925075   1.00 -0.329933
0.156947
US.Steel  0.38401758   0.48263726  -0.329933  1.00
0.698954
Westinghouse  0.13832413   0.77689848   0.156947  0.698954
1.00


SUR estimates for 'Chrysler' (equation 1)
Model Formula: Chrysler_invest ~ Chrysler_value + Chrysler_capital
environment: 0x03ae6cbc

  Estimate Std. Error  t value   Pr(|t|)
(Intercept)  0.5043036 12.4874164  0.04038   0.968257
value0.0695456  0.0183279  3.79452   0.001448 **
capital  0.3085445  0.0280530 10.99864 3.7702e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 13.409796 on 17 degrees of freedom
Number of observations: 20 Degrees of Freedom: 17
SSR: 3056.984521 MSE: 179.822619 Root MSE: 13.409796
Multiple R-Squared: 0.911862 Adjusted R-Squared: 0.901493


SUR estimates for 'General.Electric' (equation 2)
Model Formula: General.Electric_invest ~ General.Electric_value +
General.Electric_capital
environment: 0x03ae6cbc

   Estimate  Std. Error  t value   Pr(|t|)
(Intercept) -22.4389132  27.6787930 -0.81069   0.428748
value 0.0372914   0.0133012  2.80360   0.012212 *
capital   0.1307830   0.0239163  5.46836 4.1636e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 28.706543 on 17 degrees of freedom
Number of observations: 20 Degrees of Freedom: 17
SSR: 14009.115084 MSE: 824.065593 Root MSE: 28.706543
Multiple R-Squared: 0.687636 Adjusted R-Squared: 0.650887


SUR estimates for 'General.Motors' (equation 3)
Model Formula: General.Motors_invest ~ General.Motors_value +
General.Motors_capital
environment: 0x03ae6cbc

Estimate   Std. Error  t value   Pr(|t|)

[R] Polya distribution

2012-11-13 Thread Elahe m
hello
I like to comput median and mean point and intreval estimation by polya
posterior when super population is normal(35,sd=5) with 1000 repeat. 500
and 25 are population size and sample size.
how do i do?
help me please

[[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] Confidence intervals in Ripley's K function - a little challenge...

2012-11-13 Thread AMFTom
I have plotted Ripley's K function for a spatial point pattern for 12 plots,
with 39 Monte Carlo simulations for complete spatial randomness (CSR). 

I would like to analyse these data as follows:

I would like to know for which plots the Ripley's K function deviates from
CSR at a number of confidence intervals, namely 90%, 95% and 99%.

I realise that simulation envelope I have produced is not a confidence
interval. 

Is there a way to plot the different confidence intervals (or confidence
bands) around the data points representing CSR, so I could see where the
observed data significantly deviate from the theoretical CSR at different
levels of confidence?

Alternately, could I plot the different confidence bands around the data
points representing my observed data, and do it this way instead? 

http://r.789695.n4.nabble.com/file/n4649392/Env2.15.png 



--
View this message in context: 
http://r.789695.n4.nabble.com/Confidence-intervals-in-Ripley-s-K-function-a-little-challenge-tp4649392.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] Proc Nnpar1way with D option - equivalent in R

2012-11-13 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of SASandRlearn
 Sent: Tuesday, November 13, 2012 4:26 AM
 To: r-help@r-project.org
 Subject: Re: [R] Proc Nnpar1way with D option - equivalent in R
 
 Dan
 
 Thank you for your reply. I will try what you recommended.
 
 yes.. i have a 1 and 0 as binary.
 
 Here is what i have so far
 d - read.csv(c:/test.csv, header=T)
 dlogit - glm(x ~ a + b + c, data = d, family = binomial)
 attach(d)
 ks.test(x, fitted(values),alternative = c(two.sided),exact = NULL)
 
 I would also like to know how to export the model output from the glm
 into a
 output  dataset with those fitted values and then subset them into the
 1's
 and 0's. That might work as well ?
 
 
 

I am not sure what you mean about exporting the output from glm.  You basically 
already have that in the dlogit object.  Given your code above, you could call 
the ks.test() function like this

ks.test(fitted(dlogit)[d$x==1], fitted(dlogit)[d$x==0], alternative = 
c(two.sided), exact = NULL)

This should produce results consistent with the SAS results.  Whether you 
should do this I can't tell from way over here, because I don't know your data 
nor do I know what you are trying to do.  You may want to seek out a local 
statistical consultant.

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sum of squared loadings after varimax?

2012-11-13 Thread Eric Williams
Is it possible to retrieve sums of squared loadings after applying varimax
rotation?

Here's the setup to my problem:

I ran PCA using prcomp(). I then applied the Kaiser criterion to retain
only the components having eigenvalues = 1. (I know there's debate about
the wisdom of that criterion, but I don't want to get sucked into that.) I
then fed the reduced set of components to varimax() to simplify the
components. (I know there's debate about that as well, but that's also
irrelevant in this case.)

What I'd like to do is obtain the post-rotation sums of squared loadings
(eigenvalues). I know the original eigenvalues can be obtained by squaring
what's reported in the sdev vector, but I'm lost on how to get them after
rotation. I've been searching for hours to no avail. Any ideas?

Thanks :)

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] Issues running sensitivity analysis

2012-11-13 Thread Dave Murray-Rust
Hello list,

I'm trying to carry out a global sensitivity analysis using the sensitivity 
package. I have a model with 26 paramters, mostly normally distributed (with a 
few truncated to not go below 0). I've been trying both the fast99 and 
sobol2007 functions, but having problems with both:

* with fast99, points seem to be generated at the minimum and maximum values a 
distribution can take, which is fine for qunif, but causes problems with qnorm, 
as it generates +-Inf values, which don't work with the model.

* with sobol2007, I've done runs using 2x500 point samples, resulting in 14k 
runs. This gives quite wacky output, with both negative and very high values 
appearing in the first order and total indices (and associatedly large 
confidence intervals).

As far as I can tell, my options are:
* find a way to truncate the distributions for use with fast99
* increase the number of runs with sobol2007

Does anyone have any advice on which of these is more likely to work, or if 
there is an alternative route which would be better?

Thanks!
Dave Murray-Rust
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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

2012-11-13 Thread Flavio Barros
I think that the better solution is to use the transform function. Lets
suppose that your data is in table:

 table - transform(table, n12 = 2400 - n11)

and its done.

On Tue, Nov 13, 2012 at 4:16 AM, arun smartpink...@yahoo.com wrote:

 Hi,
 You can try this:
 dat1-read.table(text=
 Rad:0
 Rad1:2
 Rad3:3
 ,sep=,header=FALSE)



  
 Variable-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=:),`[`,1))
 n11-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=:),function(x)
 as.numeric(x[2])))
  n12-2400-n11
  dat2-data.frame(Variable,n11,n12)
  dat2
 #  Variable n11  n12
 #1  Rad   0 2400
 #2 Rad1   2 2398
 #3 Rad3   3 2397
  str(dat2)
 #'data.frame':3 obs. of  3 variables:
 # $ Variable: Factor w/ 3 levels Rad,Rad1,Rad3: 1 2 3
 # $ n11 : num  0 2 3
 # $ n12 : num  2400 2398 2397

 #or if you want it as a matrix:
  newmat-do.call(rbind,strsplit(as.character(dat1[[1]]),split=:))
  n12-2400-as.numeric(newmat[,2])
  newmat2-cbind(newmat,n12)
 colnames(newmat2)[1:2]-c(Variable,n11)
 A.K.






 - Original Message -
 From: farnoosh sheikhi farnoosh...@yahoo.com
 To: r-help@R-project.org r-help@r-project.org
 Cc:
 Sent: Monday, November 12, 2012 5:52 PM
 Subject: [R] reshape

 Hi,

 I have a R output that looks as follow:
 Rad:0
 Rad1:2
 Rad3:3

 I want to make a new matrix that looks like : sample size is 2400
 Variablen11  n12
 Rad0 2400-0=2400
 Rad1  2   2400-2
 Rad3  3  2400-3

 Thanks a lot for your time and help:)
 Best,Farnoosh Sheikhi
 [[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.




-- 
Att,

Flávio Barros

[[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] plot matrix

2012-11-13 Thread John Kane
Hi,
I didn't see a response for this so here is one way to approach it using the 
reshape2 and ggplo2 packages.

library(reshape2)
library(ggplot2)

dat1-read.table(text=
year   strong  medium healtly
2007   0.606000   0.5101442   0.6226696
2006   1.398500   1.2362115   1.515
2005   2.242083   1.9661923   2.4346957
2004   2.981229   2.6141827   3.2402000
2003   3.403312   3.1088077   3.7789478
2002   4.101750   3.8283269   4.5865130
2001   4.991583   4.8069038   5.6671391
,sep=,header=TRUE,stringsAsFactors=FALSE)
str(dat1)

dat2  -  melt(dat1, id=c(year))

p  -  ggplot(dat2, aes(year, value, colour = variable  )) + geom_line()
p 


John Kane
Kingston ON Canada


 -Original Message-
 From: catalinro...@gmail.com
 Sent: Sun, 11 Nov 2012 13:41:15 +0200
 To: r-help@r-project.org
 Subject: [R] plot matrix
 
 Dear R users,
 I have a problem with plot option in R.
 I want to plot all columns values in a single graph and the labels of x
 axis the row names. I try to use matplot option, but I have a problem
 with
 labels and thickness.  I use a very complex data with 10 columns and 406
 rows.
 I use this code:
 matplot(data.matrix(data1), type=l,xaxt=n)
 axis(1, labels=row.names(data1),at=1:NROW(data1))
 
 A part of my data is like this:
  strong  medium healtly
 2007   0.606000   0.5101442   0.6226696
 2006   1.398500   1.2362115   1.515
 2005   2.242083   1.9661923   2.4346957
 2004   2.981229   2.6141827   3.2402000
 2003   3.403312   3.1088077   3.7789478
 2002   4.101750   3.8283269   4.5865130
 2001   4.991583   4.8069038   5.6671391
 
 Thank you very much!
 
 
 
 
 --
 ---
 Catalin-Constantin ROIBU
 Forestry engineer, PhD
 Forestry Faculty of Suceava
 Str. Universitatii no. 13, Suceava, 720229, Romania
 office phone +4 0230 52 29 78, ext. 531
 mobile phone   +4 0745 53 18 01
+4 0766 71 76 58
 FAX:+4 0230 52 16 64
 silvic.usv.ro
 
   [[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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Invalid 'times' argument three-category ordered probit with maximum likelihood

2012-11-13 Thread David Winsemius

On Nov 12, 2012, at 2:16 PM, jackle1o4 wrote:

 Hello,
 First time poster here so let me know if you need any more information. I am
 trying to run an ordered probit with maximum likelihood model in R with a
 very simple model (model - econ3 ~ partyid). Everything looks ok until i
 try to run the optim() command and that's when I get  Error in rep(1,
 nrow(x)) : invalid 'times' argument. I had to adapt the code from a 4
 category likelihood and I have a suspicion that the problem is in there. The
 data set consists of two variables with 558 observations. Econ3 is a 1-3
 rating and partyid is a range from -3(Strong Democrat) to 3 (Strong
 Republican). Here is the code I used:
 
 setwd(C:/Users/Terry/Desktop/Terry/School/Fall 2012/ML/HW)
 
 #Load Libraries
 library(MASS)
 library(tile)
 library(simcf)
 
 #Load Data
 econrate - read.csv(hw4econ3.csv, header=TRUE, sep=,)

It's somewhat unusual to see a posting with an effort at posting code go 
uncommented for 18 hours, but in your case I suspect it is because people got 
to this point an were noticing the sprong resemblance to a homework assignment, 
which is discouraged on Rhelp. Speaking of a different sort of likelihood ... 
Help with assignments are not completely refused, but the chances of getting a 
reply would increase if you had indicated what academic institution you were 
studying at and what their policies are for soliciting help with academic 
assignments. Further increases in the likelihood of a response would occur if 
the h4econ3.csv file were made available at an URL or attached as a text file 
or included in the body of the message using the dput function.


 attach(econrate)

Generally a bad idea to attach() data objects, and that is especially so when 
you have not described the structure of the dataframe.
 
 #Ordered Probit Liklihood
 llk.oprobit3 - function(param, x, y) {
 os - rep(1, nrow(x))
  x - cbind(os, x)  
  b - param[1:ncol(x)]
  t2 - param[(ncol(x)+1)]
 xb - x%*%b
  p1 - log(pnorm(-xb))
  if (t2=0)  p2 - -(abs(t2)*1)
 else p2 - log(pnorm(t2-xb)-pnorm(-xb))  
  p3 - log(1-pnorm(t2-xb))
 -sum(cbind(y==1,y==2,y==3) * cbind(p1,p2,p3))
 }
 
 #Define Data
 y - econ3
 x - partyid
 model - (econ3 ~ partyid)
 
 #Use optim directly
 ls.result - lm(y~x)
 stval - c(ls.result$coefficients, 1)
 oprobit.result - optim(stval, llk.oprobit3, method=BFGS, x=x, y=y,
 hessian=T) ###Here is where it all breaks down
 pe - oprobit.result$par
 vc - solve(oprobit.result$hessian)
 se - sqrt(diag(vc)) 
 ll - -oprobit.result$value  
 
 Any help would be greatly appreciated. Thanks.
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Invalid-times-argument-three-category-ordered-probit-with-maximum-likelihood-tp4649341.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, 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.


Re: [R] order in stacked barplot

2012-11-13 Thread John Kane
Could be few things but we probably need some sample data to get a feeling for 
what you are doing.

 The easiest way to supply data  is to use the dput() function.  Example with 
your file named testfile: 
dput(testfile) 
Then copy the output and paste into your email.  For large data sets, you can 
just supply a representative sample.  Usually, 
dput(head(testfile, 100)) will be sufficient.   



John Kane
Kingston ON Canada


 -Original Message-
 From: kay.lue...@uni-rostock.de
 Sent: Mon, 12 Nov 2012 09:01:40 -0800 (PST)
 To: r-help@r-project.org
 Subject: [R] order in stacked barplot
 
 Hello
 i did a stacked barplot using ggplot and R arranged the bars of the items
 in
 different orders. i don´t know why. but i want to have the same order in
 every stacked bar.
 
 I used the code
 
 data1 - read.table(N_O_W_MAI.txt, header=TRUE, dec = ,)
 attach(data1)
 Teich1-factor(Teich,levels=c(5,7,9,11,G) ,ordered=is.ordered(Teich))
 Gruppe1-factor(Gruppe,levels=c(Annelida,Cladocera,Copepoda,
 Diptera,Ephemeroptera,Ostracoda,Sonstige),ordered=is.ordered(Gruppe))
 data2-data.frame(Teich1,Gruppe,Herkunft,IRI)
 data2
 str(data2)
 'data.frame':   65 obs. of  3 variables:
  $ Teich1: Factor w/ 5 levels 2,4,8,10,..: 1 1 1 1 1 1 1 1 1 1
 ...
  $ Gruppe1: Factor w/ 7 levels Annelida,Asellus,..: 1 2 3 4 5 6 7 1 2
 3
 ...
  $ IRI   : num  0.606 16.274 0.326 0.396 0 ...
 attach(data2)
 #?data.frame
 str(data2)
  library(ggplot2)
 
 ggplot(data2, aes(Teich1,IRI, fill=Gruppe1)) +
  geom_bar(stat=summary, fun.y=sum) +
   facet_grid(~Herkunft)
 
 So i get a plot with stacked bars for every Teich1(Pond), the stacks
 show
 the summed proportion (IRI) of the diffrent species (Gruppe1) in
 every
 pond.  Every species has a discret colour, but the order of species is
 displayed different for the ponds. In the original data they have the
 same
 order for every pond. This is what i want to have for the stacked
 barplot,
 too.
 Has anybody an idea?
 thanks
 Kay
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/order-in-stacked-barplot-tp4649321.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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tukey test for subgroups in a data frame

2012-11-13 Thread arun
HI,
Try this:
dat1-read.table(text=
  date name  value
  10/5/2008  L 26
  10/5/2008  L 30
  10/5/2008  L 54
  10/5/2008  L 25
  10/5/2008 M 18
  10/5/2008 M 21
  10/5/2008 M 29
  10/5/2008 M 17
  11/5/2008  L 32
  11/5/2008  L 35
  11/5/2008  L 44
  11/5/2008  L 28
  11/5/2008 M 19
  11/5/2008 M 22
  11/5/2008 M 18
  11/5/2008 M 16
  12/5/2008  L 24
  12/5/2008  L 33
  12/5/2008  L 35
  12/5/2008  L 28
  12/5/2008 M 29
  12/5/2008 M 23
  12/5/2008 M 39
  12/5/2008 M 42
  ,sep=,header=TRUE,stringsAsFactors=FALSE)
 dat1$date-as.Date(dat1$date,format=%m/%d/%Y)
dat1-within(dat1,{name-factor(name)})
res- lapply(split(dat1,dat1$date),function(x) 
TukeyHSD(aov(value~name,data=x),name,ordered=TRUE))
 res
#$`2008-10-05`
 # Tukey multiple comparisons of means
  #  95% family-wise confidence level
   # factor levels have been ordered

#Fit: aov(formula = value ~ name, data = x)

#$name
  #  diff   lwr  upr p adj
#L-M 12.5 -5.501854 30.50185 0.1402197


#$`2008-11-05`
 # Tukey multiple comparisons of means
  #  95% family-wise confidence level
   # factor levels have been ordered

#Fit: aov(formula = value ~ name, data = x)

#$name
 #   diff lwr  upr p adj
#L-M   16 7.13522 24.86478 0.0044882



A.K.

- Original Message -
From: raz barvazd...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, November 13, 2012 11:27 AM
Subject: [R] Tukey test for subgroups in a data frame

Hello,

I have a data frame with the following columns: date,name,value
the name is the same for each date
I would like to get TukeyHSD p-value for the differences of value between
names in each date separately I tried different ANOVA (aov()) but can
only get either tukey by name or by data but not name by date

any suggestions?

Thanks

-- 
\m/

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

2012-11-13 Thread David Winsemius

On Nov 12, 2012, at 10:16 PM, arun wrote:

 Hi,
 You can try this:
 dat1-read.table(text=
 Rad:0
 Rad1:2
 Rad3:3
 ,sep=,header=FALSE)
 
 
  
 Variable-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=:),`[`,1))
 n11-do.call(rbind,lapply(strsplit(as.character(dat1[[1]]),split=:),function(x)
  as.numeric(x[2])))

That seems unnecessarily complicated:

 dat - read.table(text=Rad:0
 Rad1:2
 Rad3:3, sep=:)

 names(dat) - c('Variable','n11')
 dat$n2 - 2400- dat$n1

 dat
#-#
  Variable n11   n2
1  Rad   0 2400
2 Rad1   2 2398
3 Rad3   3 2397

  n12-2400-n11
  dat2-data.frame(Variable,n11,n12)
  dat2
 #  Variable n11  n12
 #1  Rad   0 2400
 #2 Rad1   2 2398
 #3 Rad3   3 2397
  str(dat2)
 #'data.frame':3 obs. of  3 variables:
 # $ Variable: Factor w/ 3 levels Rad,Rad1,Rad3: 1 2 3
 # $ n11 : num  0 2 3
 # $ n12 : num  2400 2398 2397
 
 #or if you want it as a matrix:
  newmat-do.call(rbind,strsplit(as.character(dat1[[1]]),split=:))
  n12-2400-as.numeric(newmat[,2])
  newmat2-cbind(newmat,n12)
 colnames(newmat2)[1:2]-c(Variable,n11)
 A.K.
 
 
 - Original Message -
 From: farnoosh sheikhi farnoosh...@yahoo.com
 To: r-help@R-project.org r-help@r-project.org
 Cc: 
 Sent: Monday, November 12, 2012 5:52 PM
 Subject: [R] reshape
 
 Hi,
 
 I have a R output that looks as follow:
 Rad:0
 Rad1:2
 Rad3:3
 
 I want to make a new matrix that looks like : sample size is 2400
 Variablen11  n12
 Rad0 2400-0=2400
 Rad1  2   2400-2
 Rad3  3  2400-3
  
 Thanks a lot for your time and help:)
 Best,Farnoosh Sheikhi


Alameda, CA, 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] GAM model to reduce PACF of a model

2012-11-13 Thread PavloEs
I have asked this question on Stackoverflow and was told it does not relate
to the sites' mission as it is statistical question, thus I brought it here.  
I am fitting a gam mode in the mgcv package to study associations of
environmental pollutants and mortality. The aim is to choose a model with
lowest mgcv  and also to reduce the PACF to less than   |0.1|.

library(gamair) 
library(mgcv) 
data(chicago) 

y-matrix(0,12,5)
for (i in 1:12) {
testdf-gam(death ~ pm10median  + o3median + s(time,k=i*14,fx=T) +
s(tmpd,bs=cr), data=chicago,family=poisson)
  y[i,1]-i  
  y[i,2]-summary(testdf)$p.coeff[2]  
  ll-summary(testdf)$p.coeff[2]-1.96*summary(testdf)$se[2]  
  ul-summary(testdf)$p.coeff[2]+1.96*summary(testdf)$se[2] 
  y[i,3]-ll
  y[i,4]-ul  
  y[i,5]-(testdf)$gcv.ubre
   
}
y

pacf(residuals(testdf),lag.max=90)

The partial autocorrelation of the model residuals at lag 0 and some
subsequent lags is large, thus I want to include autoregressive models to
remove this correlation. 

In environmental epidemiology there  are some suggestions on how to choose
the best fit of a model based (one example is - Model Choice in Time Series
Studies of Air Pollution and Mortality, Peng et al.
http://biostats.bepress.com/cgi/viewcontent.cgi?article=1055context=jhubiostat;
)
1)  use fixed degree of freedom based on literature
2)  Chose df that reduces AIC, BIC 
3)  Choose df that best predicts the pollution series or outcome series
4)  Minimum residual autocorrelation (PACF)- some suggest to reduce the
absolute value of PACF to  1. 
I will follow existing literature in choosing the df of my model, but would
also like to use data driven model choice as a sensitivity analysis.   I
would appreciate any suggestion on how to improve this model,  and above
all,  how to fit a model that would reduce the absolute value of PACF to 
0.1. 

Thanks




--
View this message in context: 
http://r.789695.n4.nabble.com/GAM-model-to-reduce-PACF-of-a-model-tp4649397.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] RODBC and ORACLE

2012-11-13 Thread mmgm
Follow up. 

After lots of hours around this i got a fix:

1) Deinstalled Java
2) Downloaded the R Source
3) Configured . oraenv 
4) Made sure the libsqora.so.11.1 was on the LD_LIBRARY_PATH
5) compiled from the source with the standard ./configure and make make
install

After this RODBC started working again. I used the old libraries so this
must have something to do with how R is compiled.

Still i am able to replicate the problem again. If i reinstall JAVA (any
version of sdk_1.6.0 - sun and otherwise) an then run 

alternatives --config java  (select the proper)

And then R CMD jreconf

Then its all over again. RODBC starts complaining about links and quits with
segmentation fault. 

I would like to know how to get past this, but at least now i can use RODBC
with oracle again. 

If anyone has any  ideas i would really love to hear them.

Thanks,
Miguel



--
View this message in context: 
http://r.789695.n4.nabble.com/RODBC-and-ORACLE-tp4649352p4649403.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] Using apply instead of for loop / multithreading

2012-11-13 Thread Flavio Barros
That worked better because of vectorization, but isn't multithreaded.

To have this resource look at plyr package.

On Mon, Nov 12, 2012 at 9:08 PM, Charles D. charlybeg...@live.fr wrote:

 it works really faster !
 thank you



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Using-apply-instead-of-for-loop-multithreading-tp4649326p4649346.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.




-- 
Att,

Flávio Barros

[[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] Can't remember which package I used. Anyone can help please?

2012-11-13 Thread David Winsemius

On Nov 13, 2012, at 3:12 AM, HJ YAN wrote:

 Dear R users
 
 I tried an example earlier to check the results using two different
 methods of clustering with same data set, and for both methods, say method
 A and method B. Also I decided to have same number of groups/clusters (here
 8 was chosen).
 
 I found a good graphical tool in R to compare the distribution of the
 number in each group/cluster created by method A and method B, e.g. how
 many of the individuals are clustered as 'Group 1' both by method A and B,
 and how many are clustered as 'Group 2' both by method A and B and so on.
 In this case we have 30 and 28 respectively (please see attached table and
 plot).
 
 I lost my code and can not remember which packages/functions I used here?
 Could anyone recognize and give me some clue? I only made a note
 'crosstable' if can ring your bell...

If you want to find all package that have a function spelled crosstable do 
this:

install.packages(sos)
require(sos)
findFn(crosstable)

If you wnat to see a large list of packages that do classification then do this:

Search Google with terms: R Cran task views classification

-- 
David Winsemius, MD
Alameda, CA, 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.


Re: [R] Matrix package will not loead

2012-11-13 Thread Prof Brian Ripley

On 13/11/2012 13:28, Uzuner, Tolga I wrote:

Many thanks for your advice and assistance.

Sadly, I am unable to install from source as my operating environment does 
not have Rtools or a compiler.

Is there an old version compiled somewhere I can use ?


Yes, in your 2.15.1 installation.  Since you seem to be installing into 
a personal library, I expect that if you delete Matrix from 
H:/R/win-library/2.15 you will get the originally installed one in .Library.


And if you updated .Library, simply re-install R 2.15.1.

However, the posting guide asked you to update before posting, and that 
is the nature of the Open Source contract: help which is available is 
only for the current version since that is always freely available.  If 
you want to use binary packages, we only supply those for current and 
future versions of R, and at CRAN's discretion for the final member of 
the last series (currently 2.14.2).







install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL, 
type=source)

Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
* installing *source* package 'Matrix' ...
** package 'Matrix' successfully unpacked and MD5 sums checked
** libs
ERROR: compilation failed for package 'Matrix'
* removing 'H:/R/win-library/2.15/Matrix'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-215~1.1/bin/i386/R CMD INSTALL -l 
H:/R/win-library/2.15   H:/Downloads/Matrix_1.0-10.tar.gz' had status 1
2: In install.packages(H:\\Downloads\\Matrix_1.0-10.tar.gz, repos = NULL,  :
   installation of package 'H:/Downloads/Matrix_1.0-10.tar.gz' had non-zero 
exit status

install.packages(Matrix, type=source)

Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
Error in download.file(url, destfile, method, mode = wb, ...) :
   cannot open URL 
'http://cran.ma.imperial.ac.uk/src/contrib/Matrix_1.0-9.tar.gz'
In addition: Warning message:
In download.file(url, destfile, method, mode = wb, ...) :
   cannot open: HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :


-Original Message-
From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
Sent: 13 November 2012 13:03
To: Duncan Murdoch
Cc: Uzuner, Tolga I; r-help@r-project.org
Subject: Re: [R] Matrix package will not loead

You will find the problem and solution in the list archives.

The current version of Matrix can be installed *from source* on R (=
2.15.0), as it claims.  But if you install it on R = 2.15.2 then it
uses features of 2.15.2 and hence can only be run on R = 2.15.2. And
there was a warning about this 

On 13/11/2012 12:38, Duncan Murdoch wrote:

On 12-11-13 7:06 AM, Uzuner, Tolga I wrote:

Dear Fellow R Users,

I am having a problem with the Matrix package, in Windows XP on  R
2.15.1 .

This is the only package where I experience this. I remove the package
first, re install, and then when trying to load, get a LoadLibrary
failure as below.


I've just installed a binary copy of Matrix 1.0-10 in R 2.15.2 patched,
and I get an error too on attaching it:  The procedure entry point
Rf_copyListMatrix could not be located in the dynamic link library
R.dll.  I'm pretty sure that procedure is available in R.dll currently,
so I don't know what the real problem is.


The issue is if it is exported from R.dll, which only happened just
before 2.15.2.  Works for me with the Matrix binary package on the CRAN
master and both 2.15.2 and the current R-patched (which in any case
contains that version).



I have just rebuilt R, and the same package works fine.  So I'd suggest
that you download the latest R-patched from CRAN, and hopefully things
will be fine.

Duncan Murdoch




Thanks in advance for any assistance.

Regards,
Tolga



remove.packages(Matrix)

Removing package(s) from 'H:/R/win-library/2.15'
(as 'lib' is unspecified)

install.packages(Matrix)

Installing package(s) into 'H:/R/win-library/2.15'
(as 'lib' is unspecified)
trying URL
'http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15/Matrix_1.0-10.zip'

Content type 'application/zip' length 3289545 bytes (3.1 Mb)
opened URL
downloaded 3.1 Mb

package 'Matrix' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
  C:\Data\N048564\temp\RtmpoDC7HF\downloaded_packages

library(Matrix)

Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
'H:/R/win-library/2.15/Matrix/libs/i386/Matrix.dll':
LoadLibrary failure:  The specified procedure could not be found.

In addition: Warning message:
package 'Matrix' was built under R version 2.15.2
Error: package/namespace load failed for 'Matrix'






This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, 

[R] Using lubridate to increment date by business days only

2012-11-13 Thread ramoss
Hello,

I know how to increment a date by calendar date:

ticker$ldate - ticker$tdate + days(5)

How do I increment it by business days only so that week-ends are not
counted?

So for example friday november 2 + 5days becomes friday november 9  not
wednesday nov 7.

Thanks for your help.



--
View this message in context: 
http://r.789695.n4.nabble.com/Using-lubridate-to-increment-date-by-business-days-only-tp4649414.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] Comparing goodness of fit between two logistic regression models

2012-11-13 Thread hoguejm
Greetings, 

I want to compare the goodness-of-fit between several different models that
I have developed using Logistic Regression.  I have been doing some research
and am sort of confused on how to do this.  I know it is not as simple as in
an OLS model, however since there is no R-squared value in logistic
regression, I was wondering if there was another test statistic I could use. 
I do not want to compare the fitted models with the null model, but rather
two different fitted models.

I know there are several pseudo R-squares that can be used. (Is there  a
recommended one? Is this even a good way to compare models?)

I apologize that this is more of a statistics question than an r specific
question, but any advice would be greatly appreciated. 

Thanks, 

Jake 



--
View this message in context: 
http://r.789695.n4.nabble.com/Comparing-goodness-of-fit-between-two-logistic-regression-models-tp4649410.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] for loop

2012-11-13 Thread farnoosh sheikhi
thanks dear. method 2 worked very fast since my data is very big.
Thanks a lot. :-)
 
Best,Farnoosh Sheikhi





Cc: R help r-help@r-project.org 
Sent: Monday, November 12, 2012 6:15 PM
Subject: Re: for loop

HI,
You can do this in many ways:
dat1-read.table(text=
med1,med2,med3 
 1,0,1   
0,1,1    
2,0,0 
,sep=,,header=TRUE)   
#1st method
library(reshape)

dat2-melt(dat1)
dat3-aggregate(dat2$value,by=list(dat2$variable),sum)
 colnames(dat3)-c(name,sum(n11))
 dat3
#  name sum(n11)
#1 med1    3
#2 med2    1
#3 med3    2


#2nd method
res-data.frame(colSums(dat1)) 
 names(res)-sum(n11)
 res
# sum(n11)
#med1    3
#med2    1
#med3    2


#3rd method
 do.call(rbind,lapply(dat1,sum))
# [,1]
#med1    3
#med2    1
#med3    2

A.K.







Sent: Monday, November 12, 2012 7:24 PM
Subject: for loop


Hi there,

I want to calculate the odds ratio for a data like below.
 I want to compute the sum of each column as a new column and variable names as 
a new column.
I have about 1000 variables and I think I need to write a loop.

med1    med2    med3     
 1              01       
011
200       


The final data will look like:
name        sum(n11)
med1         3
med2          1
med3          2


Thanks a lot :-).
Best,Farnoosh Sheikhi
[[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 + Hadoop on Amazon

2012-11-13 Thread Jamie Olson
The RHadoop wiki describes the dependencies that you need to have in order
to install RHadoop.  The only tricky thing is, as mentioned, the JAVA_HOME
environmental variable.  Other than that, just follow their instructions.
 I'm actually using the ElasticMapreduce tool to setup the cluster along
with some custom bootstrap sh scripts to install the necessary packages.


Jamie Olson



On Thu, Nov 8, 2012 at 3:01 AM, Vignesh Prajapati vign...@tatvic.comwrote:

 Hey Jamie,

   Thanks for your comment. I am able to install R , Rstudio and Hadoop on
 Amazon instance with Ubuntu os. But cant able to install   the RHadoop.
 So, can you provide me such links which can help? And which AMI image you
 are using?


 Thanks
 Vignesh


 On Wed, Nov 7, 2012 at 11:24 PM, Jamie Olson inspired2apa...@gmail.comwrote:

 I've been using Amazon Elastic Mapreduce combined with RHadoop with great
 success.  The only real problem is that the default JAVA_HOME doesn't
 points to a jdk that works with rJava, so you have to correct it.  I've
 been meaning to do a writeup on it and will update you once it's up.

 Jamie Olson


 On Wed, Nov 7, 2012 at 5:32 AM, Vignesh Prajapati vign...@tatvic.comwrote:

 Hello All,

  Having some issue with local machine, I need to locate myself on Amazon
 for running R and Hadoop with Amazon instance. After searching a lot, I
 can't able to take a decision for choosing Image for Amazon instance.
 Can any
 one using R + Hadoop on Amazon.

 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.





[[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] Is function(x){x}(5) a valid expression?

2012-11-13 Thread Jamie Olson
I was surprised to notice that statements like:

h = function(...){list(...)}(x=4)

do not throw syntax errors.  R claims that 'h' is now a function, but I
can't seem to call it.

 h = function(x){list(x)}(4)
 is(h)
[1] function OptionalFunction PossibleMethod
 h()
Error in list(x) : 'x' is missing
 h(4)
Error in h(4) : attempt to apply non-function


What's going on?

Jamie Olson

[[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] save/load and package namespaces

2012-11-13 Thread Jamie Olson
Correct me if I'm wrong, but it also seems that more generally, everything
works as long as the environment is 'below' .GlobalEnv.  For example,

x = function(){
   y = 4
   function()y
}
yfun = x()
save(yfun,file = yfun.RData)

load(yfun.RData)
yfun()

This works fine even when there are more inherited environments.  I imagine
this is because in saving yfun, it also saves the environment and any
parent environments until some point?  Is it checking to see if the
environment inherits from .GlobalEnv or something like that?

Jamie Olson



On Wed, Nov 7, 2012 at 7:57 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 12-11-07 6:20 PM, Jamie Olson wrote:

 Thank you!  This explains the error thrown by getNamespace() for the
 missing package.

 So I imagine this will happen for any function's environment?  Do you
 know if this should happen for S3 objects or just S4?


 It should only happen for objects that have an environment associated with
 them.  Functions do, S4 objects do, formulas do, but S3 objects don't
 (unless they happen to contain something that does).

 If the environment is globalenv() (the user environment), it's no big
 deal.  It's only when a package namespace is there (as with functions
 exported from a package) that you create the dependency.

 Duncan Murdoch



 Jamie Olson



 On Wed, Nov 7, 2012 at 4:10 PM, Duncan Murdoch murdoch.dun...@gmail.com
 mailto:murdoch.duncan@gmail.**com murdoch.dun...@gmail.com wrote:

 On 07/11/2012 12:50 PM, Jamie Olson wrote:

 Could someone explain to me what namespaces are loaded/saved
 when objects
 are saved?


 None are loaded or saved when you save the object, but the names of
 some are saved.  For example,

 library(Hmisc)  # not normally loaded/attached
 x - zoom # copy a function from Hmisc
 save(x, file=x.RData)

 This will save a copy of a function from Hmisc to the file, but the
 function's environment is the Hmisc namespace.  To properly load
 that function via

 load(x.RData)

 R will load the referenced namespace.  You will see it appear in
 loadedNamespaces() after the load (assuming you still have Hmisc
 available).

 I believe this will also happen if you try to load an S4 object;
 you'll need to be able to load the namespace of its class.

 Duncan Murdoch



 Specifically, I'm using this:
save(list = ls(all.names = TRUE, envir = envir), file = name,
 envir =
 envir)
 to save out everything from an environment.

 Later, loading it on another machine, I'm surprised to see the
 load failing
 for being unable to load certain packages.  Could anyone help me
 understand
 why this happens?
 Jamie Olson

  [[alternative HTML version deleted]]

 __**__
 R-help@r-project.org mailto:R-help@r-project.org mailing list
 
 https://stat.ethz.ch/mailman/_**_listinfo/r-helphttps://stat.ethz.ch/mailman/__listinfo/r-help

 
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://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

 
 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.


[R] How to permanently change console colours in R

2012-11-13 Thread vinay_ragas
Hello. 

I am new to R and I like it very much... I am learning to use it day-by-day.
I have a query which might be a novice level for you. I want to know how to
change the background and text colours in the R console. Doing google
searches, I found to go to preferences in Edit and to change them. All I
could do is to change the colours and then save them as a format and on each
usage, I have to load those setup using the saved file. 

I want to change this once for all. And am crazy about the MATRIX themes, so
I would like to have the black as background and green2 as the text file.
Please help me in this. 

And by the way, I use Windows 7, and installed R 2.13.0 version. 


Regards, 
Vinay



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-permanently-change-console-colours-in-R-tp4649413.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to visualize relation between two sets of rel. frequencies?

2012-11-13 Thread Stefan Sobernig

Rich,

 I see at as an application of

a Likert plot.  I would start with this


Indeed, I went with an HH likert() for now. I am not so sure about the 
scaling, though. So for now, I stick with counts ... but I will revisit 
that with a fresh mind tomorrow.


Many thanks for your suggestion!

//stefan

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


Re: [R] Using lubridate to increment date by business days only

2012-11-13 Thread Sarah Goslee
Does this help at all:
http://stackoverflow.com/questions/7595533/generating-a-time-series-with-a-specific-start-and-end-date

Sarah

On Tue, Nov 13, 2012 at 1:49 PM, ramoss ramine.mossad...@finra.org wrote:
 Hello,

 I know how to increment a date by calendar date:

 ticker$ldate - ticker$tdate + days(5)

 How do I increment it by business days only so that week-ends are not
 counted?

 So for example friday november 2 + 5days becomes friday november 9  not
 wednesday nov 7.

 Thanks for your help.


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

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


Re: [R] save/load and package namespaces

2012-11-13 Thread Duncan Murdoch

On 13/11/2012 1:45 PM, Jamie Olson wrote:
Correct me if I'm wrong, but it also seems that more generally, 
everything works as long as the environment is 'below' .GlobalEnv. 
 For example,


x = function(){
   y = 4
   function()y
}
yfun = x()
save(yfun,file = yfun.RData)

load(yfun.RData)
yfun()

This works fine even when there are more inherited environments.  I 
imagine this is because in saving yfun, it also saves the environment 
and any parent environments until some point?  Is it checking to see 
if the environment inherits from .GlobalEnv or something like that?


The source is here: 
https://svn.r-project.org/R/trunk/src/main/serialize.c.  It's not the 
simplest code, but if you look, you can see that the empty, base and 
global environments are handled specially (by just writing a marker, not 
their contents).  Package and namespace environments are handled by 
writing out a string describing them.  Other environments are saved by 
saving their parent, their content, their hash table, and their attributes.


So yfun would be saved, along with its environment, but the parent of 
that environment is globalenv(), so just the marker is saved.


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] Is function(x){x}(5) a valid expression?

2012-11-13 Thread William Dunlap
The syntax
expression(arg)
means to call the value of 'expression' as a function with argument 'arg'.
Hence you can do things like
   { function(x)x^2 } (11:13) # gives 121, 144, 169
or, weirder,
   eval(call(function, pairlist(x=NULL, base=2), quote(log(x,base (512) # 
gives 9

If 'expression' is not a function you get an error of the sort you saw, similar
to what you would get if you did
   x - 1:10
   x(17)
The parser doesn't know if 'expression' will evaluate to a function or not
so it accepts it and you get the error at run time.

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 Jamie Olson
 Sent: Tuesday, November 13, 2012 10:33 AM
 To: r-help@r-project. org
 Subject: [R] Is function(x){x}(5) a valid expression?
 
 I was surprised to notice that statements like:
 
 h = function(...){list(...)}(x=4)
 
 do not throw syntax errors.  R claims that 'h' is now a function, but I
 can't seem to call it.
 
  h = function(x){list(x)}(4)
  is(h)
 [1] function OptionalFunction PossibleMethod
  h()
 Error in list(x) : 'x' is missing
  h(4)
 Error in h(4) : attempt to apply non-function
 
 
 What's going on?
 
 Jamie Olson
 
   [[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] Is function(x){x}(5) a valid expression?

2012-11-13 Thread Duncan Murdoch

On 13/11/2012 1:33 PM, Jamie Olson wrote:

I was surprised to notice that statements like:

h = function(...){list(...)}(x=4)

do not throw syntax errors.  R claims that 'h' is now a function, but I
can't seem to call it.

 h = function(x){list(x)}(4)
 is(h)
[1] function OptionalFunction PossibleMethod
 h()
Error in list(x) : 'x' is missing
 h(4)
Error in h(4) : attempt to apply non-function


What's going on?


The body of your function is

{list(x)}(4)

The problem is,

{list(x)}

does not return a function, so you can't call it with the argument 4.  
If you had


h - function(x) { function(y) y }(4)

it would return 4 every time, because the anonymous function does that.

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] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread David Winsemius

On Nov 13, 2012, at 7:20 AM, Anthony Damico wrote:

 Hi Andrew, to work with the Current Population Survey with R, your best
 best is to use a variant of my SAScii package that works with a SQLite
 database (and therefore doesn't overload RAM).
 
 I have written obsessively-documented code about how to work with the CPS
 in R here..
 
 http://usgsd.blogspot.com/search/label/current%20population%20survey%20%28cps%29
 
 ..but example only loads one year of data at a time.  The function
 read.SAScii.sqlite() used in that code can be run on a 51 year data set
 just the same.
 
 If you need to generate standard errors, confidence intervals, or
 variances, I don't recommend using ffdf for complex sample surveys -- in my
 experience it doesn't work well with R's survey package.
 
 These scripts use the Census Bureau version of the CPS, but you can make
 some slight changes and get it working on IPUMS files too..  Let me know if
 you run into any trouble.  :)

I'd like to take this opportunity to thank Anthony for his work on this dataset 
as well as on several others. The ones I am most interested in are the 
NHANES-III and Continuous NHANES datasets and he has the 2009-2010 set from the 
Continuous NHANES series represented in his examples. Scraping the list of 
datasets from his website:

available data

• area resource file (arf) (1)
• consumer expenditure survey (ce) (1)
• current population survey (cps) (1)
• general social survey (gss) (1)
• national health and nutrition examination survey (nhanes) (1)
• national health interview survey (nhis) (1)
• national study of drug use and health (nsduh) (1)

And thanks to you for this question, andrewH; 

... it prompted a response from Jan to a package by Jan van der Laan which had 
subsequent links (via a reverseDepends citation) to a SEERabomb package by 
Tomas Radivoyevitch that provides examples of handling the SEER datasets, at 
least the Hematologic tumors dataset. My experience with SEER data in the past 
has been entirely mediated through SEER*Stat which is (somewhat) user-friendly 
Windows package for working with the SEER fixed field formats, but it should be 
exciting to see another accessible avenue through R.

Thanks, Anthony, Jan, and andrewH, and further thanks to Thomas Lumley on whose 
work I believe Anthony's package Depends because of the need for proper 
handling of the sampling weights.

-- 
David Winsemius
 
 Anthony
 
 
 
 On Mon, Nov 12, 2012 at 11:23 PM, andrewH ahoer...@rprogress.org wrote:
 
 Dear folks ˆ
 I have a large (26 gig) ASCII flat file in fixed-width format with about 10
 million observations of roughly 400 variables.  (It is 51 years of Current
 Population Survey micro data from IPUMS, roughly half the fields for each
 record).  The file was produced by automatic process in response to a data
 request of mine.
 
 The file is not accompanied by a human-readable file giving the fieldnames
 and starting positions for each field.  Instead it comes with three command
 files that describe the file, one each for SAS SPSS, and Stata. I do not
 have ready access to any of these programs.  I understand that these files
 also include the equivalent of the levels attribute for the coded data.  I
 might be able to hand-extract the information I need from the command
 files,
 but this would involve days of tedious work that I am hoping to avoid.
 
 I have read through the R Data Import/Export manual 2 and the foreign
 package documentation and I do not see anything that would allow me to
 extract the necessary information from these command files. Does anyone
 know
 of any r package or other non-proprietary tools that would allow me to get
 this data set from its current form into any of the following formats:
 SAS, SPSS or Stata binary files read by R.
 A MySQL data base
 An ffdf object readable using the ff package.
 
 My ultimate goal is to get the data into an ffdf object so that I can
 manipulate it in R, perhaps by way of a database. In allocation I will
 probably be using no more than 20 variables at a time, probably a bit under
 a gig. I am working on a machine with three gig of ram.
 
 (I have seen some suggestions that data.table also provides a
 memory-efficient way of providing database-like functions, but I am unsure
 whether it would let me cope with an object of this size).
 
 Any help or suggestions anyone could offer would be very much appreciated.
 
 Warmest regards, andrewH
 
 


David Winsemius, MD
Alameda, CA, 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.


Re: [R] Is function(x){x}(5) a valid expression?

2012-11-13 Thread Brian Diggs

On 11/13/2012 11:19 AM, Duncan Murdoch wrote:

On 13/11/2012 1:33 PM, Jamie Olson wrote:

I was surprised to notice that statements like:

h = function(...){list(...)}(x=4)

do not throw syntax errors.  R claims that 'h' is now a function, but I
can't seem to call it.

 h = function(x){list(x)}(4)
 is(h)
[1] function OptionalFunction PossibleMethod
 h()
Error in list(x) : 'x' is missing
 h(4)
Error in h(4) : attempt to apply non-function


What's going on?


The body of your function is

{list(x)}(4)

The problem is,

{list(x)}

does not return a function, so you can't call it with the argument 4.


Another way to see this is

 body(h)
{
list(x)
}(4)
 eval(body(h))
Error in eval(expr, envir, enclos) : attempt to apply non-function

So the body is syntactically valid, but can not be evaluated because, as 
Duncan said, {list(x)} is not a function (and that fact can not be 
determined until it is being executed).



If you had

h - function(x) { function(y) y }(4)

it would return 4 every time, because the anonymous function does that.


If what you were doing is to create an anonymous function and 
immediately call it, you can do that as


h - (function(x){list(x)})(4)

in which case

 is(h)
[1] list   vector
 h
[[1]]
[1] 4

I'm not sure which behavior you were expecting.


Duncan Murdoch




--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Starting the line at zero in ggplot

2012-11-13 Thread Maziar Mohaddes
Hi

I have been looking around for a couple of days without being able to find
a solution.
I am trying to plot the following table using the package ggplot2

 MonthMean   SEM
cry3m 3-0.05227273   0.1607422
cry6m 6 0.65826087   0.6638734
cry1y12 0.3833   0.3062907
cry2y24 1.0481   0.4921863
cry3y36 0.8878   0.5122407
cry5y60-1.22235294   1.1307222
cry7y84 1.43454545   1.2690701
cry10y  120 0.501.5101821
cry13y  156 0.1650007.185

using the following code:
graph- ggplot(data=NULL, aes(table[,1],table[,2]))+
  geom_line(data=NULL, aes(table[,1],table[,2]), color=gray60) +
  geom_errorbar(aes(ymin=mrsa, ymax=mrsa+semrsa), width=.35,
color=gray60)+
graph

The line starts obviously at 3 month, I have tried rbind to add a first
line of zeros but since I am putting Error bars in the graph the ggplot
renders an error.
The data used for errorbars is:
 mrsa
  cry3m   cry6m   cry1y   cry2y   cry3y   cry5y
  cry7y  cry10y  cry13y
-0.05227273  0.65826087  0.3833  1.0481  0.8878 -1.22235294
 1.43454545  0.5000  0.1650
semrsa
cry3m cry6m cry1y cry2y cry3y cry5y cry7y
 cry10ycry13y
0.1607422 0.6638734 0.3062907 0.4921863 0.5122407 1.1307222 1.2690701
1.5101821 7.185

 Any help or reading suggestion in solving this problem would be
appreciated

-- 
Thanks in advance
Maziar Mohaddes
MD,
Gothenburg, Sweden

[[alternative HTML version deleted]]

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


[R] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Michael
How do I step thru all lines (including step into sub-routines) in a R
script?

Hi all,

I know I can put a browser() into any place...

but how to step into sub-routines?

Keep pressing n at the break-point seems not getting me into the
sub-routines?

Thanks a lot!

[[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] Missing values and geeglm

2012-11-13 Thread joann
model-geeglm(outcome~predictor+confounder, family=binomial(link = logit), 
data=na.omit(DataMiss), corstr='ar1', id=id, std.err=san.se) 

There could be other variables in DataMiss that have many missing values, so
when you apply na.omit() on DataMiss, you may be ending up with an empty
data.frame. Try subsetting DataMiss to only the variables you will use for
the model, and then taking na.omit of it outside of your model statement.

DataMissOm - na.omit(subset(DataMiss, select = c(outcome, predictor,
confounder, id)))
model-geeglm(outcome~predictor+confounder, family=binomial(link = logit), 
data=DataMissOm, corstr='ar1', id=id, std.err=san.se) 



--
View this message in context: 
http://r.789695.n4.nabble.com/Missing-values-and-geeglm-tp3675622p4649433.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Duncan Murdoch

On 12-11-13 4:05 PM, Michael wrote:

How do I step thru all lines (including step into sub-routines) in a R
script?

Hi all,

I know I can put a browser() into any place...

but how to step into sub-routines?

Keep pressing n at the break-point seems not getting me into the
sub-routines?


Mark all your functions for debugging using debug().  It's not like a 
debugger that will single step until you tell it to just continue on, 
but it gives you the individual steps.


When you've had enough of that, use undebug() to mark the functions for 
stepping over.


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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Michael
but there are hundreds of such functions...? how to mark them all using
debug?

thanks!

On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

  On 12-11-13 4:05 PM, Michael wrote:

 How do I step thru all lines (including step into sub-routines) in a R
 script?

 Hi all,

 I know I can put a browser() into any place...

 but how to step into sub-routines?

 Keep pressing n at the break-point seems not getting me into the
 sub-routines?


 Mark all your functions for debugging using debug().  It's not like a
 debugger that will single step until you tell it to just continue on, but
 it gives you the individual steps.

 When you've had enough of that, use undebug() to mark the functions for
 stepping over.

 Duncan Murdoch



[[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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Duncan Murdoch

On 12-11-13 4:50 PM, Michael wrote:

but there are hundreds of such functions...? how to mark them all using
debug?


When you see you are about to enter one that you haven't marked, you can 
mark it from within the debugger.  (So in some other debuggers you'd 
type s to step in; in R you need to type debug(foo) then n.


Duncan Murdoch


thanks!

On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com wrote:

On 12-11-13 4:05 PM, Michael wrote:

How do I step thru all lines (including step into sub-routines)
in a R
script?

Hi all,

I know I can put a browser() into any place...

but how to step into sub-routines?

Keep pressing n at the break-point seems not getting me into the
sub-routines?


Mark all your functions for debugging using debug().  It's not like
a debugger that will single step until you tell it to just continue
on, but it gives you the individual steps.

When you've had enough of that, use undebug() to mark the functions
for stepping over.

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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Michael
Is there a way to strip out all functions in hundreds of R script?

And then I can create a script which does debug(foo1); debug(foo2);
debug(foo3);,etc?

Thank you!

On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 12-11-13 4:50 PM, Michael wrote:

 but there are hundreds of such functions...? how to mark them all using
 debug?


 When you see you are about to enter one that you haven't marked, you can
 mark it from within the debugger.  (So in some other debuggers you'd type
 s to step in; in R you need to type debug(foo) then n.

 Duncan Murdoch

  thanks!

 On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
 murdoch.dun...@gmail.com 
 mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com
 wrote:

 On 12-11-13 4:05 PM, Michael wrote:

 How do I step thru all lines (including step into sub-routines)
 in a R
 script?

 Hi all,

 I know I can put a browser() into any place...

 but how to step into sub-routines?

 Keep pressing n at the break-point seems not getting me into the
 sub-routines?


 Mark all your functions for debugging using debug().  It's not like
 a debugger that will single step until you tell it to just continue
 on, but it gives you the individual steps.

 When you've had enough of that, use undebug() to mark the functions
 for stepping over.

 Duncan Murdoch





[[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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Duncan Murdoch

On 12-11-13 5:07 PM, Michael wrote:

Is there a way to strip out all functions in hundreds of R script?
And then I can create a script which does debug(foo1); debug(foo2);
debug(foo3);,etc?


Not a simple one.  You could try parsing all the scripts, and look for 
function definitions, and then see where those were assigned.


It would be easier to organize your scripts so that some of them define 
functions, and others call them.  Then just define all the functions, 
and use ls() to find their names.


Duncan Murdoch



Thank you!

On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com wrote:

On 12-11-13 4:50 PM, Michael wrote:

but there are hundreds of such functions...? how to mark them
all using
debug?


When you see you are about to enter one that you haven't marked, you
can mark it from within the debugger.  (So in some other debuggers
you'd type s to step in; in R you need to type debug(foo) then n.

Duncan Murdoch

thanks!

On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
murdoch.dun...@gmail.com mailto:murdoch.dun...@gmail.com
mailto:murdoch.duncan@gmail.__com
mailto:murdoch.dun...@gmail.com wrote:

 On 12-11-13 4:05 PM, Michael wrote:

 How do I step thru all lines (including step into
sub-routines)
 in a R
 script?

 Hi all,

 I know I can put a browser() into any place...

 but how to step into sub-routines?

 Keep pressing n at the break-point seems not getting
me into the
 sub-routines?


 Mark all your functions for debugging using debug().  It's
not like
 a debugger that will single step until you tell it to just
continue
 on, but it gives you the individual steps.

 When you've had enough of that, use undebug() to mark the
functions
 for stepping over.

 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.


[R] Can't format x axis on a stacked plot of a zoo object

2012-11-13 Thread Vindoggy !

As an example data set:

set.seed(1)
z.Date - as.Date(paste(2003, 02, c(1, 3, 7, 9, 14), sep = -))
z - zoo(cbind(left = rnorm(5), right = rnorm(5, sd = 0.2)), z.Date)

tt-time(z)



fmt-%b-%d

labs-format(tt,fmt)
plot(z[,1], xlab = Time, ylab = )

If I plot the data and don't like the format of the x axis I can do this:

plot(z[,1], xlab = Time, ylab = ,xaxt=n)

axis(side=1, at=tt[1:5],labels=labs[1:5],cex.axis=0.7)

But if I want to do a stacked plot:

plot(z, xlab = Time, ylab = ,xaxt=n)
axis(side=1, at=tt[1:5],labels=labs[1:5],cex.axis=0.7)



The axis command has no effect. Can someone explain what is going on and how to 
format a stacked plot like this?


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] OT: Any web based report delivery software that support R out there ?

2012-11-13 Thread Paul
I'm looking for something, but I'm not sure quite how to describe it, so 
maybe the list can help.


I use R to produce several different reports using database  ODBC  R  
Sweave  pdf report.


Ideally I would like to be able to upload the report 'templates' to a 
web page, and allow users to request them to be run at certain times 
with certain parameters, and pick up the resulting reports once they've 
been executed.


Is there anything out there like this ?  I have seen a propriatry system 
called Pipeline Pilot by Accelrys that effectivley does this.


Regards,

Paul.

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


Re: [R] help formatting data for clustering

2012-11-13 Thread David Carlson
This is easier if you read the data into a list instead of creating a
data frame since the number of values on each row is different. You may
be able to modify this to fit your needs. The steps are 1) Read the file
with readLines(); 2) split the lines into numeric vectors  (one for each
line); 3) repeat the first column (id) once for each brand in the line
and build a data.frame with col.names; 4) use table() to build a list of
all the brands and the number of times each appears; 5) cluster using
the table or if necessary convert to a data frame (this will add X to
the front of each brand number since numbers cannot be column names.

dta - readLines(con=stdin(), n=3)
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45

lst - strsplit(dta, , )
lst - sapply(lst, as.numeric)
a - sapply(1:length(lst), function(x) cbind(rep(lst[[x]][[1]], 
  length(lst[[x]])-1), lst[[x]][-1]))
a - data.frame(do.call(rbind, a))
colnames(a) - c(id, brand)
newdat - table(a$id, a$brand)
newdf - data.frame(unclass(newdat))

-
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Raphael Bauduin
Sent: Tuesday, November 13, 2012 4:47 AM
To: r-help@r-project.org
Subject: [R] help formatting data for clustering

Hi,

I'm a R beginner. I have data of this form:

user_id, brand_id1, brand_id2, .

for example:
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45

I'm looking for the right procedure to be able to cluster users. I am
especially interested to know which functions to use at each step.

I am currently able to load the data in a data frame, each row's name
being
the user id.

#extract user brands, ie all collumn except the first
user_brands - userclustering[,-1]

# extract user ids, ie the first column
user_ids  - userclustering[,1]

# set user ids as row name
row.names(user_brands) - user_ids

But now I'm stuck replacing the brand ids by a count for each brand the
user ordered, all other brand counters being implicitely 0 for that
user.

Then I'll need to be sure I can use it for clustering (normalising,
correct
handling of brands absent from a user's list, etc).

thanks in advance for your help!

Raph

[[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] Matrix in R

2012-11-13 Thread Haszun
Is there posiibility to read.table change in matrix?

When i used read.table it gave  me:

 V1   V2  V3 V4
[1,] OsobaA 10,00 9,00 8,00
[2,] OsobaB 2,00  3,00 1,00
[3,] OsobaC 5,00  6,00 4,00

I want to change it in:

[1,]   [2,]   [3,] [4,]  
[1,] A 10,00 9,00 8,00
[2,] B 2,00  3,00 1,00
[3,] C 5,00  6,00 4,00

What should I do to get this?






--
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-in-R-tp4649426.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] OT: Any web based report delivery software that support R out there ?

2012-11-13 Thread Gergely Daróczi
Hello Paul,

we are definitely doing something like this at http://rapporter.net based
on our pander/rapport etc. packages. Please let me know if you would have
further questions.

BTW our `rapport` package (which definitely needs an update on CRAN, so
please check out the recent version on Github if interested:
https://github.com/Rapporter/rapport) was made just for this exact need:
creating reporting templates which could be run against any data set with
optional parameters - and with the option to export the results to pdf,
docx, odt etc.

I hope you would find this useful.

Best,
Gergely

On Tue, Nov 13, 2012 at 11:31 PM, Paul p...@paulhurley.co.uk wrote:

 I'm looking for something, but I'm not sure quite how to describe it, so
 maybe the list can help.

 I use R to produce several different reports using database  ODBC  R 
 Sweave  pdf report.

 Ideally I would like to be able to upload the report 'templates' to a web
 page, and allow users to request them to be run at certain times with
 certain parameters, and pick up the resulting reports once they've been
 executed.

 Is there anything out there like this ?  I have seen a propriatry system
 called Pipeline Pilot by Accelrys that effectivley does this.

 Regards,

 Paul.

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


Re: [R] Matrix in R

2012-11-13 Thread Haszun
It's a bit complicated. Is there any shorter way?
Is there possibility to read datas from .csv as matrix, like this which i
want to have?



--
View this message in context: 
http://r.789695.n4.nabble.com/Matrix-in-R-tp4649426p4649429.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] about systemfit package

2012-11-13 Thread Sonia Amin
Dear friends,
I have written the following lines in R console wich already exist in pdf
file systemfit:
data( GrunfeldGreene )
library( plm )
GGPanel - plm.data( GrunfeldGreene, c( firm, year ) )
greeneSur - systemfit( invest ~ value + capital, method = SUR,
+ data = GGPanel )
greenSur

I have obtained the following incomplete results in wich standard errors of
the estimates and their student statistics didn't appear:
systemfit results
method: SUR

Coefficients:
Chrysler_(Intercept)   Chrysler_value
Chrysler_capital General.Electric_(Intercept)
   0.5043036
0.06954560.3085445  -22.4389132
  General.Electric_value General.Electric_capital
General.Motors_(Intercept) General.Motors_value
   0.03729140.1307830
-162.36410520.1204930
  General.Motors_capital US.Steel_(Intercept)
US.Steel_value US.Steel_capital
   0.3827462
85.42325480.10147820.314
Westinghouse_(Intercept)   Westinghouse_value
Westinghouse_capital
   1.0888770
0.05700910.0415065
but when I wrote the following lines:
summary(greeneSur)

I obtained the following results:
systemfit results
method: SUR

 N DFSSR detRCov   OLS-R2 McElroy-R2
system 100 85 347048 1.39234e+14 0.844042   0.868682

  N DF   SSR   MSE RMSE   R2   Adj R2
Chrysler 20 17   3056.98   179.823  13.4098 0.911862 0.901493
General.Electric 20 17  14009.12   824.066  28.7065 0.687636 0.650887
General.Motors   20 17 144320.88  8489.463  92.1383 0.920742 0.911417
US.Steel 20 17 183763.01 10809.589 103.9692 0.421959 0.353954
Westinghouse 20 17   1898.25   111.662  10.5670 0.726429 0.694244

The covariance matrix of the residuals used for estimation
  Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  176.3203 -25.1478   -332.655   491.857
15.6552
General.Electric  -25.1478 777.4463714.745  1064.649
207.5871
General.Motors   -332.6546 714.7449   8423.875 -2614.188
148.4426
US.Steel  491.85721064.6491  -2614.188 10466.371
642.5712
Westinghouse   15.6552 207.5871148.443   642.571
104.3079

The covariance matrix of the residuals
   Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  179.82262  2.40867   -369.063   535.399
19.6007
General.Electric2.40867824.06559712.161  1440.477
235.6662
General.Motors   -369.06303712.16059   8489.463 -3160.609
152.8077
US.Steel  535.39937   1440.47700  -3160.609 10809.589
767.9016
Westinghouse   19.60073235.66620152.808   767.902
111.6617

The correlations of the residuals
Chrysler General.Electric General.Motors  US.Steel
Westinghouse
Chrysler  1.   0.00625711  -0.298702  0.384018
0.138324
General.Electric  0.00625711   1.   0.269251  0.482637
0.776898
General.Motors   -0.29870209   0.26925075   1.00 -0.329933
0.156947
US.Steel  0.38401758   0.48263726  -0.329933  1.00
0.698954
Westinghouse  0.13832413   0.77689848   0.156947  0.698954
1.00


SUR estimates for 'Chrysler' (equation 1)
Model Formula: Chrysler_invest ~ Chrysler_value + Chrysler_capital
environment: 0x03ae6cbc

  Estimate Std. Error  t value   Pr(|t|)
(Intercept)  0.5043036 12.4874164  0.04038   0.968257
value0.0695456  0.0183279  3.79452   0.001448 **
capital  0.3085445  0.0280530 10.99864 3.7702e-09 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 13.409796 on 17 degrees of freedom
Number of observations: 20 Degrees of Freedom: 17
SSR: 3056.984521 MSE: 179.822619 Root MSE: 13.409796
Multiple R-Squared: 0.911862 Adjusted R-Squared: 0.901493


SUR estimates for 'General.Electric' (equation 2)
Model Formula: General.Electric_invest ~ General.Electric_value +
General.Electric_capital
environment: 0x03ae6cbc

   Estimate  Std. Error  t value   Pr(|t|)
(Intercept) -22.4389132  27.6787930 -0.81069   0.428748
value 0.0372914   0.0133012  2.80360   0.012212 *
capital   0.1307830   0.0239163  5.46836 4.1636e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 28.706543 on 17 degrees of freedom
Number of observations: 20 Degrees of Freedom: 17
SSR: 14009.115084 MSE: 824.065593 Root MSE: 28.706543
Multiple R-Squared: 0.687636 Adjusted R-Squared: 0.650887


SUR estimates for 'General.Motors' (equation 3)
Model Formula: General.Motors_invest ~ General.Motors_value +
General.Motors_capital
environment: 0x03ae6cbc

Estimate   Std. Error  t value   Pr(|t|)

[R] Effective degrees of freedom

2012-11-13 Thread Mario A. Pardo

Greetings,

I am performing a simple Pearson's correlation test. Length of both 
vectors is 40, therefore the resulting df is 38. Nevertheless, a 
colleague is asking me for the effective degrees of freedom. As far as 
I understand, those degrees of freedom have to be estimated for more 
complex regressions, but I was not able to find detailed information 
about it. Does any one of you know if I have to estimate those effective 
degrees of freedom for a simple Pearson correlation test?


Thank you very much in advance,

--
-mario

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


Re: [R] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread William Dunlap
You can make a list of the names of the functions defined at the top
level in a script using the following.

namesOfFunctionsDefined - function (expr) { # expr is typically output of 
parse(file)
expr - as.list(expr)
isFunctionAssignment - function(expr) is.call(expr)  identical(expr[[1]],
as.name(-))  is.call(expr[[3]])  identical(expr[[3]][[1]],
as.name(function))
asgns - vapply(expr, isFunctionAssignment, FALSE)
expr - expr[asgns]
vapply(expr, function(e) deparse(e[[2]])[1], )
}

E.g., for the script /tmp/r.R containing
  f1 - function(x)x+1
  x - 10
  x1 - f1(x)
  f2 - function(x)x+1
  x2 - f2(x)
I get:
   namesOfFunctionsDefined(parse(/tmp/r.R))
  [1] f1 f2

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 Michael
 Sent: Tuesday, November 13, 2012 2:08 PM
 To: Duncan Murdoch
 Cc: r-help
 Subject: Re: [R] How do I step thru all lines (including step into 
 sub-routines) in a R script?
 
 Is there a way to strip out all functions in hundreds of R script?
 
 And then I can create a script which does debug(foo1); debug(foo2);
 debug(foo3);,etc?
 
 Thank you!
 
 On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
 murdoch.dun...@gmail.comwrote:
 
  On 12-11-13 4:50 PM, Michael wrote:
 
  but there are hundreds of such functions...? how to mark them all using
  debug?
 
 
  When you see you are about to enter one that you haven't marked, you can
  mark it from within the debugger.  (So in some other debuggers you'd type
  s to step in; in R you need to type debug(foo) then n.
 
  Duncan Murdoch
 
   thanks!
 
  On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
  murdoch.dun...@gmail.com
 mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com
  wrote:
 
  On 12-11-13 4:05 PM, Michael wrote:
 
  How do I step thru all lines (including step into sub-routines)
  in a R
  script?
 
  Hi all,
 
  I know I can put a browser() into any place...
 
  but how to step into sub-routines?
 
  Keep pressing n at the break-point seems not getting me into the
  sub-routines?
 
 
  Mark all your functions for debugging using debug().  It's not like
  a debugger that will single step until you tell it to just continue
  on, but it gives you the individual steps.
 
  When you've had enough of that, use undebug() to mark the functions
  for stepping over.
 
  Duncan Murdoch
 
 
 
 
 
   [[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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Michael
Thanks a lot!

How do I iteratively loop your function thru all scripts under a big folder
and its sub-folders?

Thanks again!




On Tue, Nov 13, 2012 at 4:45 PM, William Dunlap wdun...@tibco.com wrote:

 You can make a list of the names of the functions defined at the top
 level in a script using the following.

 namesOfFunctionsDefined - function (expr) { # expr is typically output of
 parse(file)
 expr - as.list(expr)
 isFunctionAssignment - function(expr) is.call(expr) 
 identical(expr[[1]],
 as.name(-))  is.call(expr[[3]])  identical(expr[[3]][[1]],
 as.name(function))
 asgns - vapply(expr, isFunctionAssignment, FALSE)
 expr - expr[asgns]
 vapply(expr, function(e) deparse(e[[2]])[1], )
 }

 E.g., for the script /tmp/r.R containing
   f1 - function(x)x+1
   x - 10
   x1 - f1(x)
   f2 - function(x)x+1
   x2 - f2(x)
 I get:
namesOfFunctionsDefined(parse(/tmp/r.R))
   [1] f1 f2

 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 Michael
  Sent: Tuesday, November 13, 2012 2:08 PM
  To: Duncan Murdoch
  Cc: r-help
  Subject: Re: [R] How do I step thru all lines (including step into
 sub-routines) in a R script?
 
  Is there a way to strip out all functions in hundreds of R script?
 
  And then I can create a script which does debug(foo1); debug(foo2);
  debug(foo3);,etc?
 
  Thank you!
 
  On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
  murdoch.dun...@gmail.comwrote:
 
   On 12-11-13 4:50 PM, Michael wrote:
  
   but there are hundreds of such functions...? how to mark them all
 using
   debug?
  
  
   When you see you are about to enter one that you haven't marked, you
 can
   mark it from within the debugger.  (So in some other debuggers you'd
 type
   s to step in; in R you need to type debug(foo) then n.
  
   Duncan Murdoch
  
thanks!
  
   On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
   murdoch.dun...@gmail.com
  mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com
   wrote:
  
   On 12-11-13 4:05 PM, Michael wrote:
  
   How do I step thru all lines (including step into
 sub-routines)
   in a R
   script?
  
   Hi all,
  
   I know I can put a browser() into any place...
  
   but how to step into sub-routines?
  
   Keep pressing n at the break-point seems not getting me
 into the
   sub-routines?
  
  
   Mark all your functions for debugging using debug().  It's not
 like
   a debugger that will single step until you tell it to just
 continue
   on, but it gives you the individual steps.
  
   When you've had enough of that, use undebug() to mark the
 functions
   for stepping over.
  
   Duncan Murdoch
  
  
  
  
 
[[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] Can't format x axis on a stacked plot of a zoo object

2012-11-13 Thread Gabor Grothendieck
On Tue, Nov 13, 2012 at 5:30 PM, Vindoggy ! vindo...@hotmail.com wrote:

 As an example data set:

 set.seed(1)
 z.Date - as.Date(paste(2003, 02, c(1, 3, 7, 9, 14), sep = -))
 z - zoo(cbind(left = rnorm(5), right = rnorm(5, sd = 0.2)), z.Date)

 tt-time(z)



 fmt-%b-%d

 labs-format(tt,fmt)
 plot(z[,1], xlab = Time, ylab = )

 If I plot the data and don't like the format of the x axis I can do this:

 plot(z[,1], xlab = Time, ylab = ,xaxt=n)

 axis(side=1, at=tt[1:5],labels=labs[1:5],cex.axis=0.7)

 But if I want to do a stacked plot:

 plot(z, xlab = Time, ylab = ,xaxt=n)
 axis(side=1, at=tt[1:5],labels=labs[1:5],cex.axis=0.7)


This is a FAQ.  See FAQ #8

   vignette(zoo-faq)

and also see the examples at the bottom of

   ?plot.zoo


--
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [R] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread William Dunlap
Untested, you probably want to add pattern=\\.R$file:///\\.R$ or similar 
things
to the dir() call that lists all the files:

filenames - dir(directoryName, recursive=TRUE, full.names=TRUE)
unlist(lapply(filenames, function(file)namesOfFunctionsDefined(parse(file

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

From: Michael [mailto:comtech@gmail.com]
Sent: Tuesday, November 13, 2012 2:51 PM
To: William Dunlap
Cc: r-help
Subject: Re: [R] How do I step thru all lines (including step into 
sub-routines) in a R script?

Thanks a lot!

How do I iteratively loop your function thru all scripts under a big folder and 
its sub-folders?

Thanks again!




On Tue, Nov 13, 2012 at 4:45 PM, William Dunlap 
wdun...@tibco.commailto:wdun...@tibco.com wrote:
You can make a list of the names of the functions defined at the top
level in a script using the following.

namesOfFunctionsDefined - function (expr) { # expr is typically output of 
parse(file)
expr - as.list(expr)
isFunctionAssignment - function(expr) is.call(expr)  identical(expr[[1]],
as.namehttp://as.name/(-))  is.call(expr[[3]])  
identical(expr[[3]][[1]],
as.namehttp://as.name/(function))
asgns - vapply(expr, isFunctionAssignment, FALSE)
expr - expr[asgns]
vapply(expr, function(e) deparse(e[[2]])[1], )
}

E.g., for the script /tmp/r.R containing
  f1 - function(x)x+1
  x - 10
  x1 - f1(x)
  f2 - function(x)x+1
  x2 - f2(x)
I get:
   namesOfFunctionsDefined(parse(/tmp/r.R))
  [1] f1 f2

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.comhttp://tibco.com/


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Michael
 Sent: Tuesday, November 13, 2012 2:08 PM
 To: Duncan Murdoch
 Cc: r-help
 Subject: Re: [R] How do I step thru all lines (including step into 
 sub-routines) in a R script?

 Is there a way to strip out all functions in hundreds of R script?

 And then I can create a script which does debug(foo1); debug(foo2);
 debug(foo3);,etc?

 Thank you!

 On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
 murdoch.dun...@gmail.commailto:murdoch.dun...@gmail.comwrote:

  On 12-11-13 4:50 PM, Michael wrote:
 
  but there are hundreds of such functions...? how to mark them all using
  debug?
 
 
  When you see you are about to enter one that you haven't marked, you can
  mark it from within the debugger.  (So in some other debuggers you'd type
  s to step in; in R you need to type debug(foo) then n.
 
  Duncan Murdoch
 
   thanks!
 
  On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
  murdoch.dun...@gmail.commailto:murdoch.dun...@gmail.com
 mailto:murdoch.duncan@gmail.mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.commailto:murdoch.dun...@gmail.com
  wrote:
 
  On 12-11-13 4:05 PM, Michael wrote:
 
  How do I step thru all lines (including step into sub-routines)
  in a R
  script?
 
  Hi all,
 
  I know I can put a browser() into any place...
 
  but how to step into sub-routines?
 
  Keep pressing n at the break-point seems not getting me into the
  sub-routines?
 
 
  Mark all your functions for debugging using debug().  It's not like
  a debugger that will single step until you tell it to just continue
  on, but it gives you the individual steps.
 
  When you've had enough of that, use undebug() to mark the functions
  for stepping over.
 
  Duncan Murdoch
 
 
 
 

   [[alternative HTML version deleted]]

 __
 R-help@r-project.orgmailto:R-help@r-project.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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread Michael
Great help! Thanks a lot!

The only problem is how do I escape from a big loop?

Lets say after a few iterations in that big loop, I've already got enough
of the loop and wanted to escape the loop and debug the next line after the
loop...?

Thanks again!

On Tue, Nov 13, 2012 at 4:54 PM, William Dunlap wdun...@tibco.com wrote:

  Untested, you probably want to add pattern=\\.R$ or similar things

 to the dir() call that lists all the files:

 ** **

 filenames - dir(directoryName, recursive=TRUE, full.names=TRUE)

 unlist(lapply(filenames,
 function(file)namesOfFunctionsDefined(parse(file

 ** **

 Bill Dunlap

 Spotfire, TIBCO Software

 wdunlap tibco.com

 ** **

 *From:* Michael [mailto:comtech@gmail.com]
 *Sent:* Tuesday, November 13, 2012 2:51 PM
 *To:* William Dunlap

 *Cc:* r-help
 *Subject:* Re: [R] How do I step thru all lines (including step into
 sub-routines) in a R script?

  ** **

 Thanks a lot!

  

 How do I iteratively loop your function thru all scripts under a big
 folder and its sub-folders?

  

 Thanks again!

  



  

 On Tue, Nov 13, 2012 at 4:45 PM, William Dunlap wdun...@tibco.com wrote:
 

 You can make a list of the names of the functions defined at the top
 level in a script using the following.

 namesOfFunctionsDefined - function (expr) { # expr is typically output of
 parse(file)
 expr - as.list(expr)
 isFunctionAssignment - function(expr) is.call(expr) 
 identical(expr[[1]],
 as.name(-))  is.call(expr[[3]])  identical(expr[[3]][[1]],
 as.name(function))
 asgns - vapply(expr, isFunctionAssignment, FALSE)
 expr - expr[asgns]
 vapply(expr, function(e) deparse(e[[2]])[1], )
 }

 E.g., for the script /tmp/r.R containing
   f1 - function(x)x+1
   x - 10
   x1 - f1(x)
   f2 - function(x)x+1
   x2 - f2(x)
 I get:
namesOfFunctionsDefined(parse(/tmp/r.R))
   [1] f1 f2

 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 Michael
  Sent: Tuesday, November 13, 2012 2:08 PM
  To: Duncan Murdoch
  Cc: r-help
  Subject: Re: [R] How do I step thru all lines (including step into
 sub-routines) in a R script?
 
  Is there a way to strip out all functions in hundreds of R script?
 
  And then I can create a script which does debug(foo1); debug(foo2);
  debug(foo3);,etc?
 
  Thank you!
 
  On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
  murdoch.dun...@gmail.comwrote:
 
   On 12-11-13 4:50 PM, Michael wrote:
  
   but there are hundreds of such functions...? how to mark them all
 using
   debug?
  
  
   When you see you are about to enter one that you haven't marked, you
 can
   mark it from within the debugger.  (So in some other debuggers you'd
 type
   s to step in; in R you need to type debug(foo) then n.
  
   Duncan Murdoch
  
thanks!
  
   On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
   murdoch.dun...@gmail.com

  mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com

   wrote:
  
   On 12-11-13 4:05 PM, Michael wrote:
  
   How do I step thru all lines (including step into
 sub-routines)
   in a R
   script?
  
   Hi all,
  
   I know I can put a browser() into any place...
  
   but how to step into sub-routines?
  
   Keep pressing n at the break-point seems not getting me
 into the
   sub-routines?
  
  
   Mark all your functions for debugging using debug().  It's not
 like
   a debugger that will single step until you tell it to just
 continue
   on, but it gives you the individual steps.
  
   When you've had enough of that, use undebug() to mark the
 functions
   for stepping over.
  
   Duncan Murdoch
  
  
  
  
 

[[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] Tukey test for subgroups in a data frame

2012-11-13 Thread arun
Hi,
To extract the p values alone:
lapply(split(dat1,dat1$date),function(x) 
TukeyHSD(aov(value~name,data=x),name,ordered=TRUE)[[1]][4])
#$`2008-10-05`
#[1] 0.1402197

#$`2008-11-05`
#[1] 0.004488184

#$`2008-12-05`
#[1] 0.5441151
A.K.



- Original Message -
From: arun smartpink...@yahoo.com
To: raz barvazd...@gmail.com
Cc: R help r-help@r-project.org
Sent: Tuesday, November 13, 2012 12:57 PM
Subject: Re: [R] Tukey test for subgroups in a data frame

HI,
Try this:
dat1-read.table(text=
  date name  value
  10/5/2008  L 26
  10/5/2008  L 30
  10/5/2008  L 54
  10/5/2008  L 25
  10/5/2008 M 18
  10/5/2008 M 21
  10/5/2008 M 29
  10/5/2008 M 17
  11/5/2008  L 32
  11/5/2008  L 35
  11/5/2008  L 44
  11/5/2008  L 28
  11/5/2008 M 19
  11/5/2008 M 22
  11/5/2008 M 18
  11/5/2008 M 16
  12/5/2008  L 24
  12/5/2008  L 33
  12/5/2008  L 35
  12/5/2008  L 28
  12/5/2008 M 29
  12/5/2008 M 23
  12/5/2008 M 39
  12/5/2008 M 42
  ,sep=,header=TRUE,stringsAsFactors=FALSE)
 dat1$date-as.Date(dat1$date,format=%m/%d/%Y)
dat1-within(dat1,{name-factor(name)})
res- lapply(split(dat1,dat1$date),function(x) 
TukeyHSD(aov(value~name,data=x),name,ordered=TRUE))
 res
#$`2008-10-05`
 # Tukey multiple comparisons of means
  #  95% family-wise confidence level
   # factor levels have been ordered

#Fit: aov(formula = value ~ name, data = x)

#$name
  #  diff   lwr  upr p adj
#L-M 12.5 -5.501854 30.50185 0.1402197


#$`2008-11-05`
 # Tukey multiple comparisons of means
  #  95% family-wise confidence level
   # factor levels have been ordered

#Fit: aov(formula = value ~ name, data = x)

#$name
 #   diff lwr  upr p adj
#L-M   16 7.13522 24.86478 0.0044882



A.K.

- Original Message -
From: raz barvazd...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Tuesday, November 13, 2012 11:27 AM
Subject: [R] Tukey test for subgroups in a data frame

Hello,

I have a data frame with the following columns: date,name,value
the name is the same for each date
I would like to get TukeyHSD p-value for the differences of value between
names in each date separately I tried different ANOVA (aov()) but can
only get either tukey by name or by data but not name by date

any suggestions?

Thanks

-- 
\m/

    [[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] How do I step thru all lines (including step into sub-routines) in a R script?

2012-11-13 Thread William Dunlap
I am not familiar with debugger().  I only showed how to list
all function definitions in a group of files.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

From: Michael [mailto:comtech@gmail.com]
Sent: Tuesday, November 13, 2012 2:59 PM
To: William Dunlap
Cc: r-help
Subject: Re: [R] How do I step thru all lines (including step into 
sub-routines) in a R script?

Great help! Thanks a lot!

The only problem is how do I escape from a big loop?

Lets say after a few iterations in that big loop, I've already got enough of 
the loop and wanted to escape the loop and debug the next line after the 
loop...?

Thanks again!
On Tue, Nov 13, 2012 at 4:54 PM, William Dunlap 
wdun...@tibco.commailto:wdun...@tibco.com wrote:
Untested, you probably want to add pattern=\\.R$ or similar things
to the dir() call that lists all the files:

filenames - dir(directoryName, recursive=TRUE, full.names=TRUE)
unlist(lapply(filenames, function(file)namesOfFunctionsDefined(parse(file

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.comhttp://tibco.com/

From: Michael [mailto:comtech@gmail.commailto:comtech@gmail.com]
Sent: Tuesday, November 13, 2012 2:51 PM
To: William Dunlap

Cc: r-help
Subject: Re: [R] How do I step thru all lines (including step into 
sub-routines) in a R script?

Thanks a lot!

How do I iteratively loop your function thru all scripts under a big folder and 
its sub-folders?

Thanks again!




On Tue, Nov 13, 2012 at 4:45 PM, William Dunlap 
wdun...@tibco.commailto:wdun...@tibco.com wrote:
You can make a list of the names of the functions defined at the top
level in a script using the following.

namesOfFunctionsDefined - function (expr) { # expr is typically output of 
parse(file)
expr - as.list(expr)
isFunctionAssignment - function(expr) is.call(expr)  identical(expr[[1]],
as.namehttp://as.name/(-))  is.call(expr[[3]])  
identical(expr[[3]][[1]],
as.namehttp://as.name/(function))
asgns - vapply(expr, isFunctionAssignment, FALSE)
expr - expr[asgns]
vapply(expr, function(e) deparse(e[[2]])[1], )
}

E.g., for the script /tmp/r.R containing
  f1 - function(x)x+1
  x - 10
  x1 - f1(x)
  f2 - function(x)x+1
  x2 - f2(x)
I get:
   namesOfFunctionsDefined(parse(/tmp/r.R))
  [1] f1 f2

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.comhttp://tibco.com/


 -Original Message-
 From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Michael
 Sent: Tuesday, November 13, 2012 2:08 PM
 To: Duncan Murdoch
 Cc: r-help
 Subject: Re: [R] How do I step thru all lines (including step into 
 sub-routines) in a R script?

 Is there a way to strip out all functions in hundreds of R script?

 And then I can create a script which does debug(foo1); debug(foo2);
 debug(foo3);,etc?

 Thank you!

 On Tue, Nov 13, 2012 at 3:56 PM, Duncan Murdoch
 murdoch.dun...@gmail.commailto:murdoch.dun...@gmail.comwrote:

  On 12-11-13 4:50 PM, Michael wrote:
 
  but there are hundreds of such functions...? how to mark them all using
  debug?
 
 
  When you see you are about to enter one that you haven't marked, you can
  mark it from within the debugger.  (So in some other debuggers you'd type
  s to step in; in R you need to type debug(foo) then n.
 
  Duncan Murdoch
 
   thanks!
 
  On Tue, Nov 13, 2012 at 3:43 PM, Duncan Murdoch
  murdoch.dun...@gmail.commailto:murdoch.dun...@gmail.com
 mailto:murdoch.duncan@gmail.mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.commailto:murdoch.dun...@gmail.com
  wrote:
 
  On 12-11-13 4:05 PM, Michael wrote:
 
  How do I step thru all lines (including step into sub-routines)
  in a R
  script?
 
  Hi all,
 
  I know I can put a browser() into any place...
 
  but how to step into sub-routines?
 
  Keep pressing n at the break-point seems not getting me into the
  sub-routines?
 
 
  Mark all your functions for debugging using debug().  It's not like
  a debugger that will single step until you tell it to just continue
  on, but it gives you the individual steps.
 
  When you've had enough of that, use undebug() to mark the functions
  for stepping over.
 
  Duncan Murdoch
 
 
 
 

   [[alternative HTML version deleted]]

 __
 R-help@r-project.orgmailto:R-help@r-project.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, 

Re: [R] How to permanently change console colours in R

2012-11-13 Thread Peter Ehlers

On 2012-11-13 10:49, vinay_ragas wrote:

Hello.

I am new to R and I like it very much... I am learning to use it day-by-day.
I have a query which might be a novice level for you. I want to know how to
change the background and text colours in the R console. Doing google
searches, I found to go to preferences in Edit and to change them. All I
could do is to change the colours and then save them as a format and on each
usage, I have to load those setup using the saved file.

I want to change this once for all. And am crazy about the MATRIX themes, so
I would like to have the black as background and green2 as the text file.
Please help me in this.

And by the way, I use Windows 7, and installed R 2.13.0 version.


Regards,
Vinay


Look for the file Rconsole in the RHome/etc folder.
Then look for (near the bottom):

  ## Colours for console and pager(s)
  # (see rw/etc/rgb.txt for the known colours).
  background = White
  normaltext = NavyBlue
  usertext = Red
  highlight = DarkRed

Adjust to suit your tastes and save.
For example, my aging eyes prefer

  background = black
  normaltext = DarkSeaGreen
  usertext = yellow
  highlight = HotPink

And you should really consider updating your R version.

Peter Ehlers

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


Re: [R] How to permanently change console colours in R

2012-11-13 Thread vinay_ragas
Hello Peter Ehlers

I tried your suggestion. But I couldnt save the settings into Rconsole file
while using that. So i temporarily used my another console settings file and
tried changing the Rconsole from \etc, but still gives an error. 

Anyhow will update my R tomorrow and try your suggestion again and let you
know. Thanks again. 


Regards
Vinay



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-permanently-change-console-colours-in-R-tp4649413p4649454.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Multiple groups barplot

2012-11-13 Thread michele caseposta
Hi everyone,
I have a certain number of samples and I want to visualize the groups those 
samples belong to.
For example, suppose to have three variables, age, sex, and smoker/nonsmoker, 
and three samples, S1, S2, S3.
S1 is 35, male, nonsmoker
S2 is 24, female, nonsmoker
S3 is 24, female, smoker

at the end I have the following data frame:

S1  S2  S3
age 35  24  30
sex M   F   F
smk N   N   S

What I would like is to see this represented in a matrix with colors 
representing the group the specific sample belongs to. In the example, Age 
would have three levels, sex and smoker/nonsmoker will have two.

An example of what I would like to obtain is from the attached image (from The 
Cancer Genome Browser at UCSC)
You can see the class of each sample represented by the color.
Clearly here there are useless variables, like sample name, but the example 
gives an idea of what I would like to get.

So far I was able to achieve a pseudo-result with colorbar.plot, but I find it 
hard to get the labels in the correct position, as it seems like I cannot find 
a way to automatically put them near each class bar

Any suggestions other than colorbar.plot?



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


Re: [R] help formatting data for clustering

2012-11-13 Thread arun
Hi,

You could also try:
dta - read.table(text=
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45
,sep=,,fill=TRUE)
library(reshape)
 dtanew-reshape(dta,varying=2:5,v.name=brand,idvar=V1,direction=long)[,c(1,3)]
 dtanew1-dtanew[complete.cases(dtanew),]
 dtanew1-dtanew1[order(dtanew1$V1),]
 colnames(dtanew1)[1]-id
 table(dtanew1$id,dtanew1$brand)
   
#    11 23 32 34 43 45
 # 1  0  1  1  0  0  2
 # 2  0  0  0  1  0  0
 # 4  1  0  0  0  1  1


A.K.

- Original Message -
From: David Carlson dcarl...@tamu.edu
To: 'Raphael Bauduin' rbli...@gmail.com; r-help@r-project.org
Cc: 
Sent: Tuesday, November 13, 2012 5:38 PM
Subject: Re: [R] help formatting data for clustering

This is easier if you read the data into a list instead of creating a
data frame since the number of values on each row is different. You may
be able to modify this to fit your needs. The steps are 1) Read the file
with readLines(); 2) split the lines into numeric vectors  (one for each
line); 3) repeat the first column (id) once for each brand in the line
and build a data.frame with col.names; 4) use table() to build a list of
all the brands and the number of times each appears; 5) cluster using
the table or if necessary convert to a data frame (this will add X to
the front of each brand number since numbers cannot be column names.

dta - readLines(con=stdin(), n=3)
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45

lst - strsplit(dta, , )
lst - sapply(lst, as.numeric)
a - sapply(1:length(lst), function(x) cbind(rep(lst[[x]][[1]], 
      length(lst[[x]])-1), lst[[x]][-1]))
a - data.frame(do.call(rbind, a))
colnames(a) - c(id, brand)
newdat - table(a$id, a$brand)
newdf - data.frame(unclass(newdat))

-
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77840-4352

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Raphael Bauduin
Sent: Tuesday, November 13, 2012 4:47 AM
To: r-help@r-project.org
Subject: [R] help formatting data for clustering

Hi,

I'm a R beginner. I have data of this form:

user_id, brand_id1, brand_id2, .

for example:
1 , 45 , 32, 45, 23
2 , 34
4, 11, 43, 45

I'm looking for the right procedure to be able to cluster users. I am
especially interested to know which functions to use at each step.

I am currently able to load the data in a data frame, each row's name
being
the user id.

#extract user brands, ie all collumn except the first
user_brands - userclustering[,-1]

# extract user ids, ie the first column
user_ids  - userclustering[,1]

# set user ids as row name
row.names(user_brands) - user_ids

But now I'm stuck replacing the brand ids by a count for each brand the
user ordered, all other brand counters being implicitely 0 for that
user.

Then I'll need to be sure I can use it for clustering (normalising,
correct
handling of brands absent from a user's list, etc).

thanks in advance for your help!

Raph

    [[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] Bootstrapping issues

2012-11-13 Thread Clive Nicholas
Thank you for your answer - I will consult the help file to see if it has
anything to useful to say by way of a solution - but I don't understand why
you accused me of shouting.

I merely pasted in the R output which contained the heading of the results
in block letters: I honestly didn't know that this now constituted
shouting. I don't believe it does. Unless, of course, you objected to my
emphasising of certain words _like this_. I rather think you'll find that
this, too, does not contravene any sort of list 'netiquette' - it's
commonly found on other listservs - and that perhaps you're being rather
too sensitive in response.

C

On 13 November 2012 12:53, PIKAL Petr petr.pi...@precheza.cz wrote:

  Hi

 ** **

 ** **

 *From:* Clive Nicholas [mailto:cliveli...@googlemail.com]
 *Sent:* Tuesday, November 13, 2012 3:12 AM
 *To:* PIKAL Petr
 *Cc:* r-help@r-project.org
 *Subject:* Re: [R] Bootstrapping issues

 ** **

 Petr Pikal replied:

 ** **

 [...]

 ** **

   The following works
 
  results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)
 

 Actually it does not work either

  ** **

 Correct, but I _did_ get it to work shortly before my initial post (sorry
 for not showing it, but I didn't save the output - silly me). 

 ** **

 What seems to happen is that I successfully run the version that _does_
 work, which I then follow up with successful calls to
 -plot(results,index=#)- and -boot.ci(results,type=bca,index=#)-, then I
 follow up with the unsuccessful version of the code, which won't run and
 produces the error, but when I go back to run the original code, this too
 produces the same error. This, to me at least, is very weird behaviour for
 R.

  


  results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)

 Error in data[indices, ] : incorrect number of dimensions
 

 I am not sure but I suspect your bs function expects some indices vector
 and it is somehow not in accordance with your data.

  ** **

 This code, using different simulated data _does_ run, however:

 ** **

 ** **

  mytest-data.frame(Y=rnorm(500, mean=60, sd=1), X1=sample(c(AAA, BBB, 
  CCC, DDD, None, NA), size=500, replace=TRUE), X2=sample(c(0.88, 0.99, 
  1.43, 1.22, 1.1), size=500, replace=TRUE), X3=sample(c(Yes, No), 
  size=500, prob=c(0.6,0.4), replace=TRUE))

 ** **

 ** **

 ** **

  bs - function(formula, data, indices) {

 + mytest - data[indices,]

 + fit - lm(formula, data=mytest)

 + return(coef(fit)) 

 + }

  results - boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)

 ** **

 Hm. Maybe the difference is in using formula.  

 ** **

  results - boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)

 ** **

 From help page, the fourth parameter is called sim and shall be character 
 vector.

 ** **

 See below.

 ** **

  results - boot(data=mytest, statistic=bs, R=1000, Y~X1+X2+X3)

 Error in data[indices, ] : incorrect number of dimensions

  results - boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)

  results

 ** **

 ORDINARY NONPARAMETRIC BOOTSTRAP

 ** **

 ** **

 Call:

 boot(data = mytest, statistic = bs, R = 1000, formula = Y ~ X1 + 

 X2 + X3)

 ** **

 ** **

 Bootstrap Statistics :

originalbiasstd. error

 t1* 59.67822240 -0.0060177161  0.29491879

 t2*  0.09745349  0.0004995554  0.15627776

 t3*  0.24210280 -0.0047317673  0.15018019

 t4* -0.03399254 -0.0046603446  0.15884994

 t5*  0.15302117 -0.0038503464  0.14045470

 t6*  0.15040121  0.0074829413  0.24225957

 t7*  0.18454691 -0.0003127565  0.09321305

 ** **

 ** **

 ** **

   snip

 ** **

 Answers please!

 ** **

 Do not shout, please. I presented an answer and if you consulted help page
 you could find out what I also found out.

 ** **

 Regards

 Petr

 ** **

 Clive Nicholas (clivenicholas.posterous.com

 [Please DO NOT mail me personally here, but at clivenicho...@hotmail.com.
 Please respond to contributions I make in a list thread here. Thanks!]

 My colleagues in the social sciences talk a great deal about methodology.
 I prefer to call it style. -- Freeman J. Dyson




-- 
Clive Nicholas (clivenicholas.posterous.com)

[Please DO NOT mail me personally here, but at clivenicho...@hotmail.com.
Please respond to contributions I make in a list thread here. Thanks!]

My colleagues in the social sciences talk a great deal about methodology.
I prefer to call it style. -- Freeman J. Dyson

[[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] Proc Nnpar1way with D option - equivalent in R

2012-11-13 Thread SASandRlearn
Dan,

what you suggested worked out well. This code below also worked out well for
me and it matches with SAS output.

Ks - cbind(x,fitted(d1logit))
ks.df - data.frame(Ks)
x - subset(ks.df,x==0,select=c(V2))
y - subset(ks.df,x==1,select=c(V2))
ks.test(x[,'V2'], y[,'V2'], alternative = c(two.sided),exact=NULL)

Thank you



--
View this message in context: 
http://r.789695.n4.nabble.com/Proc-Nnpar1way-with-D-option-equivalent-in-R-tp4649348p4649459.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] numbering observations: help please!

2012-11-13 Thread Paul Artes
Dear Friends,

I have the very simple problem of needing to number observations in a data
frame. After scratching the rest of my hair off my head without inspiration,
I'm using a silly loop. I'm sure that there is a much more elegant and
faster solution - can anyone help? 

Here is an example:

my.data - data.frame (person=c(1,1,1,1,2,2,3,3,3,3,3,3,3,4,4,4))   # now I
want to number those observations sequentially 
# for each person

my.data$item.number - 0
for (i in 1:length(unique(my.data$person))) {
my.data$item.number [which (my.data$person == 
unique(my.data$person)[i])]
- seq (1:dim(tmp)[1]) }






--
View this message in context: 
http://r.789695.n4.nabble.com/numbering-observations-help-please-tp4649457.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] Macro Variable in R

2012-11-13 Thread SASandRlearn
I have over 300 variables in my table. I want to choose only a handful of
those variables to run through many procedures. Lm(), glm() etc..i have over
10 procedures that i need to run those variables everytime. Those handful of
variables can change everytime if output is satisfactory or not. 

I have done this in SAS. Now i need to know how to do this in R. Any help or
even if someone can point to a previous thread will help. 







--
View this message in context: 
http://r.789695.n4.nabble.com/Macro-Variable-in-R-tp4649460.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] Random sampling many times and run through glm model

2012-11-13 Thread SASandRlearn
I have a large dataset from which i need to take a random sample many times (
say N=50) and run it through the same glm() - logistic regression model
everytime ( 50 times )  and capture the chi-square p-values ( Pr  ChiSq )
of the variables for each run and output  average p-value of the variables
that went into the model. 

I have done this in SAS. LIke to know how i can do this in R. Any help is
appreciated.




--
View this message in context: 
http://r.789695.n4.nabble.com/Random-sampling-many-times-and-run-through-glm-model-tp4649461.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] Random sampling many times and run through glm model

2012-11-13 Thread chuck.01
see:

?boot



SASandRlearn wrote
 I have a large dataset from which i need to take a random sample many
 times ( say N=50) and run it through the same glm() - logistic regression
 model everytime ( 50 times )  and capture the chi-square p-values ( Pr 
 ChiSq ) of the variables for each run and output  average p-value of the
 variables that went into the model. 
 
 I have done this in SAS. LIke to know how i can do this in R. Any help is
 appreciated.





--
View this message in context: 
http://r.789695.n4.nabble.com/Random-sampling-many-times-and-run-through-glm-model-tp4649461p4649462.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] How to filter xml value in R?

2012-11-13 Thread Manish Gupta
Hi,

I have one xml file. 

Class
 Node1 code =1 First node /Node1
 Node2 code =1 Second node /Node2
 Node3 code =1 Third node /Node3
Node1 code =2 Fourth node /Node1
/Class

for (i in 1:xmlSize())
{
 print(Class[i])   # how can i filter Node1 ?
}

by using xmlChildren(Class), i get nodes of Class. How can i filter Node1
and print other elements of Class node?

Regards





--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-filter-xml-value-in-R-tp4649465.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] Getting information encoded in a SAS, SPSS or Stata command file into R.

2012-11-13 Thread andrewH
Wow!  After reading Jan's post, I said Great, I'll do that, because it was
the closest to what I originally had in mind. Then I read Ista's post, and
said I think I'l try that first, because it got me back on the track of
following directions in the R Data Import/Export manual. Then I read
Anthony's post. Now, I am not so thrilled to go the database route, because
frankly have hardly ever used them before, and this would make an already
complex project take longer. 

But, I know that I will need to use the sample survey package for what I am
trying to do. So i think I am going to try to get the data into SQLite
format, and just hope the effort builds character.  Anthony, I have not used
your packages yet, but they look great!

It will probably be more than a week before i get all this worked out and
implemented. Given how much work this will be, I do not want to do it twice,
so I think I will go back to IPUMS and get the rest of the variables, and
break the file up into smaller chunks at the same time, both so I really
have the whole thing, and also so that it is easier to work with.   The
IPUMS version of the file is rectangular (it duplicates the household data
in each individual), and IPUMS has done a lot of valuable work in cleaning
the data and harmonizing variable names and definitions that have changed
over the history of the CPS. (Annoyingly, however, they have not connected
the cross-sections between years. All the CPS samples consist of two sets of
four consecutive months, eight months apart, so the March Supplement always
consist half of people who were interviewed in the last year and half of
people who will be interviewed in the next year (barring turnover)). 

Anyway, when I have figured out my route to import I will report back here.
In the meantime, I have three more questions that one of you may be able to
answer:
1.   Anthony, does the read.SAScii.sqlite function  preserve the label names
for factors in a data frame it imports into SQLite, when those labels are
coded in the command file? 
2.   If I want to make the resulting SQLite database available to the R
community, is there a good place for me to put it? Assume it is 10-20 gigs
in size.  Ideally, it would be set up so that it could be queried remotely
and extracts downloaded. Setting this up is beyond my competence today, but
maybe not in a couple of months.  (I'd like to do the same thing with the 30
years of Consumer Expenditure Survey data I have. I don't have access to SAS
any more, but I converted it all to flat flies while I still did. Currently
the BLS only makes 2011 microdata available free. Earlier years on cd are
$200/year. But they have told me that they have no objection to my making
them available). 
3. I have not yet been able to determine whether CPS micro data from the
period 1940-1961 exists. Does anyone know? It is not on
http://thedataweb.rm.census.gov/ftp/cps_ftp.html, and  IPUMS and NBER
(http://www.nber.org/data/current-population-survey-data.html)  both only
give data back to 1962. I wrote to Census a week ago, but I have not heard
back from them, and in the past they have not been very helpful about
historical micro data.

Thanks to all! Andrew




--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-information-encoded-in-a-SAS-SPSS-or-Stata-command-file-into-R-tp4649353p4649466.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] numbering observations: help please!

2012-11-13 Thread Rolf Turner

On 14/11/12 14:50, Paul Artes wrote:

Dear Friends,

I have the very simple problem of needing to number observations in a data
frame. After scratching the rest of my hair off my head without inspiration,
I'm using a silly loop. I'm sure that there is a much more elegant and
faster solution - can anyone help?

Here is an example:

my.data - data.frame (person=c(1,1,1,1,2,2,3,3,3,3,3,3,3,4,4,4))   # now I
want to number those observations sequentially
# for each person

my.data$item.number - 0
for (i in 1:length(unique(my.data$person))) {
my.data$item.number [which (my.data$person == 
unique(my.data$person)[i])]
- seq (1:dim(tmp)[1]) }

my.data$item.number - 
with(my.data,unlist(tapply(1:length(person),person,function(x){1:length(x)})))


cheers,

Rolf Turner

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