[R] trouble installing SparseM

2012-04-25 Thread Erin Hodgess
Dear R People:

I am attempting to install SparseM on R 2.15.0 on a Linux 11.10 system.

Here is the output
 install.packages(SparseM,depen=TRUE)
Installing package(s) into ‘/home/erin/R/x86_64-pc-linux-gnu-library/2.15’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.at.r-project.org/src/contrib/SparseM_0.96.tar.gz'
Content type 'application/x-gzip' length 749740 bytes (732 Kb)
opened URL
==
downloaded 732 Kb

* installing *source* package ‘SparseM’ ...
** package ‘SparseM’ successfully unpacked and MD5 sums checked
** libs
gfortran   -fpic  -O3 -pipe  -g  -c bckslv.f -o bckslv.o
gfortran   -fpic  -O3 -pipe  -g  -c chol.f -o chol.o
gfortran   -fpic  -O3 -pipe  -g  -c chol2csr.f -o chol2csr.o
gfortran   -fpic  -O3 -pipe  -g  -c cholesky.f -o cholesky.o
gfortran   -fpic  -O3 -pipe  -g  -c csr.f -o csr.o
gfortran   -fpic  -O3 -pipe  -g  -c extract.f -o extract.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG  -fpic  -O3 -pipe
-g  -c iohb.c -o iohb.o
iohb.c: In function ‘readHB_info’:
iohb.c:267: warning: cast from pointer to integer of different size
iohb.c: In function ‘readHB_header’:
iohb.c:309: warning: cast from pointer to integer of different size
iohb.c:310: warning: cast from pointer to integer of different size
iohb.c:328: warning: cast from pointer to integer of different size
iohb.c:346: warning: cast from pointer to integer of different size
iohb.c:347: warning: cast from pointer to integer of different size
iohb.c:348: warning: cast from pointer to integer of different size
iohb.c:349: warning: cast from pointer to integer of different size
iohb.c:362: warning: cast from pointer to integer of different size
iohb.c:305: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:313: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:323: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:336: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:354: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_double’:
iohb.c:423: warning: cast from pointer to integer of different size
iohb.c:446: warning: cast from pointer to integer of different size
iohb.c:474: warning: cast from pointer to integer of different size
iohb.c:427: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:450: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:478: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_double’:
iohb.c:660: warning: cast from pointer to integer of different size
iohb.c:627: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:638: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:645: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:665: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:693: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_char’:
iohb.c:975: warning: cast from pointer to integer of different size
iohb.c:998: warning: cast from pointer to integer of different size
iohb.c:1026: warning: cast from pointer to integer of different size
iohb.c:979: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1002: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1030: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_char’:
iohb.c:1192: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1203: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1213: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1231: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1262: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘ParseRfmt’:
iohb.c:1537: warning: cast from pointer to integer of different size
iohb.c:1547: warning: cast from pointer to integer of different size
iohb.c:1551: warning: cast from pointer to integer of different size
iohb.c: In function ‘substr’:
iohb.c:1585: warning: cast from pointer to integer of different size
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG  -fpic  -O3 -pipe
-g  -c readwrite.c -o readwrite.o
readwrite.c: In function ‘read_HB1’:
readwrite.c:33: 

[R] Using apply() with a function involving ode()

2012-04-25 Thread Adam Zeilinger

Hello,

I am trying to get the output from the numerical simulation of a system 
of ordinary differential equations for a range of values for three 
parameters.  I am using the ode() function (deSolve package) to run the 
numerical simulation and apply() to run the simulation function for each 
set of parameter values.  I am having trouble getting the apply() 
function to work.


Here is an example.  Consider an epidemiology model of West Nile Virus:

wnv.model - function(Time, State, Pars){
  with(as.list(c(State, Pars)), {
dSB - -(alphaB*betaB*SB*IM)/(SB + IB)
dIB - (alphaB*betaB*SB*IM)/(SB + IB) - deltaB*IB
dSM - bM*(SM + EM + IM) - (alphaM*betaB*IB*SM)/(SB 
+ IB) - dM*SM
dEM - (alphaM*betaB*SM*IB)/(SB + IB) - kappaM*EM - 
dM*EM

dIM - kappaM*EM - dM*IM
return(list(c(dSB, dIB, dSM, dEM, dIM)))
  })
}

# I would like to run a numerical simulation of this model for each 
combination of values for the parameters alphaB, betaB, # and kappaM:


av - seq(0, 1, by = 0.2) # vector of values for alphaB
bv - seq(0, 1, by = 0.2) # vector of values for betaB
kv - seq(0, 1, by = 0.2) # vector of values for kappaM

# Here is my function with ode() for the numerical simulation.  The 
function returns the last value of the simulation for the # IB state 
variable (Infected Birds).


library(deSolve)
wnv.sim - function(x){
 Pars - c(alphaB = x[1], betaB = x[2], deltaB = 0.2, bM = 
0.03, dM = 0.03, alphaM = 0.69, kappaM = x[3])

 State - c(SB = 100, IB = 0, SM = 1500, EM = 0, IM = 0.0001)
 Time - seq(0, 60, by = 1)
 model.out - as.data.frame(ode(func = wnv.incubation,
   y = State,
   parms = Pars,
   times = Time))
 model.out[nrow(model.out),]$IB
}

# Finally, here is my apply() function:
dat - apply(expand.grid(av, bv, kv), 1, wnv.sim)

However, the apply() function returns an error:
Error in eval(expr, envir, enclos) : object 'alphaB' not found

I am not sure what is wrong.  Any help would be much appreciated.

Sincerely,
Adam

--
Adam Zeilinger
Post Doctoral Scholar
Department of Entomology
University of California Riverside
www.linkedin.com/in/adamzeilinger

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Combining local data frame with external data

2012-04-25 Thread omezquita
Hi,

I have a list of IDs on a data frame and I want to extract information for
those IDs  from an external database.

I did a workaround using the IN clause in SQL but when the number of IDs
is big this method doesn't work.

In other words, I want to create a join between a local and a external table
using either RODBC() or any other package.

Thanks a lot for your help!

Orlando

--
View this message in context: 
http://r.789695.n4.nabble.com/Combining-local-data-frame-with-external-data-tp4585355p4585355.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] Conditional average

2012-04-25 Thread Christopher W. Ryan

Kebrab67--

It's difficult to answer in the absence of a small bit of representative 
data, and more information about it. How is age76 recorded, as numerical 
years or in categories (age ranges?)  And what are years (you didn't 
mention them as a variable in your data.)


That being said, perhaps by(), or summaryBy() in the doBy package, might 
help.


--Chris Ryan
SUNY Upstate Medical University Clincal Campus
Binghamton, NY

kebrab67 wrote:

Hello, I have a set of data including age, wage and education level each
called age76, wage76 and grade76 I want to know how i can calculate the
average wage of people age 15 to 65 (each year separetly) , only for those
who have an education level of 10 12 and 16...

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

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


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


[R] How to reduce plot size on linux?

2012-04-25 Thread Manish Gupta
Hi,

I am working on linux and i need to reduce plot size (bar plot) so that i
can easily use in sweave.  How can i implement it?

Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-reduce-plot-size-on-linux-tp4585371p4585371.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] Removing the rows from dataset

2012-04-25 Thread santoshdvn
Hi,

I have data set where i have col1,col2,col3,col4

i want to write a condition where the rows has to removed from the dataset
for col110

Please help,

Thanks
Santosh

--
View this message in context: 
http://r.789695.n4.nabble.com/Removing-the-rows-from-dataset-tp4585710p4585710.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] trouble installing SparseM

2012-04-25 Thread Uwe Ligges



On 25.04.2012 08:21, Erin Hodgess wrote:

Dear R People:

I am attempting to install SparseM on R 2.15.0 on a Linux 11.10 system.

Here is the output

install.packages(SparseM,depen=TRUE)

Installing package(s) into ‘/home/erin/R/x86_64-pc-linux-gnu-library/2.15’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.at.r-project.org/src/contrib/SparseM_0.96.tar.gz'
Content type 'application/x-gzip' length 749740 bytes (732 Kb)
opened URL
==
downloaded 732 Kb

* installing *source* package ‘SparseM’ ...
** package ‘SparseM’ successfully unpacked and MD5 sums checked
** libs
gfortran   -fpic  -O3 -pipe  -g  -c bckslv.f -o bckslv.o
gfortran   -fpic  -O3 -pipe  -g  -c chol.f -o chol.o
gfortran   -fpic  -O3 -pipe  -g  -c chol2csr.f -o chol2csr.o
gfortran   -fpic  -O3 -pipe  -g  -c cholesky.f -o cholesky.o
gfortran   -fpic  -O3 -pipe  -g  -c csr.f -o csr.o
gfortran   -fpic  -O3 -pipe  -g  -c extract.f -o extract.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG  -fpic  -O3 -pipe
-g  -c iohb.c -o iohb.o
iohb.c: In function ‘readHB_info’:
iohb.c:267: warning: cast from pointer to integer of different size
iohb.c: In function ‘readHB_header’:
iohb.c:309: warning: cast from pointer to integer of different size
iohb.c:310: warning: cast from pointer to integer of different size
iohb.c:328: warning: cast from pointer to integer of different size
iohb.c:346: warning: cast from pointer to integer of different size
iohb.c:347: warning: cast from pointer to integer of different size
iohb.c:348: warning: cast from pointer to integer of different size
iohb.c:349: warning: cast from pointer to integer of different size
iohb.c:362: warning: cast from pointer to integer of different size
iohb.c:305: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:313: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:323: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:336: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:354: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_double’:
iohb.c:423: warning: cast from pointer to integer of different size
iohb.c:446: warning: cast from pointer to integer of different size
iohb.c:474: warning: cast from pointer to integer of different size
iohb.c:427: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:450: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:478: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_double’:
iohb.c:660: warning: cast from pointer to integer of different size
iohb.c:627: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:638: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:645: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:665: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:693: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_char’:
iohb.c:975: warning: cast from pointer to integer of different size
iohb.c:998: warning: cast from pointer to integer of different size
iohb.c:1026: warning: cast from pointer to integer of different size
iohb.c:979: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1002: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1030: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_char’:
iohb.c:1192: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1203: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1213: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1231: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1262: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘ParseRfmt’:
iohb.c:1537: warning: cast from pointer to integer of different size
iohb.c:1547: warning: cast from pointer to integer of different size
iohb.c:1551: warning: cast from pointer to integer of different size
iohb.c: In function ‘substr’:
iohb.c:1585: warning: cast from pointer to integer of different size
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG  -fpic  -O3 -pipe
-g  -c readwrite.c -o readwrite.o
readwrite.c: 

Re: [R] Removing the rows from dataset

2012-04-25 Thread Jeff Newmiller
Seems you should re-read An Introduction to R that comes with it. Hint: look 
for subset.
---
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.

santoshdvn santosh...@gmail.com wrote:

Hi,

I have data set where i have col1,col2,col3,col4

i want to write a condition where the rows has to removed from the
dataset
for col110

Please help,

Thanks
Santosh

--
View this message in context:
http://r.789695.n4.nabble.com/Removing-the-rows-from-dataset-tp4585710p4585710.html
Sent from the R help mailing list archive at Nabble.com.
   [[alternative HTML version deleted]]

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

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


Re: [R] trouble installing SparseM

2012-04-25 Thread Prof Brian Ripley

On 25/04/2012 08:05, Uwe Ligges wrote:



On 25.04.2012 08:21, Erin Hodgess wrote:

Dear R People:

I am attempting to install SparseM on R 2.15.0 on a Linux 11.10 system.

Here is the output

install.packages(SparseM,depen=TRUE)

Installing package(s) into
‘/home/erin/R/x86_64-pc-linux-gnu-library/2.15’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.at.r-project.org/src/contrib/SparseM_0.96.tar.gz'
Content type 'application/x-gzip' length 749740 bytes (732 Kb)
opened URL
==
downloaded 732 Kb

* installing *source* package ‘SparseM’ ...
** package ‘SparseM’ successfully unpacked and MD5 sums checked
** libs
gfortran -fpic -O3 -pipe -g -c bckslv.f -o bckslv.o
gfortran -fpic -O3 -pipe -g -c chol.f -o chol.o
gfortran -fpic -O3 -pipe -g -c chol2csr.f -o chol2csr.o
gfortran -fpic -O3 -pipe -g -c cholesky.f -o cholesky.o
gfortran -fpic -O3 -pipe -g -c csr.f -o csr.o
gfortran -fpic -O3 -pipe -g -c extract.f -o extract.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O3 -pipe
-g -c iohb.c -o iohb.o
iohb.c: In function ‘readHB_info’:
iohb.c:267: warning: cast from pointer to integer of different size
iohb.c: In function ‘readHB_header’:
iohb.c:309: warning: cast from pointer to integer of different size
iohb.c:310: warning: cast from pointer to integer of different size
iohb.c:328: warning: cast from pointer to integer of different size
iohb.c:346: warning: cast from pointer to integer of different size
iohb.c:347: warning: cast from pointer to integer of different size
iohb.c:348: warning: cast from pointer to integer of different size
iohb.c:349: warning: cast from pointer to integer of different size
iohb.c:362: warning: cast from pointer to integer of different size
iohb.c:305: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:313: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:323: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:336: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:354: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_double’:
iohb.c:423: warning: cast from pointer to integer of different size
iohb.c:446: warning: cast from pointer to integer of different size
iohb.c:474: warning: cast from pointer to integer of different size
iohb.c:427: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:450: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:478: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_double’:
iohb.c:660: warning: cast from pointer to integer of different size
iohb.c:627: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:638: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:645: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:665: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:693: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_mat_char’:
iohb.c:975: warning: cast from pointer to integer of different size
iohb.c:998: warning: cast from pointer to integer of different size
iohb.c:1026: warning: cast from pointer to integer of different size
iohb.c:979: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1002: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1030: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘readHB_aux_char’:
iohb.c:1192: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1203: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1213: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1231: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c:1262: warning: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
iohb.c: In function ‘ParseRfmt’:
iohb.c:1537: warning: cast from pointer to integer of different size
iohb.c:1547: warning: cast from pointer to integer of different size
iohb.c:1551: warning: cast from pointer to integer of different size
iohb.c: In function ‘substr’:
iohb.c:1585: warning: cast from pointer to integer of different size
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O3 -pipe
-g -c readwrite.c -o readwrite.o
readwrite.c: In 

[R] RCOM comInvoke

2012-04-25 Thread Arnaud Battistella
Hi,

I have a quick question regarding RCOM and in particular the comInvoke
function. When we use comCreateObject we have a way to check the
object was properly created with comIsValidHandle; however, after
calling comInvoke the only way to check it worked as expected is to
use comGetProperty and see if we get a correct information. The issue
is that comInvoke always returns NULL so I couldn't find a way to
catch a problem with comInvoke. I was wondering whether there was a
way to check whether comInvoke worked as expected before extracting
data from the object, i.e. before using comGetProperty etc... As a
side note I did try to use comInvoke with inaccurate object names,
i.e. objects not created, and it also returned NULL, as it does when
it works and is properly called.
Thanks in advance for your help.

Best Regards,
Arnaud

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [pROC] roc.test returns NA p-value...

2012-04-25 Thread O
Hello,

I am comparing two ROC curves with bootstraping.  However, some runs return
p-value = NA, and I have no clue why.

Is this anyhow related to like sample size or no sufficient numbers of
bootstraping?  I used the default value (i.e. boot.n=2000), and the number
of observations are quite big since I am comparing maps (e.g., the largest
has more than 9 million observations).

It'd would be great if someone could explain why this is happening.

With thanks,
OK

--
View this message in context: 
http://r.789695.n4.nabble.com/pROC-roc-test-returns-NA-p-value-tp4585795p4585795.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() with a function involving ode()

2012-04-25 Thread Berend Hasselman

See inline comments.

On 25-04-2012, at 08:40, Adam Zeilinger wrote:

 Hello,
 
 I am trying to get the output from the numerical simulation of a system of 
 ordinary differential equations for a range of values for three parameters.  
 I am using the ode() function (deSolve package) to run the numerical 
 simulation and apply() to run the simulation function for each set of 
 parameter values.  I am having trouble getting the apply() function to work.
 
 Here is an example.  Consider an epidemiology model of West Nile Virus:
 
 wnv.model - function(Time, State, Pars){
  with(as.list(c(State, Pars)), {
dSB - -(alphaB*betaB*SB*IM)/(SB + IB)
dIB - (alphaB*betaB*SB*IM)/(SB + IB) - deltaB*IB
dSM - bM*(SM + EM + IM) - (alphaM*betaB*IB*SM)/(SB + IB) 
 - dM*SM
dEM - (alphaM*betaB*SM*IB)/(SB + IB) - kappaM*EM - dM*EM
dIM - kappaM*EM - dM*IM
return(list(c(dSB, dIB, dSM, dEM, dIM)))
  })
 }
 
 # I would like to run a numerical simulation of this model for each 
 combination of values for the parameters alphaB, betaB, # and kappaM:
 
 av - seq(0, 1, by = 0.2) # vector of values for alphaB
 bv - seq(0, 1, by = 0.2) # vector of values for betaB
 kv - seq(0, 1, by = 0.2) # vector of values for kappaM
 
 # Here is my function with ode() for the numerical simulation.  The function 
 returns the last value of the simulation for the # IB state variable 
 (Infected Birds).
 
 library(deSolve)
 wnv.sim - function(x){
 Pars - c(alphaB = x[1], betaB = x[2], deltaB = 0.2, bM = 0.03, dM = 
 0.03, alphaM = 0.69, kappaM = x[3])
 State - c(SB = 100, IB = 0, SM = 1500, EM = 0, IM = 0.0001)
 Time - seq(0, 60, by = 1)
 model.out - as.data.frame(ode(func = wnv.incubation,

There is no function wnv.incubation.
Assuming you mean wnv.model

   y = State,
   parms = Pars,
   times = Time))
 model.out[nrow(model.out),]$IB
 }
 
 # Finally, here is my apply() function:
 dat - apply(expand.grid(av, bv, kv), 1, wnv.sim)
 
 However, the apply() function returns an error:
 Error in eval(expr, envir, enclos) : object 'alphaB' not found

Have you inspected the object returned by expand.grid?
Do head(expand.grid(av,bv,kv))
and you will see that the columns have names which confuse the rest of your 
code.

I was able to repair by doing

pars.grid - expand.grid(av, bv, kv)
names(pars.grid) - NULL
dat - apply(pars.grid, 1, wnv.sim)

HTH,

Berend
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 reduce plot size on linux?

2012-04-25 Thread Uwe Ligges



On 25.04.2012 04:02, Manish Gupta wrote:

Hi,

I am working on linux and i need to reduce plot size (bar plot) so that i
can easily use in sweave.  How can i implement it?



You can control the size of the plots from Sweave, no need to change 
soemthing in the plts themselves (unless you want relative size 
corrections). But that would need some more specific question.


uwe Ligges


Regards

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-reduce-plot-size-on-linux-tp4585371p4585371.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] [pROC] roc.test returns NA p-value...

2012-04-25 Thread Uwe Ligges
Probably you got NAs in some bootstrap results, or you got a 0 variance, 
or you hat 0 observations in a group you compared to another group? 
Check the data and the separate results!


Uwe Ligges


On 25.04.2012 09:28, O wrote:

Hello,

I am comparing two ROC curves with bootstraping.  However, some runs return
p-value = NA, and I have no clue why.

Is this anyhow related to like sample size or no sufficient numbers of
bootstraping?  I used the default value (i.e. boot.n=2000), and the number
of observations are quite big since I am comparing maps (e.g., the largest
has more than 9 million observations).

It'd would be great if someone could explain why this is happening.

With thanks,
OK

--
View this message in context: 
http://r.789695.n4.nabble.com/pROC-roc-test-returns-NA-p-value-tp4585795p4585795.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] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Dwaipayan Dasgupta
Hi,
Could someone help me with this please , im trying to use 
Y = Attrition_data[,1] # extract labels from the data 
 msk = sample.split (Y, SplitRatio=3/4)
  table(Y,msk) 
to do the splitting but it keeps throwing up and error 
 Error: could not find function sample.split
Could you please help

Thanks in advance
doy


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Dwaipayan Dasgupta
Sent: Tuesday, April 24, 2012 9:08 PM
To: r-help@r-project.org
Subject: [R] Splitting data into test and train (80:20) kepping attributes 
similar

Hi,
I am trying to do some predictive modeling around attrition and want to split 
the dataset into test and train (80:20) and keep the ratio of attritees:non 
attrites same.
In my dataset the attrition indicator is coded as 0(for non-attritees) and 1 
(for attritees) and I want to keep the ratio of 0's to 1 similar.
I apologize for this trivial question but this is my second week with R.

Thanks,
Doy





American Express made the following annotations on Tue Apr 24 2012 08:38:50 

**

This message and any attachments are solely for the intended recipient and may 
contain confidential or privileged information. If you are not the intended 
recipient, any disclosure, copying, use, or distribution of the information 
included in this message and any attachments is prohibited. If you have 
received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments. Thank 
you. 

American Express a ajouté le commentaire suivant le Tue Apr 24 2012 08:38:50 

Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
est interdite. Si vous avez reçu cette communication par erreur, veuillez nous 
en aviser par courrier et détruire immédiatement le courrier et les pièces 
jointes. Merci. 

**
---


[[alternative HTML version deleted]]


American Express made the following annotations on Wed Apr 25 2012 03:39:08

**

This message and any attachments are solely for the intended recipient and may 
contain confidential or privileged information. If you are not the intended 
recipient, any disclosure, copying, use, or distribution of the information 
included in this message and any attachments is prohibited. If you have 
received this communication in error, please notify us by reply e-mail and 
immediately and permanently delete this message and any attachments. Thank 
you. 

American Express a ajouté le commentaire suivant le Wed Apr 25 2012 03:39:08 

Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
est interdite. Si vous avez reçu cette communication par erreur, veuillez nous 
en aviser par courrier et détruire immédiatement le courrier et les pièces 
jointes. Merci. 

**
---

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

2012-04-25 Thread Rainer Schuermann
Cross posting
http://stackoverflow.com/questions/10308955/how-to-reduce-image-size-in-sweave

The code you have provided there is unusable, I assume your problems come from 
a lack of understanding how Sweave works (nothing to do with Linux).

Always make sure that 
=
and
@
are always the first characters on the line, 

Comment character in R is # and % in Latex (never //).

Have a look at Section 9 of this paper here
http://www.stat.auckland.ac.nz/%7Eihaka/downloads/Sweave-customisation.pdf
This should solve your problems with plot size in Sweave.

Rgds,
Rainer




On Tuesday 24 April 2012 19:02:23 Manish Gupta wrote:
 Hi,
 
 I am working on linux and i need to reduce plot size (bar plot) so that i
 can easily use in sweave.  How can i implement it?
 
 Regards
 
 --
 View this message in context: http://r.789695.n4.nabble.com/How-to-reduce-
plot-size-on-linux-tp4585371p4585371.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] R shell script

2012-04-25 Thread aoife doherty
Hey guys,
Does anyone have an example of a REALLY simple shell script in R.

Basically i want to run this command:

library(MASS)
wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)

in a shell script something like this:

#!/bin/bash
R
library(MASS)
for i in *.out
do
wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
done


that i can run on a command line this this:
sh R.sh


because i've SO many files to run this command on.


I've been googling, but i'm having trouble of just finding a simple example
explaining how to make this shell script.

Any help appreciated :)
Aoife

[[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] Positioning main title

2012-04-25 Thread Jim Lemon

On 04/25/2012 12:28 AM, ramonovelar wrote:

Hello,

I have a barplot where each row has quite long texts and I have used par
to make some room in the left:
par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0))
barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7)

My problem is that main text appears justified to the plot. I want to put it
in the middle of the image, and find a way to sort it  out with mtex

par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0))
barplot2(prueba,  col=colores, horiz=TRUE,las=1, cex.names=.7)
mtext(l,side = 3, at = -70, line = 0.8)

But I will have to adjust this at =-70 to his plot, depending on the
length of the title. I wonder if I can't find a way to place it in the
center.


Hi Ramon,
Have a look at the getFigCtr function in the plotrix package. This 
returns the center of the figure region by default, but can be adjusted 
to return different proportions of the figure region.


Jim

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


Re: [R] Adding more files to list

2012-04-25 Thread Brian Flatley
Hi,

 

I have searched over the last two days to try and sort this problem but
unfortunately I cannot find the correct solution.

I have a main directory  - Spectra

In this folder I have two subfolders Normal  and Case

 

I am using a package MALDIquant for processing of mass spectrometry data, 

The following command will open and list all my files from the Normal
subfolder (70 files containing spectrums)

 

Spectra - mqReadBrukerFlex(file.path(Spectra/, Normal));

 

How do I add the Case folder to the list (another 70 spectra), so that I
can then process all the files in the same manner and yet maintain their
origin so when I want to do stats analyse on them I can differentiate??

 

Any help would be great, I am very much a beginner,

 

Brian 

 


[[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] take data from a file to another according to their correlation coefficient

2012-04-25 Thread jeff6868
Seems to work great! 

I have a last question (or 2) for you about it, and I will leave you alone
afterwords, I promise :)

I tested your function process.all for the automatization. It seems to be
OK.
It's just when I'd like to save the filled data files.
If I name process.all, for example:  test - process.all(lst, corr2008)
and I save it: write.table(test, ...)
and I check the test file, It has filled my data but all the files from
lst are in one file (the columns are: ST001, ST001_time, ST002,
ST002_time, . (with ST001 for station 1 for example)).
How can I cut these files and save them automatically (one file for ST001,
another for ST002, ...) according to these columns names?

And it is possible in your script to take the second best correlated station
data instead of the best one, if there are NAs in this best correlated
station at the same lines with the NA gaps of the station to fill?

Thanks again for all your help. If you come one day in France near the Alps
or Chamonix (where I'm working), just tell me. I'll pay you some beers or a
restaurant! You deserve it ^^
By the way, where do my rescuer come from? Are you a statistician?

Geoffrey

--
View this message in context: 
http://r.789695.n4.nabble.com/take-data-from-a-file-to-another-according-to-their-correlation-coefficient-tp4580054p4586079.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] Assignment problems

2012-04-25 Thread phillip03
Thanks again!

I would like to construct 14 new 'year' dummy variables. I have 14 years: 
1992:2006 with 231 observations pr. year. The year dummies should assign a 1
if the observation is within the specific year and 0 otherwise. So for
example: 1992dummyvariable=1 if year=0 and so on. 

P

--
View this message in context: 
http://r.789695.n4.nabble.com/Assignment-problems-tp4578672p4586252.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] recommended way to group function calls in Sweave

2012-04-25 Thread Liviu Andronic
Dear all
When using Sweave, I'm always hitting the same bump: I want to group
repetitive calls in a function, but I want both the results and the
function calls in the printed output. Let me explain myself.

Consider the following computation in an Sweave document:
summary(iris[,1:2])
cor(iris[,1:2])

When using these two calls directly, I obtain the following output:
 summary(iris[,1:2])
  Sepal.LengthSepal.Width
 Min.   :4.300   Min.   :2.000
 1st Qu.:5.100   1st Qu.:2.800
 Median :5.800   Median :3.000
 Mean   :5.843   Mean   :3.057
 3rd Qu.:6.400   3rd Qu.:3.300
 Max.   :7.900   Max.   :4.400
 cor(iris[,1:2])
 Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


However, if I try to group the calls in a function:
f - function(d, ind){
  print(summary(d[ , ind]))
  print(cor(d[ , ind]))
  return(invisible(NULL))
}


Then I get a different output in the Sweave PDF:
 f(iris, 1:2)
  Sepal.LengthSepal.Width
 Min.   :4.300   Min.   :2.000
 1st Qu.:5.100   1st Qu.:2.800
 Median :5.800   Median :3.000
 Mean   :5.843   Mean   :3.057
 3rd Qu.:6.400   3rd Qu.:3.300
 Max.   :7.900   Max.   :4.400
 Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


Of course I can use 'echo=F' to remove the ' f(iris, 1:2)' in the
above, but how can I do to keep the original calls 'summary(d[ ,
ind])' and 'cor(d[ , ind])'? Or even better, could the actual calls be
used, after the replacement of arguments by their values:
'summary(iris[,1:2])' and 'cor(iris[,1:2])'.

Or is the recommended way to use cat()-ed statements:
f - function(d, ind){
  cat('Variable summary:\n')
  print(summary(d[ , ind]))
  cat('\nCorrelation table:\n')
  print(cor(d[ , ind]))
  return(invisible(NULL))
}


To obtain such output:
 f(iris, 1:2)
Variable summary:
  Sepal.LengthSepal.Width
 Min.   :4.300   Min.   :2.000
 1st Qu.:5.100   1st Qu.:2.800
 Median :5.800   Median :3.000
 Mean   :5.843   Mean   :3.057
 3rd Qu.:6.400   3rd Qu.:3.300
 Max.   :7.900   Max.   :4.400

Correlation table:
 Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


What is the recommended way of grouping repetitive function calls?
What do you usually use in your own documents? Regards
Liviu


-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

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


Re: [R] Positioning main title

2012-04-25 Thread Ramon Ovelar
Many many thanks for the tip and for authoring this function!

The final code for the plot goes like this:

par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0))
barplot2(prueba,  col=colores, horiz=TRUE,las=1, cex.names=.7)
mtext(l,side = 3, at = getFigCtr()[1], line = 0.8, cex=1.5)



On Wed, Apr 25, 2012 at 12:51 PM, Jim Lemon j...@bitwrit.com.au wrote:

 On 04/25/2012 12:28 AM, ramonovelar wrote:

 Hello,

 I have a barplot where each row has quite long texts and I have used par
 to make some room in the left:
 par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0))
 barplot2(prueba, main = l, col=colores, horiz=TRUE,las=1, cex.names=.7)

 My problem is that main text appears justified to the plot. I want to put
 it
 in the middle of the image, and find a way to sort it  out with mtex

 par(mar=c(0, 17, 3, 0), oma=c(0, 0, 0, 0))
 barplot2(prueba,  col=colores, horiz=TRUE,las=1, cex.names=.7)
 mtext(l,side = 3, at = -70, line = 0.8)

 But I will have to adjust this at =-70 to his plot, depending on the
 length of the title. I wonder if I can't find a way to place it in the
 center.

  Hi Ramon,
 Have a look at the getFigCtr function in the plotrix package. This returns
 the center of the figure region by default, but can be adjusted to return
 different proportions of the figure region.

 Jim




-- 
==
Ramón Ovelar

[[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] Create a new Vector based on two columns

2012-04-25 Thread Patrick Hausmann

Hello,

I am trying to get a new vector 'x1' based on the not NA-values in 
column 'a' and 'b'. I found a way but I am sure this is not the best 
solution. So any ideas on how to optimize this would be great!


m - factor(c(a1, a1, a2, b1, b2, b3, d1, d1),  ordered 
= TRUE)

df - data.frame( a= m, b = m)
df[1,1] - NA
df[4,2] - NA
df[2,2] - NA
df[6,1] - NA
df

w - !apply(df, 2, is.na)
v - apply(w, 1, FUN=function(L) which(L == TRUE)[[1]])

for (i in 1:nrow(df) ) {
g[i] - df[i, v[i]]
}

df$x1 - g

Thanks for any help
Patrick

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


Re: [R] trouble loading ggplot2 using R

2012-04-25 Thread Ramon Ovelar
I don't think I have touched at anything at all. I'm very newbie to R and
to be honest I don't know what Ramdom.seed is. I will try to find out.

I have seen other messages about restoring random.seed, but in order to
check that the problem is really that I have used some Viewing data
commands. The error says, in Spanish, that  .Random.seed is not an integer
vector but a list (.Random.seed no es un vector de números enteros pero es
de tipo 'list')

 class(.Random.seed)
[1] data.frame
 str(.Random.seed)
'data.frame': 626 obs. of  1 variable:
 $ .Random.seed: num  4.03e+02 1.00e+01 -1.28e+09 -1.40e+09 -1.06e+09 ..
 head(.Random.seed)
  .Random.seed
1  403
2   10
3  -1282779759
4  -1404015037
5  -1062445742
6665436644
 tail(.Random.seed)
.Random.seed
621   1369617214
622  -1673749493
623  -1883947891
624   1445895610
625   -903220232
626970996181

On Tue, Apr 24, 2012 at 4:26 PM, Hadley Wickham had...@rice.edu wrote:

  I have a similar error, running R in Snow Leopard too
 
  library(ggplot2)
  Error : .onAttach failed in attachNamespace() for 'ggplot2', details:
   call: stats::runif(1)
   error: .Random.seed no es un vector de números enteros pero es de tipo
  'list'
  Error: package/namespace load failed for ‘ggplot2’

 That's a completely different error.  Are you setting .Random.seed to
 something non-standard?  That's what the error message suggests.

 Hadley

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




-- 
==
Ramón Ovelar

[[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] Create a new Vector based on two columns

2012-04-25 Thread Petr Savicky
On Wed, Apr 25, 2012 at 02:22:05PM +0200, Patrick Hausmann wrote:
 Hello,
 
 I am trying to get a new vector 'x1' based on the not NA-values in 
 column 'a' and 'b'. I found a way but I am sure this is not the best 
 solution. So any ideas on how to optimize this would be great!
 
 m - factor(c(a1, a1, a2, b1, b2, b3, d1, d1),  ordered 
 = TRUE)
 df - data.frame( a= m, b = m)
 df[1,1] - NA
 df[4,2] - NA
 df[2,2] - NA
 df[6,1] - NA
 df
 
 w - !apply(df, 2, is.na)
 v - apply(w, 1, FUN=function(L) which(L == TRUE)[[1]])
 
 for (i in 1:nrow(df) ) {
 g[i] - df[i, v[i]]
 }
 
 df$x1 - g

Hello.

The above code does not initialize g. Adding the command

  g - rep(NA, times=nrow(df))

i get the same as using

  df$x1 - ifelse(is.na(df$a), df$b, df$a)
  df

   ab x1
  1 NA   a1  1
  2   a1 NA  1
  3   a2   a2  2
  4   b1 NA  3
  5   b2   b2  4
  6 NA   b3  5
  7   d1   d1  6
  8   d1   d1  6

The codes are obtained, since the original data frame contains
factors. If the intention is to keep character values, then use

  df$x1 - ifelse(is.na(df$a), as.character(df$b), as.character(df$a))
  df

   ab x1
  1 NA   a1 a1
  2   a1 NA a1
  3   a2   a2 a2
  4   b1 NA b1
  5   b2   b2 b2
  6 NA   b3 b3
  7   d1   d1 d1
  8   d1   d1 d1

Hope this helps.

Petr Savicky.

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

2012-04-25 Thread Nicola Van Wilgen
Dear R list,

It appears that my request from yesterday got a bit garbled. I have
tried to rephrase and retype it - please let me know if you can help me
- I am having some trouble drawing a bar-graph with two groups, both of
which are stacked.

I would like to plot the conservation status according to two
classifications (i.e. my groups - IUCN status and national status), and
for each of those groups I would like data for the marine and
terrestrial species to be stacked. My data look like this (where the
names for the columns are conservation status': NE, LC, NT, VU, EN and
CR; and the matrix name is cs.not.log.bp):

IUCN.Terrestrial168  41  5  4  4  1

IUCN.Marine  69   6  4  2  2  0

National.CS.Terrestrial  16 148  7  7  4  2

National.CS.Marine   69   6  4  2  2  0

I have tried the following code, but it does not work:

barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
Number of species, col = c(grey90,grey80),names = cs.names, ylim =
c(0,250), space = 2)

barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
T,add = T,names.arg = NA)

legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
Terrestrial,National CS Marine),  col =
c(grey90,grey80,grey60,grey30), pch = 15)

What happens is that some of the data in the second group stacks onto
the first group and then the remainder forms a second group. I would
like only like data (i.e. from the same database row) to stack within
a group.

There was one other similar post on the R-list
(http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
the user had the same problem as I did, but it does not seem that this
was resolved.

Please let me know if you have any suggestions.

Thanks and best wishes,

Nicola

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Nicola Van Wilgen
Sent: 24 April 2012 01:12 PM
To: r-help@r-project.org
Subject: [R] Combined grouped and stacked bargraph

Dear R list,

 

I am having some trouble drawing a bar-graph with two groups, both of
which are stacked.

 

A sample of my data (IUCN and national conservation status for marine
and terrestrial species) look like this:

Status

IUCN Terrestrial

IUCN Marine

National CS Terrestrial

National CS Marine

NE

168

69

16

69

LC

41

6

148

6

NT

5

4

7

4

VU

4

2

7

2

EN

4

2

4

2

CR

1

0

2

0

 

I would like to plot the conservation status for two groups (IUCN status
and national status), and for each of those groups I would like data for
the marine and terrestrial species to be stacked. I needed to transpose
the data to plot correctly, so my data in the code below look like this
(where the names for data in the columns are NE, LC, NT, VU, EN and CR;
and the matrix name is cs.not.log.bp):

 

IUCN.Terrestrial168  41  5  4  4  1

IUCN.Marine  69   6  4  2  2  0

National.CS.Terrestrial  16 148  7  7  4  2

National.CS.Marine   69   6  4  2  2  0

 

I have tried the following code, but it does not work:

 

barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
Number of species, col = c(grey90,grey80),

  names = cs.names, ylim = c(0,250), space = 2)

barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
T,add = T,names.arg = NA)

legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
Terrestrial,National CS Marine),

  col = c(grey90,grey80,grey60,grey30), pch = 15)

 

What happens is that some of the data in the second group stacks onto
the first group and then the remainder forms a second group. I would
like only like data to stack within a group.

 

There was one other similar post on the R-list
(http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
the user had the same problem as I did, but it does not seem that this
was resolved.

 

Please let me know if you have any suggestions.

 

Thanks and best wishes,

 

Nicola



This e-mail communication and any attachments are confidential and are
intended 
only for the individual(s) or entity named above and others who have
been 
specifically authorized to receive it. If you are not the intended
recipient, 
please do not copy, use or disclose the contents of this communication
to others. 
Please notify the sender that you have received this email in error by
replying 
to the e-mail or by telephoning the sender. Please then delete the
e-mail and 
any copies of it. This information may contain private, confidential or 
privileged material. 
Thank you. 


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

Re: [R] Use of optim to fit two curves at the same time ?

2012-04-25 Thread Arnaud Mosnier
Dear list,

In order to find a solution to my problem, I created a third objective
function including both calculations done in the previous cases. This
function return a value (i.e. the value to be minimize by optim) equal to
the sum of the two sum of squares, but it does not work (see the code added
at the end of my previous script).

Any suggestion ?

Arnaud


Dear list,

 Here is a small example code that use optim and optimize in order to fit
 two functions.
 Is it possible to fit two functions (like those two for example) at the
 same time using optim ... or another function in R ?

 Thanks

 Arnaud

 ##
 ## function 1
 x1 - 1:100
 y1 - 5.468 * x + 3 # + rnorm(100,0, 10)
 dfxy - cbind(x1,y1)

 # Objective function
 optfunc - function(x, dfxy){
   a - x[1]
   b - x[2]
   xtest - dfxy[,1]
   yobs - dfxy[,2]
   ysim - a*xtest + b
   sum((ysim - yobs)^2)
 }

 out- optim(par=c(0.2,5), fn=function(x){optfunc(x, dfxy)}, method =
 Nelder-Mead, hessian = F)


 ## function 2

 x2 - seq(0.01, 0.1, length=100)
 y2 - exp(30*x2)
 dfxy2 - cbind(x2,y2)

 # objective function
 optfunc2 - function(x, dfxy){
   a - x[1]
   xtest - dfxy[,1]
   yobs - dfxy[,2]
   ysim - exp(a*xtest)
   sum((ysim - yobs)^2)
 }

 out- optimize(f=function(x){optfunc2(x, dfxy2)}, interval=c(0,500))

 ##



optfunc3 - function(x,  dfxy, dfxy2){

  a - x[1]
  b - x[2]
  xtest - dfxy[,1]
  yobs - dfxy[,2]
  ysim - a*xtest + b
  obj1 - sum((ysim - yobs)^2)

  c - x[3]
  xtest2 - dfxy2[,1]
  yobs2 - dfxy2[,2]
  ysim2 - exp(c*xtest2)
  obj2 - sum((ysim2 - yobs2)^2)

obj1 + obj2
}

out3- optim(par=c(0.2,5, 500), fn=function(x){optfunc3(x, dfxy, dfxy2)},
method = Nelder-Mead, hessian = F)

[[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] FW: Combined grouped and stacked bargraph

2012-04-25 Thread John Kane
Hi Nicola,

You have provided the code and data as requested the data is in a very 
unfriendly format.

If you would  supply the data in an easily useable format so that the readers 
here can work with it it would help.

Since it looks like you have a small data set the easiest thing is to use 
dput()  [see ?dput for information] and then just paste the output into your 
email.  I expect you would get faster and better answers.


John Kane
Kingston ON Canada


 -Original Message-
 From: nicola.vanwil...@sanparks.org
 Sent: Wed, 25 Apr 2012 14:42:49 +0200
 To: r-help@r-project.org
 Subject: [R] FW: Combined grouped and stacked bargraph
 
 Dear R list,
 
 It appears that my request from yesterday got a bit garbled. I have
 tried to rephrase and retype it - please let me know if you can help me
 - I am having some trouble drawing a bar-graph with two groups, both of
 which are stacked.
 
 I would like to plot the conservation status according to two
 classifications (i.e. my groups - IUCN status and national status), and
 for each of those groups I would like data for the marine and
 terrestrial species to be stacked. My data look like this (where the
 names for the columns are conservation status': NE, LC, NT, VU, EN and
 CR; and the matrix name is cs.not.log.bp):
 
 IUCN.Terrestrial168  41  5  4  4  1
 
 IUCN.Marine  69   6  4  2  2  0
 
 National.CS.Terrestrial  16 148  7  7  4  2
 
 National.CS.Marine   69   6  4  2  2  0
 
 I have tried the following code, but it does not work:
 
 barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
 Number of species, col = c(grey90,grey80),names = cs.names, ylim =
 c(0,250), space = 2)
 
 barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
 T,add = T,names.arg = NA)
 
 legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
 Terrestrial,National CS Marine),  col =
 c(grey90,grey80,grey60,grey30), pch = 15)
 
 What happens is that some of the data in the second group stacks onto
 the first group and then the remainder forms a second group. I would
 like only like data (i.e. from the same database row) to stack within
 a group.
 
 There was one other similar post on the R-list
 (http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
 the user had the same problem as I did, but it does not seem that this
 was resolved.
 
 Please let me know if you have any suggestions.
 
 Thanks and best wishes,
 
 Nicola
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Nicola Van Wilgen
 Sent: 24 April 2012 01:12 PM
 To: r-help@r-project.org
 Subject: [R] Combined grouped and stacked bargraph
 
 Dear R list,
 
 
 
 I am having some trouble drawing a bar-graph with two groups, both of
 which are stacked.
 
 
 
 A sample of my data (IUCN and national conservation status for marine
 and terrestrial species) look like this:
 
 Status
 
 IUCN Terrestrial
 
 IUCN Marine
 
 National CS Terrestrial
 
 National CS Marine
 
 NE
 
 168
 
 69
 
 16
 
 69
 
 LC
 
 41
 
 6
 
 148
 
 6
 
 NT
 
 5
 
 4
 
 7
 
 4
 
 VU
 
 4
 
 2
 
 7
 
 2
 
 EN
 
 4
 
 2
 
 4
 
 2
 
 CR
 
 1
 
 0
 
 2
 
 0
 
 
 
 I would like to plot the conservation status for two groups (IUCN status
 and national status), and for each of those groups I would like data for
 the marine and terrestrial species to be stacked. I needed to transpose
 the data to plot correctly, so my data in the code below look like this
 (where the names for data in the columns are NE, LC, NT, VU, EN and CR;
 and the matrix name is cs.not.log.bp):
 
 
 
 IUCN.Terrestrial168  41  5  4  4  1
 
 IUCN.Marine  69   6  4  2  2  0
 
 National.CS.Terrestrial  16 148  7  7  4  2
 
 National.CS.Marine   69   6  4  2  2  0
 
 
 
 I have tried the following code, but it does not work:
 
 
 
 barplot(cs.not.log.bp[c(1:2),], xlab = Conservation status, ylab =
 Number of species, col = c(grey90,grey80),
 
   names = cs.names, ylim = c(0,250), space = 2)
 
 barplot(cs.not.log.bp[c(3:4),], col = c(grey60,grey30), beside =
 T,add = T,names.arg = NA)
 
 legend(topright,c(IUCN Terrestrial,IUCN Marine,National CS
 Terrestrial,National CS Marine),
 
   col = c(grey90,grey80,grey60,grey30), pch = 15)
 
 
 
 What happens is that some of the data in the second group stacks onto
 the first group and then the remainder forms a second group. I would
 like only like data to stack within a group.
 
 
 
 There was one other similar post on the R-list
 (http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
 the user had the same problem as I did, but it does not seem that this
 was resolved.
 
 
 
 Please let me know if you have any suggestions.
 
 
 
 Thanks and best wishes,
 
 
 
 Nicola



FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!


[R] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread Stephen Sefick

row - c(a,b,c,d,e,f,g) #rows from larger data frame

row.1 - c(a,b,c,g) #rows of smaller data frame because d, e, 
and f don't contain any of the species, but the zeros are important


x - data.frame(sp1=rnorm(4), sp2=rnorm(4), sp3=rnorm(4), sp4=rnorm(4))

rownames(x) - row.1

#I would like to make z as if I had y, but I only have the rownames of y

y - data.frame(sp1=c(0,0,0), sp2=c(0,0,0), sp3=c(0,0,0), sp4=c(0,0,0))

rownames(y) - c(d, e, f)

z - rbind(x,y)

z - z[order(row.names(z)),]

#I know I am missing something
#many thanks,

--
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

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

-K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

  -Robert Gentleman

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


[R] Where to find the p-value of a correlation test

2012-04-25 Thread Aaditya Nanduri
Hey everyone,


I hope this finds you in good cheer.

I just have a quick question: What is the function that outputs the p-value
for correlation?

cor(x,y) only provides the R value. I would like the p-value associated
with it.

Thank you all for your help!

[[alternative HTML version deleted]]

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


Re: [R] trouble loading ggplot2 using R

2012-04-25 Thread Hadley Wickham
On Wed, Apr 25, 2012 at 6:27 AM, Ramon Ovelar ramon.ove...@gmail.com wrote:
 I don't think I have touched at anything at all. I'm very newbie to R and to
 be honest I don't know what Ramdom.seed is. I will try to find out.

 I have seen other messages about restoring random.seed, but in order to
 check that the problem is really that I have used some Viewing data
 commands. The error says, in Spanish, that  .Random.seed is not an integer
 vector but a list (.Random.seed no es un vector de números enteros pero es
 de tipo 'list')

That's definitely not what it should look like - you might want to
start from a fresh R workspace.

Hadley

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

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


Re: [R] Where to find the p-value of a correlation test

2012-04-25 Thread Ista Zahn
Hi,

Look at the See also section of ?cor

Best,
Ista

On Wed, Apr 25, 2012 at 9:30 AM, Aaditya Nanduri
aaditya.nand...@gmail.com wrote:
 Hey everyone,


 I hope this finds you in good cheer.

 I just have a quick question: What is the function that outputs the p-value
 for correlation?

 cor(x,y) only provides the R value. I would like the p-value associated
 with it.

 Thank you all for your help!

        [[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] recommended way to group function calls in Sweave

2012-04-25 Thread Duncan Murdoch

On 12-04-25 7:41 AM, Liviu Andronic wrote:

Dear all
When using Sweave, I'm always hitting the same bump: I want to group
repetitive calls in a function, but I want both the results and the
function calls in the printed output. Let me explain myself.

Consider the following computation in an Sweave document:
summary(iris[,1:2])
cor(iris[,1:2])

When using these two calls directly, I obtain the following output:

summary(iris[,1:2])

   Sepal.LengthSepal.Width
  Min.   :4.300   Min.   :2.000
  1st Qu.:5.100   1st Qu.:2.800
  Median :5.800   Median :3.000
  Mean   :5.843   Mean   :3.057
  3rd Qu.:6.400   3rd Qu.:3.300
  Max.   :7.900   Max.   :4.400

cor(iris[,1:2])

  Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


However, if I try to group the calls in a function:
f- function(d, ind){
   print(summary(d[ , ind]))
   print(cor(d[ , ind]))
   return(invisible(NULL))
}


Then I get a different output in the Sweave PDF:

f(iris, 1:2)

   Sepal.LengthSepal.Width
  Min.   :4.300   Min.   :2.000
  1st Qu.:5.100   1st Qu.:2.800
  Median :5.800   Median :3.000
  Mean   :5.843   Mean   :3.057
  3rd Qu.:6.400   3rd Qu.:3.300
  Max.   :7.900   Max.   :4.400
  Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


Of course I can use 'echo=F' to remove the '  f(iris, 1:2)' in the
above, but how can I do to keep the original calls 'summary(d[ ,
ind])' and 'cor(d[ , ind])'? Or even better, could the actual calls be
used, after the replacement of arguments by their values:
'summary(iris[,1:2])' and 'cor(iris[,1:2])'.

Or is the recommended way to use cat()-ed statements:
f- function(d, ind){
   cat('Variable summary:\n')
   print(summary(d[ , ind]))
   cat('\nCorrelation table:\n')
   print(cor(d[ , ind]))
   return(invisible(NULL))
}


To obtain such output:

f(iris, 1:2)

Variable summary:
   Sepal.LengthSepal.Width
  Min.   :4.300   Min.   :2.000
  1st Qu.:5.100   1st Qu.:2.800
  Median :5.800   Median :3.000
  Mean   :5.843   Mean   :3.057
  3rd Qu.:6.400   3rd Qu.:3.300
  Max.   :7.900   Max.   :4.400

Correlation table:
  Sepal.Length Sepal.Width
Sepal.Length1.000  -0.1175698
Sepal.Width-0.1175698   1.000


What is the recommended way of grouping repetitive function calls?
What do you usually use in your own documents? Regards
Liviu


I would use the last method, or if the calls were truly repetitive (i.e. 
always identical, not just the same pattern), use a named chunk.


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] trouble loading ggplot2 using R

2012-04-25 Thread David Winsemius


On Apr 25, 2012, at 8:27 AM, Ramon Ovelar wrote:

I don't think I have touched at anything at all. I'm very newbie to  
R and
to be honest I don't know what Ramdom.seed is. I will try to find  
out.


I have seen other messages about restoring random.seed, but in  
order to

check that the problem is really that I have used some Viewing data
commands. The error says, in Spanish, that  .Random.seed is not an  
integer
vector but a list (.Random.seed no es un vector de números enteros  
pero es

de tipo 'list')


class(.Random.seed)

[1] data.frame


That _is_ a problem. It _should_ be an integer atomic vector, although  
it appears to be the correct length (at least is the same as  
my .Random.seed which has the same leading entry, 403, as yours)  and  
it appears to be all integers. Something you have done or some program  
has done has altered the default value. It is possible that this  
problem assignment has been saved in your (invisible) .Rdata file.


It is generally a bad idea to do anything to .Random.seed, but I don't  
see any harm at this point in trying this:


.Random.seed - unlist(.Random.seed)

(... and then trying to install ggplot2)


That should get rid of the 'data.frame' attribute. I would also track  
down your .Rdata file and maybe also your .Rhistory file and delete  
them. You will need to learn how to do this in a Terminal session or  
you will need to learn how to display invisible files in Finder.app.  
The archives of the SIG-Mac list will have instructions.


--
David.


str(.Random.seed)

'data.frame': 626 obs. of  1 variable:
$ .Random.seed: num  4.03e+02 1.00e+01 -1.28e+09 -1.40e+09 -1.06e 
+09 ..

head(.Random.seed)

 .Random.seed
1  403
2   10
3  -1282779759
4  -1404015037
5  -1062445742
6665436644

tail(.Random.seed)

   .Random.seed
621   1369617214
622  -1673749493
623  -1883947891
624   1445895610
625   -903220232
626970996181

On Tue, Apr 24, 2012 at 4:26 PM, Hadley Wickham had...@rice.edu  
wrote:



I have a similar error, running R in Snow Leopard too


library(ggplot2)
Error : .onAttach failed in attachNamespace() for 'ggplot2',  
details:

call: stats::runif(1)
error: .Random.seed no es un vector de números enteros pero es de  
tipo

'list'
Error: package/namespace load failed for ‘ggplot2’


That's a completely different error.  Are you setting .Random.seed to
something non-standard?  That's what the error message suggests.

Hadley

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





--
==
Ramón Ovelar

[[alternative HTML version deleted]]

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] Where to find the p-value of a correlation test

2012-04-25 Thread Duncan Murdoch

On 12-04-25 9:30 AM, Aaditya Nanduri wrote:

Hey everyone,


I hope this finds you in good cheer.

I just have a quick question: What is the function that outputs the p-value
for correlation?

cor(x,y) only provides the R value. I would like the p-value associated
with it.


cor(x,y) calculates the correlation, it doesn't perform a test, so there 
is no p-value.


cor.test() performs a test.

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] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Jessica Streicher
Well, it throws an error, because there is no such function in default R. A bit 
of googling showed it might be the one in the caTools package.

execute this:
install.packages(caTools)
library(caTools)

before executing your code


Am 25.04.2012 um 12:39 schrieb Dwaipayan Dasgupta:

 Hi,
 Could someone help me with this please , im trying to use 
 Y = Attrition_data[,1] # extract labels from the data 
 msk = sample.split (Y, SplitRatio=3/4)
  table(Y,msk) 
 to do the splitting but it keeps throwing up and error 
 Error: could not find function sample.split
 Could you please help
 
 Thanks in advance
 doy
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Dwaipayan Dasgupta
 Sent: Tuesday, April 24, 2012 9:08 PM
 To: r-help@r-project.org
 Subject: [R] Splitting data into test and train (80:20) kepping attributes 
 similar
 
 Hi,
 I am trying to do some predictive modeling around attrition and want to split 
 the dataset into test and train (80:20) and keep the ratio of attritees:non 
 attrites same.
 In my dataset the attrition indicator is coded as 0(for non-attritees) and 1 
 (for attritees) and I want to keep the ratio of 0's to 1 similar.
 I apologize for this trivial question but this is my second week with R.
 
 Thanks,
 Doy
 
 
 
 
 
 American Express made the following annotations on Tue Apr 24 2012 08:38:50 
 
 **
 
 This message and any attachments are solely for the intended recipient and 
 may contain confidential or privileged information. If you are not the 
 intended recipient, any disclosure, copying, use, or distribution of the 
 information included in this message and any attachments is prohibited. If 
 you have received this communication in error, please notify us by reply 
 e-mail and immediately and permanently delete this message and any 
 attachments. Thank you. 
 
 American Express a ajouté le commentaire suivant le Tue Apr 24 2012 08:38:50 
 
 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
 destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
 privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
 duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
 est interdite. Si vous avez reçu cette communication par erreur, veuillez 
 nous en aviser par courrier et détruire immédiatement le courrier et les 
 pièces jointes. Merci. 
 
 **
 ---
 
 
   [[alternative HTML version deleted]]
 
 
 American Express made the following annotations on Wed Apr 25 2012 03:39:08
 
 **
 
 This message and any attachments are solely for the intended recipient and 
 may contain confidential or privileged information. If you are not the 
 intended recipient, any disclosure, copying, use, or distribution of the 
 information included in this message and any attachments is prohibited. If 
 you have received this communication in error, please notify us by reply 
 e-mail and immediately and permanently delete this message and any 
 attachments. Thank you. 
 
 American Express a ajouté le commentaire suivant le Wed Apr 25 2012 03:39:08 
 
 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
 destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
 privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
 duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
 est interdite. Si vous avez reçu cette communication par erreur, veuillez 
 nous en aviser par courrier et détruire immédiatement le courrier et les 
 pièces jointes. Merci. 
 
 **
 ---
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 read the source code of biplot?

2012-04-25 Thread Kevin Wright
I think this should help:

require(pcaMethods)
data(metaboliteDataComplete)
mdc  -  scale(metaboliteDataComplete,  center=TRUE,  scale=FALSE)
##  Now  create  5%  of  outliers.
cond  -  runif(length(mdc))0.05;
mdcOut  -  mdc
mdcOut[cond]  -  10
##  Now  we  do  a  conventional  PCA  and  robustPca  on  the  original
and  the  data
##  with  outliers.
##  We  use  center=FALSE  here  because  the  large  artificial  outliers
would
##  affect  the  means  and  not  allow  to  objectively  compare  the
results.
resSvd-  pca(mdc,  method  =  svd,  nPcs  =  10,  center  =
FALSE)
resSvdOut  -  pca(mdcOut,  method  =  svd,  nPcs  =  10,  center  =
FALSE)
resRobPca  -  pca(mdcOut,  method  =  robustPca,  nPcs  =  10,  center
=  FALSE)
biplot(resRobPca) # Draw the graph
biplot  # shows the generic
methods(biplot) # which method is used?  Depends on the class of the
object
class(resRobPca) # the class is 'pcaRes'
biplot.pcaRes # show the actual code for drawing the object

Kevin

On Tue, Apr 24, 2012 at 1:44 PM, Michael comtech@gmail.com wrote:

  biplot

 standardGeneric for biplot defined from package stats

 function (x, ...)

 standardGeneric(biplot)

 environment: 0x0dd8

 Methods may be defined for arguments: x

 Use showMethods(biplot) for currently available ones.

 

 

  showMethods(biplot)

 Function: biplot (package stats)

 x=ANY

 x=character

 (inherited from: x=ANY)

 x=Pca

  biplot(resRobPCA)

 But how do I get the source code of biplot?

 Thank you!

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




-- 
Kevin Wright

[[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] recommended way to group function calls in Sweave

2012-04-25 Thread Liviu Andronic
On Wed, Apr 25, 2012 at 3:41 PM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:
 I would use the last method, or if the calls were truly repetitive (i.e.
 always identical, not just the same pattern), use a named chunk.

Labeled chunks are indeed what I was looking for [1]. As far as I
understand, this is what Sweave functions (or are these macros?)
look like:


=
d - iris
ind - 1:2
@

sw=
  summary(d[ , ind])
  cor(d[ , ind])
@

=
d - iris
ind - 2:4
sw
@


Regards
Liviu

[1] vignette('Sweave', 'utils')

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

2012-04-25 Thread Mabille, Geraldine
Hi,
I am working with gam models in the mgcv library. My response variable (Y) is 
binary (0/1), and my dataset contains repeated measures over 110 individuals 
(same number of 0/1 within a given individual: e.g. 345-zero and 345-one for 
individual A, 226-zero and 226-one for individual B, etc.). The variable Factor 
is separating the individuals in three groups according to mass (group 0,1,2), 
Factor1 is a binary variable coding for individuals of group1, Factor2 is a 
binary variable for individuals of group 2
I use gam models of this sort with random effects coded using a s( ..., 
bs=re) term:
gm-gam(Y~Factor+te(x1,x2,by=Factor) 
)+s(Individual,bs=re),dat=Data,family=binomial(link=logit),method=REML)
gm1-gam(Y~Factor+te(x1,x2)+ te(x1,x2,by=Factor1)+ 
te(x1,x2,by=Factor2)+s(Individual,bs=re),dat=Data,family=binomial(link=logit),method=REML)

1)First question: is it OK to use gam() to model a binary variable with random 
effects coded as a bs=re term??
I have read that the gamm4() function gives better performance than gamm() to 
deal with binary variables when random effects are coded as: 
random=~(1|Individual) but does that mean that binary variables should not be 
used as response variable in gam() with random effects coded as bs=re???

2)Second question: For some models, I obtain a p-value=NA and Chi-square=0 for 
the s(Individual) term, and for some other models a p-value=1 and high 
Chi-square. The difference between one model that can estimate a p-value and 
one that cannot is very slight: for example if I use a variable x3 instead of 
x2 in a model, it can change from p-value=NA to p-value=1. Does anyone know 
what can be happening?

3)Third question: Not linked to random effects but rather to what the two 
models gm and gm1 are actually testing. From my understanding, the first model 
creates a 2d-smooth for each level of my factor variable and test whether those 
smooth are significantly different from a straight line. The second model, also 
creates 3 smooth: one for the reference level of my Factor variable (group0), 
one showing the difference between the reference smooth and the smooth for 
group1, one showing the difference between the reference smooth and the smooth 
for group 2. The summary(gm1) gives p-values associated with each of those 
three smooths and which determine:  if the reference smooth is different from 
0, if the smooth for group1 is different from the reference smooth and  if the 
smooth for group2 is different from the reference smooth.
Do I understand well what the models are testing? The number of edf estimated 
for te(x1,x2):Factor2 in the gm1 model is 3,013 while it is 19,57 in the gm 
model. Does that mean that the difference between the reference smooth: 
te(x1,x2) and the smooth for group 2: te(x1,x2, by=Factor2) is small so it 
can be modeled with only 3 degrees of freedom? Still, the associated p-value is 
highly significant?
When comparing AIC between the gm and gm1 models, I find sometimes that gm1 has 
a lower AIC than gm.  How can that be interpreted??
Thanks a lot if anyone can help...
Geraldine




[[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] Create new Vector based on two colums

2012-04-25 Thread Patrick Hausmann

Hello,

I am trying to get a new vector 'x1' based on the not NA-values in 
column 'a' and 'b'. I found a way but I am sure this is not the best 
solution. So any ideas on how to optimize this would be great!


m - factor(c(a1, a1, a2, b1, b2, b3, d1, d1),  ordered 
= TRUE)

df - data.frame( a= m, b = m)
df[1,1] - NA
df[4,2] - NA
df[2,2] - NA
df[6,1] - NA
df

w - !apply(df, 2, is.na)
v - apply(w, 1, FUN=function(L) which(L == TRUE)[[1]])

for (i in 1:nrow(df) ) {
g[i] - df[i, v[i]]
}

df$x1 - g

Thanks for any help
Patrick

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


Re: [R] Adding more files to list

2012-04-25 Thread Sebastian Gibb
Hi Brian,

On Wednesday 25 April 2012 13:15:03 Brian Flatley wrote:
 I have a main directory  - Spectra
 
 In this folder I have two subfolders Normal  and Case
The following should be enough:

library(readBrukerFlexData)
Spectra - mqReadBrukerFlex(Spectra/);

 ...
 The following command will open and list all my files from the Normal
 subfolder (70 files containing spectrums)

 Spectra - mqReadBrukerFlex(file.path(Spectra/, Normal));
 
 How do I add the Case folder to the list (another 70 spectra), so that I
 can then process all the files in the same manner and yet maintain their
 origin so when I want to do stats analyse on them I can differentiate??
 
To combine a list you could use c:

SpectraNormal - mqReadBrukerFlex(file.path(Spectra/, Normal));
SpectraCase - mqReadBrukerFlex(file.path(Spectra/, Case));

Spectra - c(SpectraNormal, SpectraCase);

To maintain the origin you could store the indices:

normal - 1:length(SpectraNormal);
cases - (normal+1):(normal+1+length(SpectraCase));

But I would prefer to fetch this information from the MassSpectrum metaData 
slot:

filenames - sapply(Spectra, function(x) {return(metaData(x)$file); });
normal - grepl(pattern=/Normal/, x=filenames);
classes - as.factor(ifelse(normal, Normal, Case));

Now you could access the different cases in the following way:
Spectra[classes==Normal]
Spectra[classes==Case]

Bye,

Sebastian

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


[R] Help on time series Hurst exponent

2012-04-25 Thread Barun Saha
Hello,

I'm an absolute beginner with R. I'm hoping to do some time-series analysis
on my data. The data looks like
#time value
18 153
20 426
70 7
83 130
84 7

and so on where time could be in seconds or hours or days (not all at the
same time). How could I import such a file to R and do some simple stuff
(say plot the values)? As per the tutorials on time series, I could use the
ts() method to import the values (not timestamps). However, one problem
with my data is that the *time intervals are not regular* -- i.e. I don't
have observations at every delta_t. So, I possibly can't ignore the
timestamps.

I'm also interested to estimate the Hurst exponent for the above series.
I've installed the fArma package. Again, I'm not sure how to use the above
series there.

Could someone please help me on this?

-- 
Thanks,
Barun Saha
JPA
IIT, Kharagpur

http://pothi.com/pothi/book/barun-saha-swapner-kheya
http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html

[[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] Conditional average

2012-04-25 Thread kebrab67
id   age76   Wage76   Grade76   Black   immigrt. ...
1  25  102456  12  1 0
2  27  15432 15  0 1
3  30  12340  16 1 1

Then I have lots of data variables 100 for 5000 individuals nearly. What I
wanted is to discriminated by age and education level (age is years only and
grade is years in educational system and wage is salary only no rational
numbers here)
I want to have for people of education level 10 12 16, the average wage for
age 15, and then the same for age 16, and the same for age 17 and so on...
Once i have these average I plot (age vs average salary) to see the
distribution in average

--
View this message in context: 
http://r.789695.n4.nabble.com/Conditional-average-tp4585313p4586691.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] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread chuck.01


--
View this message in context: 
http://r.789695.n4.nabble.com/fill-a-dataframe-with-zeros-where-the-rows-are-a-smaller-subset-of-a-larger-dataframe-species-by-sit-tp4586534p4586711.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] take data from a file to another according to their correlation coefficient

2012-04-25 Thread Rui Barradas
Hello,

The first is easy.


 How can I cut these files and save them automatically (one file for ST001,
 another for ST002, ...) according to these columns names?
 

Similar to the way they were read, using lapply on the results list.
But first make a file names vector.
(I've used the file extension 'dat'.)


test - process.all(lst, m)
fl.names - paste(names(test), dat, sep=.)
lapply(seq_len(length(test)), function(i) write.table(test[[i]],
fl.names[i], ...))


The second is trickier.


 And it is possible in your script to take the second best correlated
 station data
 instead of the best one, if there are NAs in this best correlated station
 at the same
 lines with the NA gaps of the station to fill?


In the function 'process.all', after the internal function 'f',
include the following.


g - function(station){
x - df.list[[station]]
if(any(is.na(x$data))){
mat[row(mat) == col(mat)] - -Inf
nas - which(is.na(x$data))
ord - order(mat[station, ], decreasing = TRUE)[-c(1, 
ncol(mat))]
for(i in nas){
for(y in ord){
if(!is.na(df.list[[y]]$data[i])){
x$data[i] - df.list[[y]]$data[i]
break
}
}
}
}
x
}


Then, change the second pass to

# Note that the two passes are different
df.list - lapply(seq.int(n), f)
df.list - lapply(seq.int(n), g)


And I come from Portugal. I'm a mathematician (with 6 semesters of stats).
When I go to France, it's more to Charente-Maritime - Cognac, I have friends
there,
and I'll definitelly have a couple of cognacs on you.
Good luck with your assignment.

Rui Barradas



--
View this message in context: 
http://r.789695.n4.nabble.com/take-data-from-a-file-to-another-according-to-their-correlation-coefficient-tp4580054p4586719.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] Adding more files to list

2012-04-25 Thread Jeff Newmiller
As to combining, use c().

as to tracking, keep track of the directory that goes with the file. There are 
various ways to do this:

a) keep a vector of filenames, and every time you combine vectors of filenames, 
do the same for the vectors of directory names. You will probably need to use 
rep() to turn one directory name into a vector of repeated values.

b) an organized way to accomplish option a above is to keep the vectors in data 
frames, and use rbind() instead of c() to combine them.

c) you will have to use paste() to combine the paths and filenames before you 
open them, so you might want to do so early on and keep track of which category 
each falls into using more presentable category names in the auxiliary 
vector(s) instead of tracking paths separately.
---
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.

Brian Flatley b.flat...@pgr.reading.ac.uk wrote:

Hi,

 

I have searched over the last two days to try and sort this problem but
unfortunately I cannot find the correct solution.

I have a main directory  - Spectra

In this folder I have two subfolders Normal  and Case

 

I am using a package MALDIquant for processing of mass spectrometry
data, 

The following command will open and list all my files from the Normal
subfolder (70 files containing spectrums)

 

Spectra - mqReadBrukerFlex(file.path(Spectra/, Normal));

 

How do I add the Case folder to the list (another 70 spectra), so
that I
can then process all the files in the same manner and yet maintain
their
origin so when I want to do stats analyse on them I can differentiate??

 

Any help would be great, I am very much a beginner,

 

Brian 

 


   [[alternative HTML version deleted]]

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

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


Re: [R] trouble loading ggplot2 using R

2012-04-25 Thread R. Michael Weylandt
Alternatively, the OP might just use set.seed(1) to get a fresh seed
rather than playing with .Random.seed directly.

To the OP: if you're on Mac, follow these instructions and we'll see
if that fixes your problem:

**) open Terminal
**) type R -q --vanilla
**) At the prompt type the following lines

set.seed(1)
install.packages(ggplot2)
library(ggplot2)
qplot(carat, price, data = head(diamonds, 200)) # Should make a nice
ggplot graph with not so many dots

**) If that works and you don't have anything important saved in your
default start up, return to Terminal and type

mv .RData .Trash

(This just puts it in the trash so we can recover it if you realize
later there actually is something important there)

**) Then start R by typing R -q and enter

library(ggplot2)
qplot(carat, price, data = head(diamonds, 200))

and that should work.

Hopefully that will isolate your problem. If anything fails along the
way, let us know exactly where and how.

Best,
Michael

On Wed, Apr 25, 2012 at 9:42 AM, David Winsemius dwinsem...@comcast.net wrote:

 On Apr 25, 2012, at 8:27 AM, Ramon Ovelar wrote:

 I don't think I have touched at anything at all. I'm very newbie to R and
 to be honest I don't know what Ramdom.seed is. I will try to find out.

 I have seen other messages about restoring random.seed, but in order to
 check that the problem is really that I have used some Viewing data
 commands. The error says, in Spanish, that  .Random.seed is not an
 integer
 vector but a list (.Random.seed no es un vector de números enteros pero
 es
 de tipo 'list')

 class(.Random.seed)

 [1] data.frame


 That _is_ a problem. It _should_ be an integer atomic vector, although it
 appears to be the correct length (at least is the same as my .Random.seed
 which has the same leading entry, 403, as yours)  and it appears to be all
 integers. Something you have done or some program has done has altered the
 default value. It is possible that this problem assignment has been saved in
 your (invisible) .Rdata file.

 It is generally a bad idea to do anything to .Random.seed, but I don't see
 any harm at this point in trying this:

 .Random.seed - unlist(.Random.seed)

 (... and then trying to install ggplot2)


 That should get rid of the 'data.frame' attribute. I would also track down
 your .Rdata file and maybe also your .Rhistory file and delete them. You
 will need to learn how to do this in a Terminal session or you will need to
 learn how to display invisible files in Finder.app. The archives of the
 SIG-Mac list will have instructions.

 --
 David.

 str(.Random.seed)

 'data.frame': 626 obs. of  1 variable:
 $ .Random.seed: num  4.03e+02 1.00e+01 -1.28e+09 -1.40e+09 -1.06e+09 ..

 head(.Random.seed)

  .Random.seed
 1          403
 2           10
 3  -1282779759
 4  -1404015037
 5  -1062445742
 6    665436644

 tail(.Random.seed)

   .Random.seed
 621   1369617214
 622  -1673749493
 623  -1883947891
 624   1445895610
 625   -903220232
 626    970996181

 On Tue, Apr 24, 2012 at 4:26 PM, Hadley Wickham had...@rice.edu wrote:

 I have a similar error, running R in Snow Leopard too

 library(ggplot2)

 Error : .onAttach failed in attachNamespace() for 'ggplot2', details:
 call: stats::runif(1)
 error: .Random.seed no es un vector de números enteros pero es de tipo
 'list'
 Error: package/namespace load failed for ‘ggplot2’


 That's a completely different error.  Are you setting .Random.seed to
 something non-standard?  That's what the error message suggests.

 Hadley

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




 --
 ==
 Ramón Ovelar

        [[alternative HTML version deleted]]

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


 David Winsemius, MD
 West Hartford, CT


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

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


Re: [R] Selecting columns whose names contain mutated except when they also contain non or un

2012-04-25 Thread Paul Miller
Hello Dr. Winsemius,

There was a non-numeric column. Thanks for helping me to see the obvious.

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] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread Stephen Sefick
I am subsetting a larger data frame that contains macroinverterate 
taxa.  I am subsetting them at different levels of taxonomic 
resolution.  Some of the sites do not have say Tipulidae present, so the 
rows are removed completely for this site.  I would like to fill in the 
sites that were removed during the subsetting and fill these with 0.  I 
have the non-subsetted dataframe which contains all of the sites.  I 
would like to use the sites from this complete data set to expand the 
dataframe that is a subset of the sites in the original.  Is that more 
clear.


Stephen

On Wed 25 Apr 2012 09:13:24 AM CDT, chuck.01 wrote:




--
View this message in context: 
http://r.789695.n4.nabble.com/fill-a-dataframe-with-zeros-where-the-rows-are-a-smaller-subset-of-a-larger-dataframe-species-by-sit-tp4586534p4586711.html

Sent from the R help mailing list archive at Nabble.com.

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

and provide commented, minimal, self-contained, reproducible code.
--
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

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

 -K. Mullis

A big computer, a complex algorithm and a long time does not equal science.

   -Robert Gentleman



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


Re: [R] Help on time series Hurst exponent

2012-04-25 Thread R. Michael Weylandt
You really don't want to use ts() -- if you want to use the tools in
fArma use a timeSeries (provided by the package of the same name)

Michael

On Wed, Apr 25, 2012 at 9:54 AM, Barun Saha barun.sah...@gmail.com wrote:
 Hello,

 I'm an absolute beginner with R. I'm hoping to do some time-series analysis
 on my data. The data looks like
 #time value
 18 153
 20 426
 70 7
 83 130
 84 7

 and so on where time could be in seconds or hours or days (not all at the
 same time). How could I import such a file to R and do some simple stuff
 (say plot the values)? As per the tutorials on time series, I could use the
 ts() method to import the values (not timestamps). However, one problem
 with my data is that the *time intervals are not regular* -- i.e. I don't
 have observations at every delta_t. So, I possibly can't ignore the
 timestamps.

 I'm also interested to estimate the Hurst exponent for the above series.
 I've installed the fArma package. Again, I'm not sure how to use the above
 series there.

 Could someone please help me on this?

 --
 Thanks,
 Barun Saha
 JPA
 IIT, Kharagpur

 http://pothi.com/pothi/book/barun-saha-swapner-kheya
 http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html

        [[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] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread Sarah Goslee
The clarification helps; the original description was rather terse.

What about:

 row - c(a,b,c,d,e,f,g) #rows from larger data frame

 x - data.frame(sp1=rnorm(4), sp2=rnorm(4), sp3=rnorm(4), sp4=rnorm(4))

 rownames(x) - row.1

 merge(x, matrix(row, ncol=1), by.x=0, by.y=1, all=TRUE)
  Row.namessp1sp2sp3sp4
1 a  0.4964272  1.4989159  0.4302415  0.9648854
2 b  1.4137142  0.9430609  0.0728391 -0.6275084
3 c -0.8103023 -1.3375148 -0.3799518  0.4523287
4 d NA NA NA NA
5 e NA NA NA NA
6 f NA NA NA NA
7 g -0.1914184  0.5156566  0.5626614  0.8068154

Sarah

On Wed, Apr 25, 2012 at 10:42 AM, Stephen Sefick sas0...@auburn.edu wrote:
 I am subsetting a larger data frame that contains macroinverterate taxa.  I
 am subsetting them at different levels of taxonomic resolution.  Some of the
 sites do not have say Tipulidae present, so the rows are removed completely
 for this site.  I would like to fill in the sites that were removed during
 the subsetting and fill these with 0.  I have the non-subsetted dataframe
 which contains all of the sites.  I would like to use the sites from this
 complete data set to expand the dataframe that is a subset of the sites in
 the original.  Is that more clear.

 Stephen

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


[R] RODBC Error Code 202 on Mac OS X 10.6

2012-04-25 Thread julia . jacobson
Hello everybody out there using the RODBC package,

On my linux (unixODBC) and windows machines, I can successfully use the RODBC 
package to connect to a PostgreSQL databse.
On my Mac Book running Mac OS X 10.6 (Intel 64bit architecture), I get the 
error code 202 and message ? when I try to establish an connection by 
using
con - odbcConnect(dsn=MyDataSource,UID=Me,pwd=secret)
Could anyone please hint me towards additional diagnostics I can run to pin 
down the problem?
I have the latest versions of unixODBC and psqlODBC installed from Macports.
They seem to be okay, because
$isql dsn uid pwd
works fine to connect to the database.

Thanks in advance for your help,
Julia

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

2012-04-25 Thread R. Michael Weylandt
You can do this in bash but why not just do it in R directly? You probably need

list.files(pattern = .out)

to get started. Then just wrap your script in a function and pass it
to (s|l)apply something like:

sapply(list.files(pattern  = *.out), function(x) wilcox.test ( ... ) )

Michael

On Wed, Apr 25, 2012 at 6:47 AM, aoife doherty
aoife.m.dohe...@gmail.com wrote:
 Hey guys,
 Does anyone have an example of a REALLY simple shell script in R.

 Basically i want to run this command:

 library(MASS)
 wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)

 in a shell script something like this:

 #!/bin/bash
 R
 library(MASS)
 for i in *.out
 do
 wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
 done


 that i can run on a command line this this:
 sh R.sh


 because i've SO many files to run this command on.


 I've been googling, but i'm having trouble of just finding a simple example
 explaining how to make this shell script.

 Any help appreciated :)
 Aoife

        [[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 with significance of the estimates when running the pgls function

2012-04-25 Thread Bianca A Santini
Hello,
I am running the pgls () function of the caper programme, the output has
some estimates, some of them are negative and others are positive ( values
can be less, equal, or more than 1 ). If I have an estimate of -0.12 for a
coefficient (body size) on head size.   How do I interpreted it?

Thanks a lot for your help!

:)

-- 
BAS

PhD Student
Department of Animal  Plant Sciences
University of Sheffield
Alfred Denny Building
Western Bank
Sheffield
S10 2TN

0114 2220057

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

2012-04-25 Thread aoife doherty
Thanks for replying.

My problem is that i have say 50 input files, that i wanted to run a
particular command on, get 50 output files, and then when i close R, have
them in my directory?

so for example if i say:

R

library(MASS)

list.files(pattern = .out)

sapply(list.files(pattern  = *.out), function(x) wilcox.test ( ... ) )

send each output to a different file, and save it in such a way that
when i close R the outputs are still there

i thought this might be easier in a shell way?



On Wed, Apr 25, 2012 at 4:03 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 You can do this in bash but why not just do it in R directly? You probably
 need

 list.files(pattern = .out)

 to get started. Then just wrap your script in a function and pass it
 to (s|l)apply something like:

 sapply(list.files(pattern  = *.out), function(x) wilcox.test ( ... ) )

 Michael

 On Wed, Apr 25, 2012 at 6:47 AM, aoife doherty
 aoife.m.dohe...@gmail.com wrote:
  Hey guys,
  Does anyone have an example of a REALLY simple shell script in R.
 
  Basically i want to run this command:
 
  library(MASS)
 
 wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)
 
  in a shell script something like this:
 
  #!/bin/bash
  R
  library(MASS)
  for i in *.out
  do
  wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
  done
 
 
  that i can run on a command line this this:
  sh R.sh
 
 
  because i've SO many files to run this command on.
 
 
  I've been googling, but i'm having trouble of just finding a simple
 example
  explaining how to make this shell script.
 
  Any help appreciated :)
  Aoife
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] R shell script

2012-04-25 Thread Steve Lianoglou
Check out the vignette for the optparse library:

http://cran.r-project.org/web/packages/optparse/vignettes/optparse.pdf

Super helpful library if you plan on making any semi-interesting
command line scripts w/ R.

-steve

On Wed, Apr 25, 2012 at 6:47 AM, aoife doherty
aoife.m.dohe...@gmail.com wrote:
 Hey guys,
 Does anyone have an example of a REALLY simple shell script in R.

 Basically i want to run this command:

 library(MASS)
 wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)

 in a shell script something like this:

 #!/bin/bash
 R
 library(MASS)
 for i in *.out
 do
 wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
 done


 that i can run on a command line this this:
 sh R.sh


 because i've SO many files to run this command on.


 I've been googling, but i'm having trouble of just finding a simple example
 explaining how to make this shell script.

 Any help appreciated :)
 Aoife

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



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] recommended way to group function calls in Sweave

2012-04-25 Thread Duncan Murdoch

On 25/04/2012 10:20 AM, Liviu Andronic wrote:

On Wed, Apr 25, 2012 at 3:41 PM, Duncan Murdoch
murdoch.dun...@gmail.com  wrote:
  I would use the last method, or if the calls were truly repetitive (i.e.
  always identical, not just the same pattern), use a named chunk.

Labeled chunks are indeed what I was looking for [1]. As far as I
understand, this is what Sweave functions (or are these macros?)
look like:


Yes.  They're definitely macros, not functions:  pure text substitution.

Duncan Murdoch



=
d- iris
ind- 1:2
@

sw=
   summary(d[ , ind])
   cor(d[ , ind])
@

=
d- iris
ind- 2:4
sw
@


Regards
Liviu

[1] vignette('Sweave', 'utils')


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


Re: [R] Selecting columns whose names contain mutated except when they also contain non or un

2012-04-25 Thread peter dalgaard

On Apr 24, 2012, at 19:15 , Rui Barradas wrote:
 
 Has anyone realized that both 'non' and 'un' end with the same letter? The
 only one we really need to check?
 
 (tmp - c('mutation','nonmutated','unmutated','verymutated','other')) 
 
 i1 - grepl(muta, tmp)
 i2 - grepl(nmuta, tmp)
 
 tmp[i1  !i2]
 


Yes, I was wondering why people were avoiding the obvious use of grepl(). I'm 
not too happy about the nmuta technique though: What about deletionmutation 
and such? Might as well do the safe(r) thing:

i2 - grepl(unmuta, tmp) | grepl(nonmuta, tmp) 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Dwaipayan Dasgupta
Thank you so much for replying. I tried what you said but it still throws the 
same error i.e could not find function sample.split
Might be because of the version of R I am running (R version 2.12.2).i do not 
have admin rights to upgrade to the newest version.
Is there anything else I can try? Im trying to split my data into 80:20 keeping 
the ratio of 0,1 in the Y variable(binary) constant.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Jessica Streicher
Sent: Wednesday, April 25, 2012 7:17 PM
To: r-help@r-project.org
Subject: Re: [R] Splitting data into test and train (80:20) kepping attributes 
similar

Well, it throws an error, because there is no such function in default R. A bit 
of googling showed it might be the one in the caTools package.

execute this:
install.packages(caTools)
library(caTools)

before executing your code


Am 25.04.2012 um 12:39 schrieb Dwaipayan Dasgupta:

 Hi,
 Could someone help me with this please , im trying to use 
 Y = Attrition_data[,1] # extract labels from the data 
 msk = sample.split (Y, SplitRatio=3/4)
  table(Y,msk) 
 to do the splitting but it keeps throwing up and error 
 Error: could not find function sample.split
 Could you please help
 
 Thanks in advance
 doy
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Dwaipayan Dasgupta
 Sent: Tuesday, April 24, 2012 9:08 PM
 To: r-help@r-project.org
 Subject: [R] Splitting data into test and train (80:20) kepping attributes 
 similar
 
 Hi,
 I am trying to do some predictive modeling around attrition and want to split 
 the dataset into test and train (80:20) and keep the ratio of attritees:non 
 attrites same.
 In my dataset the attrition indicator is coded as 0(for non-attritees) and 1 
 (for attritees) and I want to keep the ratio of 0's to 1 similar.
 I apologize for this trivial question but this is my second week with R.
 
 Thanks,
 Doy
 
 
 
 
 
 American Express made the following annotations on Tue Apr 24 2012 08:38:50 
 
 **
 
 This message and any attachments are solely for the intended recipient and 
 may contain confidential or privileged information. If you are not the 
 intended recipient, any disclosure, copying, use, or distribution of the 
 information included in this message and any attachments is prohibited. If 
 you have received this communication in error, please notify us by reply 
 e-mail and immediately and permanently delete this message and any 
 attachments. Thank you. 
 
 American Express a ajouté le commentaire suivant le Tue Apr 24 2012 08:38:50 
 
 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
 destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
 privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
 duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
 est interdite. Si vous avez reçu cette communication par erreur, veuillez 
 nous en aviser par courrier et détruire immédiatement le courrier et les 
 pièces jointes. Merci. 
 
 **
 ---
 
 
   [[alternative HTML version deleted]]
 
 
 American Express made the following annotations on Wed Apr 25 2012 03:39:08
 
 **
 
 This message and any attachments are solely for the intended recipient and 
 may contain confidential or privileged information. If you are not the 
 intended recipient, any disclosure, copying, use, or distribution of the 
 information included in this message and any attachments is prohibited. If 
 you have received this communication in error, please notify us by reply 
 e-mail and immediately and permanently delete this message and any 
 attachments. Thank you. 
 
 American Express a ajouté le commentaire suivant le Wed Apr 25 2012 03:39:08 
 
 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
 destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
 privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
 duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
 est interdite. Si vous avez reçu cette communication par erreur, veuillez 
 nous en aviser par courrier et détruire immédiatement le courrier et les 
 pièces jointes. Merci. 
 
 **
 ---
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 

Re: [R] Create new Vector based on two colums

2012-04-25 Thread ilai
On Wed, Apr 25, 2012 at 6:14 AM, Patrick Hausmann
patrick.hausm...@covimo.de wrote:
 Hello,

 I am trying to get a new vector 'x1' based on the not NA-values in column
 'a' and 'b'. I found a way but I am sure this is not the best solution. So
 any ideas on how to optimize this would be great!

If by optimize you mean no loops, you could try

(df- structure(list(a = structure(c(NA, 1L, 2L, 3L, 4L, NA, 6L, 6L
), .Label = c(a1, a2, b1, b2, b3, d1), class = c(ordered,
factor)), b = structure(c(1L, NA, 2L, NA, 4L, 5L, 6L, 6L), .Label = c(a1,
a2, b1, b2, b3, d1), class = c(ordered, factor))),
.Names = c(a,
b), row.names = c(NA, -8L), class = data.frame))

x0 - factor(paste(ifelse(is.na(df[,1]),'',df[,1]),
ifelse(is.na(df[,2]),'',df[,2]), sep=''))
df$x1 - as.numeric(x0)  # only needed for a numeric vector as in your solution
df

HTH

PS - In the future please avoid df and data as object names, as
they mask R functions.


 m - factor(c(a1, a1, a2, b1, b2, b3, d1, d1),  ordered =
 TRUE)
 df - data.frame( a= m, b = m)
 df[1,1] - NA
 df[4,2] - NA
 df[2,2] - NA
 df[6,1] - NA
 df

 w - !apply(df, 2, is.na)
 v - apply(w, 1, FUN=function(L) which(L == TRUE)[[1]])

 for (i in 1:nrow(df) ) {
        g[i] - df[i, v[i]]
 }

 df$x1 - g

 Thanks for any help
 Patrick

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Help on time series Hurst exponent

2012-04-25 Thread R. Michael Weylandt michael.weyla...@gmail.com
www.rmetrics.org/ebooks

There's a free book on time series classes in R here: I haven't used it myself, 
but it is by the fArma (RMetrics) folks so I presume it covers their own time 
series class. 

Michael

On Apr 25, 2012, at 11:11 AM, Barun Saha barun.sah...@gmail.com wrote:

 Thanks, Michael! Could you plz point to some easy tutorials regarding this?
 
 On Wed, Apr 25, 2012 at 8:14 PM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:
 You really don't want to use ts() -- if you want to use the tools in
 fArma use a timeSeries (provided by the package of the same name)
 
 Michael
 
 On Wed, Apr 25, 2012 at 9:54 AM, Barun Saha barun.sah...@gmail.com wrote:
  Hello,
 
  I'm an absolute beginner with R. I'm hoping to do some time-series analysis
  on my data. The data looks like
  #time value
  18 153
  20 426
  70 7
  83 130
  84 7
 
  and so on where time could be in seconds or hours or days (not all at the
  same time). How could I import such a file to R and do some simple stuff
  (say plot the values)? As per the tutorials on time series, I could use the
  ts() method to import the values (not timestamps). However, one problem
  with my data is that the *time intervals are not regular* -- i.e. I don't
  have observations at every delta_t. So, I possibly can't ignore the
  timestamps.
 
  I'm also interested to estimate the Hurst exponent for the above series.
  I've installed the fArma package. Again, I'm not sure how to use the above
  series there.
 
  Could someone please help me on this?
 
  --
  Thanks,
  Barun Saha
  JPA
  IIT, Kharagpur
 
  http://pothi.com/pothi/book/barun-saha-swapner-kheya
  http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html
 
 [[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.
 
 
 
 -- 
 Thanks,
 Barun Saha
 JPA
 IIT, Kharagpur
 
 http://pothi.com/pothi/book/barun-saha-swapner-kheya
 http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html
 

[[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] recommended way to group function calls in Sweave

2012-04-25 Thread Rainer Schuermann
What I usually do when I have to write a report with some functions I use 
multiple times is that I put them in a separate file (call it setup.Rnw or 
so).

The first chunk there loads the libraries, sets initial variable values etc:

echo=FALSE, results=hide=
library(  xtable )
d - iris
ind - 1
@

Then I have a number of chunks that are not evaluated at this point:

chunk_name_1,eval=FALSE,echo=FALSE=
summary(d[ , ind])
cor(d[ , ind])
@

chunk_name_2,eval=FALSE,echo=FALSE=
# produce a nice table from some data
@

In my master file, I load these definitions first

SweaveInput( setup.Rnw )

and from here, I can suse the named chunks almost like function calls, as you 
you describe below. The advantage (for me) is that I have only one place where 
I maintain the functions code, and only one line in the real document, 
rather than a lot of code, possibly distributed over the document..

Rgds,
Rainer




On Wednesday 25 April 2012 16:20:13 Liviu Andronic wrote:
 On Wed, Apr 25, 2012 at 3:41 PM, Duncan Murdoch
 murdoch.dun...@gmail.com wrote:
  I would use the last method, or if the calls were truly repetitive (i.e.
  always identical, not just the same pattern), use a named chunk.
 
 Labeled chunks are indeed what I was looking for [1]. As far as I
 understand, this is what Sweave functions (or are these macros?)
 look like:
 
 
 =
 d - iris
 ind - 1:2
 @
 
 sw=
   summary(d[ , ind])
   cor(d[ , ind])
 @
 
 =
 d - iris
 ind - 2:4
 sw
 @
 
 
 Regards
 Liviu
 
 [1] vignette('Sweave', 'utils')
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Splitting data into test and train (80:20) kepping attributes similar

2012-04-25 Thread Jessica Streicher
Don't know whats wrong there (except if you're using the eclipse R plugin on a 
mac like me and the window for choosing the download site doesn't pop up..  did 
it?^^)

Anyway, you could just split all of your data into 2 datasets, one that has all 
the data labeled 0, the other for all labeled 1, then take a random 80% of 
both, put them back together into the 80% data, and put the rest back together 
to form the 20%.

Since i don't know your data, heres an example:
M-cbind(c(rep(0,10),rep(1,10)),1:20)
 M
  [,1] [,2]
 [1,]01
 [2,]02
 [3,]03
 [4,]04
 [5,]05
 [6,]06
 [7,]07
 [8,]08
 [9,]09
[10,]0   10
[11,]1   11
[12,]1   12
[13,]1   13
[14,]1   14
[15,]1   15
[16,]1   16
[17,]1   17
[18,]1   18
[19,]1   19
[20,]1   20

index1-which(M[,1]==1)
 index1
 [1] 11 12 13 14 15 16 17 18 19 20

 M1-M[index1,]
 M1
  [,1] [,2]
 [1,]1   11
 [2,]1   12
 [3,]1   13
 [4,]1   14
 [5,]1   15
 [6,]1   16
 [7,]1   17
 [8,]1   18
 [9,]1   19
[10,]1   20

 M0-M[-index1,]
 M0
  [,1] [,2]
 [1,]01
 [2,]02
 [3,]03
 [4,]04
 [5,]05
 [6,]06
 [7,]07
 [8,]08
 [9,]09
[10,]0   10

 s1-sample(1:dim(M1)[1],0.8*dim(M1)[1])
 s1
[1] 10  3  5  9  2  6  8  7

 s0-sample(1:dim(M0)[1],0.8*dim(M0)[1])
 s0
[1]  8 10  9  3  7  4  2  1

 data80-rbind(M1[s1,],M0[s0,])
 data80
  [,1] [,2]
 [1,]1   20
 [2,]1   13
 [3,]1   15
 [4,]1   19
 [5,]1   12
 [6,]1   16
 [7,]1   18
 [8,]1   17
 [9,]08
[10,]0   10
[11,]09
[12,]03
[13,]07
[14,]04
[15,]02
[16,]01

 data20-rbind(M1[-s1,],M0[-s0,])
 data20
 [,1] [,2]
[1,]1   11
[2,]1   14
[3,]05
[4,]06


which is probably not how you really do things efficiently, but it should work.

greetings
Jessi


Am 25.04.2012 um 17:18 schrieb Dwaipayan Dasgupta:

 Thank you so much for replying. I tried what you said but it still throws the 
 same error i.e could not find function sample.split
 Might be because of the version of R I am running (R version 2.12.2).i do not 
 have admin rights to upgrade to the newest version.
 Is there anything else I can try? Im trying to split my data into 80:20 
 keeping the ratio of 0,1 in the Y variable(binary) constant.
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Jessica Streicher
 Sent: Wednesday, April 25, 2012 7:17 PM
 To: r-help@r-project.org
 Subject: Re: [R] Splitting data into test and train (80:20) kepping 
 attributes similar
 
 Well, it throws an error, because there is no such function in default R. A 
 bit of googling showed it might be the one in the caTools package.
 
 execute this:
 install.packages(caTools)
 library(caTools)
 
 before executing your code
 
 
 Am 25.04.2012 um 12:39 schrieb Dwaipayan Dasgupta:
 
 Hi,
 Could someone help me with this please , im trying to use 
 Y = Attrition_data[,1] # extract labels from the data 
 msk = sample.split (Y, SplitRatio=3/4)
 table(Y,msk) 
 to do the splitting but it keeps throwing up and error 
 Error: could not find function sample.split
 Could you please help
 
 Thanks in advance
 doy
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf Of Dwaipayan Dasgupta
 Sent: Tuesday, April 24, 2012 9:08 PM
 To: r-help@r-project.org
 Subject: [R] Splitting data into test and train (80:20) kepping attributes 
 similar
 
 Hi,
 I am trying to do some predictive modeling around attrition and want to 
 split the dataset into test and train (80:20) and keep the ratio of 
 attritees:non attrites same.
 In my dataset the attrition indicator is coded as 0(for non-attritees) and 1 
 (for attritees) and I want to keep the ratio of 0's to 1 similar.
 I apologize for this trivial question but this is my second week with R.
 
 Thanks,
 Doy
 
 
 
 
 
 American Express made the following annotations on Tue Apr 24 2012 08:38:50 
 
 **
 
 This message and any attachments are solely for the intended recipient and 
 may contain confidential or privileged information. If you are not the 
 intended recipient, any disclosure, copying, use, or distribution of the 
 information included in this message and any attachments is prohibited. If 
 you have received this communication in error, please notify us by reply 
 e-mail and immediately and permanently delete this message and any 
 attachments. Thank you. 
 
 American Express a ajouté le commentaire suivant le Tue Apr 24 2012 08:38:50 
 
 Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
 destinataire indiqué et peuvent renfermer des renseignements confidentiels 
 et privilégiés. Si vous n'êtes pas le destinataire 

[R] pca biplot.princomp has a bug?

2012-04-25 Thread Michael
x=rmvnorm(2000, rep(0, 6), diag(c(5, rep(1,5
x=scale(x, center=T, scale=F)
pc - princomp(x)
biplot(pc)

There are a bunch of red arrows plotted, what do they mean? I knew that the
first arrow labelled with Var1 should be pointing the most varying
direction of the data-set (if we think them as 2000 data points, each being
a vector of size 6). I also read from somewhere, the most varying direction
should be the direction of the 1st eigen vector.

However, reading into the code of biplot in R. The line about the arrows is:

 if(var.axes)
  arrows(0, 0, y[,1L] * 0.8, y[,2L] * 0.8, col = col[2L],

Where `y` is the actually the loadings matrix, which is the eigenvector
matrix. So it looks like the 1st arrow is actually pointing from `(0, 0)`
to `(y[1, 1], y[1, 2])`. I understand that we are trying to plot a high
dimensional arrow onto a 2D plane. That's why we are taking the 1st and 2nd
element of the `y[1, ]` vector. However what I don't understand is:

Shouldn't the 1st eigenvector direction be the vector denoted by `y[, 1]`,
instead of `y[1, ]`?  (Again, here `y` is the eigenvector matrix, obtained
by PCA or by eigendecomposition of `t(x) %*% x`.) i.e. the eigenvectors
should be column vectors, not those horizontal vectors.

Even though we are plotting them on 2D plane, we should draw the 1st
direction to be from `(0, 0)` pointing to `(y[1, 1], y[2, 1])`?



I think the R code biplot.princomp has a bug: the loading matrix
(eigenvector matrix) should be transposed before being sent into
biplot.princomp... Any thoughts?

[[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] RODBC Error Code 202 on Mac OS X 10.6

2012-04-25 Thread Marc Schwartz
On Apr 25, 2012, at 10:03 AM, julia.jacob...@arcor.de wrote:

 Hello everybody out there using the RODBC package,
 
 On my linux (unixODBC) and windows machines, I can successfully use the RODBC 
 package to connect to a PostgreSQL databse.
 On my Mac Book running Mac OS X 10.6 (Intel 64bit architecture), I get the 
 error code 202 and message ? when I try to establish an connection by 
 using
 con - odbcConnect(dsn=MyDataSource,UID=Me,pwd=secret)
 Could anyone please hint me towards additional diagnostics I can run to pin 
 down the problem?
 I have the latest versions of unixODBC and psqlODBC installed from Macports.
 They seem to be okay, because
 $isql dsn uid pwd
 works fine to connect to the database.
 
 Thanks in advance for your help,
 Julia


Anytime Fink or MacPorts comes into the picture, I get uncontrollable 
shakes...never had good luck with them when I moved to OSX from Linux three 
years ago and they really screwed up my MacBook Pro, conflicting with all kinds 
of stuff. If I needed something, I always go to the upstream source.

I can't seem to locate an error code 202 in any ODBC documentation. Is the 
above a direct copy and paste of the _complete_ error message?

That being said, do you know if the MacPorts installs are 32 bit, 64 bit or 
both? The entire tool chain, including unixODBC, the ODBC driver and R must all 
be of the same architecture, or you get conflicts. Check to see which version 
of R you are running by using:

  .Machine$sizeof.pointer

If it comes back with 8, you are running 64 bit R, if 4, then 32 bit R. 

Runnning:

  vignette(RODBC)

will bring up additional installation and other relevant details on using 
RODBC, including pointers to Actual Technologies:

  http://www.actualtech.com/products.php

which provides relatively inexpensive commercial ODBC drivers for OSX and which 
is what I use to access Oracle on OSX, using RODBC. You would want:

  http://www.actualtech.com/product_opensourcedatabases.php

They are easy to install and configure and also provide the ODBC Manager app, 
which replaces the no longer included Apple ODBC Administrator app.

Also, you should post this query (now follow ups) to R-SIG-DB, as that list is 
focused on DB access related issues:

  https://stat.ethz.ch/mailman/listinfo/r-sig-db

Regards,

Marc Schwartz

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


Re: [R] R shell script

2012-04-25 Thread mlell08
On 25.04.2012 17:12, Steve Lianoglou wrote:
 Check out the vignette for the optparse library:

 http://cran.r-project.org/web/packages/optparse/vignettes/optparse.pdf

 Super helpful library if you plan on making any semi-interesting
 command line scripts w/ R.

 -steve

 On Wed, Apr 25, 2012 at 6:47 AM, aoife doherty
 aoife.m.dohe...@gmail.com wrote:
 Hey guys,
 Does anyone have an example of a REALLY simple shell script in R.

 Basically i want to run this command:

 library(MASS)
 wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)

 in a shell script something like this:

 #!/bin/bash
 R
 library(MASS)
 for i in *.out
 do
 wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
 done


 that i can run on a command line this this:
 sh R.sh


 because i've SO many files to run this command on.


 I've been googling, but i'm having trouble of just finding a simple example
 explaining how to make this shell script.

 Any help appreciated :)
 Aoife

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


Hi Aoife
you can use the capture.output function if you want so sent R output to
a file

Regards!

-- 
GnuPG Key:7340821E
http://pgp.mit.edu:11371/pks/lookup?search=0x7340821eop=indexfingerprint=on


[[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] Average for Huge file

2012-04-25 Thread Hassan
Hi, I am a PhD student. Basic knowing R. I have 2 datw files 1st 5min
intervals  the 2nd 1min for a month. My taske is to have 15min average for
all.
This how data look;
Date Pm  FF LL   KK   
HH NNWwDD
01/01/2012 00:00:00  349 120  10 8 1178  
12922005  762
01/01/01/2012 00:00:05 356 119  12 7 1167   1289
1992778
01/01/2012 00:00:10   360 115   15   8  189 
1302 2010   770

--
View this message in context: 
http://r.789695.n4.nabble.com/Average-for-Huge-file-tp4586926p4586926.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] transforming data based on factors in a dataframe

2012-04-25 Thread Carly Huitema
Hello R-help list,

I would really appreciate help with my factoring problem.

My generated data is this:

df - expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2))
df$curve - as.factor(rep(1:6, each=length(seq(10,80, by=5
df$counts - 3*df$T/df$conc + rnorm(df$T,0,2)

plot(counts~T, df)


What I would like to do add a new column to the dataframe of zeroed
data (say df$counts.zeroed). For each curve (designated by factor
df$curve) I want to take the value in counts and subtract the minimum
value for that curve. However, I don't really have an idea of how to
approach this problem and haven't found anything in my searches.

And just as a second question, my second line of code assigns the
factors, but if there is a nicer way of doing this I would really
appreciate knowing how.

Thanks for any help!
Carly

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

2012-04-25 Thread rafitoariaz
Hi everybody. I'm making a confidence interval plot using the function
plotCI. I would like to decrease the space between the lines. How can I do
that? Thanks alot 

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-confidence-interval-graphics-tp4587052p4587052.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] Help on time series Hurst exponent

2012-04-25 Thread Barun Saha
Thanks, Michael! Could you plz point to some easy tutorials regarding this?

On Wed, Apr 25, 2012 at 8:14 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 You really don't want to use ts() -- if you want to use the tools in
 fArma use a timeSeries (provided by the package of the same name)

 Michael

 On Wed, Apr 25, 2012 at 9:54 AM, Barun Saha barun.sah...@gmail.com
 wrote:
  Hello,
 
  I'm an absolute beginner with R. I'm hoping to do some time-series
 analysis
  on my data. The data looks like
  #time value
  18 153
  20 426
  70 7
  83 130
  84 7
 
  and so on where time could be in seconds or hours or days (not all at the
  same time). How could I import such a file to R and do some simple stuff
  (say plot the values)? As per the tutorials on time series, I could use
 the
  ts() method to import the values (not timestamps). However, one problem
  with my data is that the *time intervals are not regular* -- i.e. I don't
  have observations at every delta_t. So, I possibly can't ignore the
  timestamps.
 
  I'm also interested to estimate the Hurst exponent for the above series.
  I've installed the fArma package. Again, I'm not sure how to use the
 above
  series there.
 
  Could someone please help me on this?
 
  --
  Thanks,
  Barun Saha
  JPA
  IIT, Kharagpur
 
  http://pothi.com/pothi/book/barun-saha-swapner-kheya
  http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html
 
 [[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.




-- 
Thanks,
Barun Saha
JPA
IIT, Kharagpur

http://pothi.com/pothi/book/barun-saha-swapner-kheya
http://delay-tolerant-networks.blogspot.com/p/one-tutorial.html

[[alternative HTML version deleted]]

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


[R] r-square for non-linear regression

2012-04-25 Thread Pierre Grison
Hi,

I saw you discussed about the meaning of the R squared in a nls regression. Do 
you have a source or a quotation please?

kind regards,

Pierre Grison
Tel: 06 01 79 74 22
Mail: pgri...@hotmail.fr




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

2012-04-25 Thread Steve Lianoglou
Hi,

On Wed, Apr 25, 2012 at 11:11 AM, aoife doherty
aoife.m.dohe...@gmail.com wrote:
 Thanks for replying.

 My problem is that i have say 50 input files, that i wanted to run a
 particular command on, get 50 output files, and then when i close R, have
 them in my directory?

 so for example if i say:

R

library(MASS)

list.files(pattern = .out)

sapply(list.files(pattern  = *.out), function(x) wilcox.test ( ... ) )

 send each output to a different file, and save it in such a way that
 when i close R the outputs are still there

 i thought this might be easier in a shell way?

In this case, just make your function write a text file -- you have to
figure out what you want to save and serialize it to text. Or you can
write as many output rds (or rda) files as you do tests, for instance:

filez - list.files(pattern=*.out)
for (f in filez) {
  ## something to load the data in file `f` I presume
  w - wilcox.test(... on the data you loaded ...)

  saveRDS(w, gsub('.out', '.rds', f) ## if you want to save the object
}

or
info - lapply(filez, function(x) {
  ## load the file
  w - wilcox.test(... on the data you loaded ...)
  data.frame(file.name=x, statistic=w$statistic, p.value=w$p.value,
... anything else you want?)
})
result - do.call(rbind, info)
write.table(result, 'wilcox.results.txt', ...)

HTH,
-steve




 On Wed, Apr 25, 2012 at 4:03 PM, R. Michael Weylandt 
 michael.weyla...@gmail.com wrote:

 You can do this in bash but why not just do it in R directly? You probably
 need

 list.files(pattern = .out)

 to get started. Then just wrap your script in a function and pass it
 to (s|l)apply something like:

 sapply(list.files(pattern  = *.out), function(x) wilcox.test ( ... ) )

 Michael

 On Wed, Apr 25, 2012 at 6:47 AM, aoife doherty
 aoife.m.dohe...@gmail.com wrote:
  Hey guys,
  Does anyone have an example of a REALLY simple shell script in R.
 
  Basically i want to run this command:
 
  library(MASS)
 
 wilcox.test(list1,list2,paired=TRUE,alternative=c(greater),correct=TRUE,exact=FALSE)
 
  in a shell script something like this:
 
  #!/bin/bash
  R
  library(MASS)
  for i in *.out
  do
  wilcox.test($i,${i/out}.out2,paired=TRUE)  $i.out
  done
 
 
  that i can run on a command line this this:
  sh R.sh
 
 
  because i've SO many files to run this command on.
 
 
  I've been googling, but i'm having trouble of just finding a simple
 example
  explaining how to make this shell script.
 
  Any help appreciated :)
  Aoife
 
         [[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.



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 insert filename as column in a file

2012-04-25 Thread Shivam
Thanks Jeff. I had tried the 'list' approach as well but got stuck with the
below error:

Error in `$-.data.frame`(`*tmp*`, date, value = 20100701) :
  replacement has 1 rows, data has 0

Couldnt find a work around to this, hence resorted to the multiple
dataframes approach. Any insights into this?


On Tue, Apr 24, 2012 at 9:51 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote:

 Programatically dealing with large numbers of separately-named objects
 leads to syntactically complicated code that is hard to read and maintain.

 Load the data frames into a list so you can access them by numeric or
 named index, and then getting at the loaded data will be much easier.

 fnames = list.files(path = getwd())
 # preallocating the list for efficiency (execution speed)
 dtalist - vector( list, length(fnames) )
 for (i in seq_len(length(fnames))){
  dtalist[[i]] - read.csv.sql(fnames[i], sql = select * from file where
 V3 == 'XXX' and V5=='YYY',header = FALSE, sep= '|', eol =\n))
  dtalist[[i]]$date -  substr(fnames[i],1,8))
 }
 names(dtalist) - fnames
 # now you can optionally refer to dtalist$file20120424.csv or
 dtalist[[file20120424]] if you wish.
 ---
 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.



 Shivam shivamsi...@gmail.com wrote:

 Reposting in hope of a reply.
 
 On Tue, Apr 24, 2012 at 1:12 AM, Shivam shivamsi...@gmail.com wrote:
 
  Thanks for the quick response. It works for an individual dataframe,
 but I
  have many dataframes. This is the code so far
 
  fnames = list.files(path = getwd())
  for (i in 1:length(fnames)){
  assign(paste(file,i,sep=),read.csv.sql(fnames[i], sql = select *
 from
  file where V3 == 'XXX' and V5=='YYY',header = FALSE, sep= '|', eol =
 \n))
  }
 
  This generates dataframes named as as file1,file2,...,file250. Is
 there a
  way to do something like below within the same loop?
 
  file1$date = substr(fnames[1],1,8))
  file2$date = substr(fnames[2],1,8))
  .
  .
  file250$date = substr(fnames[250],1,8))
 
  assign(paste(file,i,sep=)$date doesnt work.
 
  Any help?
 
 
 
 
 
  On Tue, Apr 24, 2012 at 12:01 AM, MacQueen, Don
 macque...@llnl.govwrote:
 
  This little example might help.
 
   foo - data.frame(a=1:10, b=letters[1:0])
   foo
 a b
  1   1 a
  2   2 a
  3   3 a
  4   4 a
  5   5 a
  6   6 a
  7   7 a
  8   8 a
  9   9 a
  10 10 a
   foo$date - '20120423'
   foo
 a b date
  1   1 a 20120423
  2   2 a 20120423
  3   3 a 20120423
  4   4 a 20120423
  5   5 a 20120423
  6   6 a 20120423
  7   7 a 20120423
  8   8 a 20120423
  9   9 a 20120423
  10 10 a 20120423
 
 
  In other words, immediately after reading the data into a data
 frame, add
  a date column as in the example. You'll have to extract the date
 from the
  filename, of course.
 
  -Don
 
 
  --
  Don MacQueen
 
  Lawrence Livermore National Laboratory
  7000 East Ave., L-627
  Livermore, CA 94550
  925-423-1062
 
 
 
 
 
  On 4/23/12 9:29 AM, Shivam shivamsi...@gmail.com wrote:
 
  Hi,
  
  I am relatively new to R. Have scourged the help files and the www
 but
  havent been able to get a solution.
  
  I have around 250 csv files, one file for each date. They have
 columns of
  all types, numeric, string etc. The name of each file is the date
 in the
  form of 'mmdd'. There is no column within the file which helps
 me
  identify the date on which the file was generated, only the
 filename has
  that info.
  
  I am selecting some data (using read.csv.sql) from each file and
 creating
  a
  dataset for each day. Ultimately I will combine all the datasets. I
 can
  accomplish the select and combine part, but after combining I wont
 have a
  record as to the date corresponding to the data.
  
  Hence I want to insert the filename as a column in the respective
 file to
  help me in identifying to what date each data row belongs to.
  
  Sorry for the long mail, but wanted to make myself clear. Any help
 would
  be
  greatly appreciated.
  
  Thanks in advance,
  Shivam
  
 [[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.
 
 
 
 
  --
  *Victoria Concordia Crescit*
 
 
 
 
 --
 *Victoria Concordia Crescit*
 
[[alternative HTML version deleted]]
 
 __
 

Re: [R] r-square for non-linear regression

2012-04-25 Thread Bert Gunter
This question has been asked many times before. Please search the archives.

The short answer is: R-squared is more or less meaningless in
nonlinear regression. The archives provide elaboration and caveats to
this claim.

-- Bert

On Wed, Apr 25, 2012 at 8:12 AM, Pierre Grison pgri...@hotmail.fr wrote:
 Hi,

 I saw you discussed about the meaning of the R squared in a nls regression. 
 Do you have a source or a quotation please?

 kind regards,

 Pierre Grison
 Tel: 06 01 79 74 22
 Mail: pgri...@hotmail.fr




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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread jim holtman
try this:  (uses 'ave')

 df - expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2))
 df$curve - as.factor(rep(1:6, each=length(seq(10,80, by=5
 df$counts - 3*df$T/df$conc + rnorm(df$T,0,2)

 plot(counts~T, df)
 df$zero - ave(df$counts, df$curve, FUN = function(x) x - min(x))

 df
T conc curve  counts   zero
1  101 1  30.4148210   0.00
2  151 1  43.2169594  12.802138
3  201 1  64.3876491  33.972828
4  251 1  75.2957249  44.880904
5  301 1  95.4479888  65.033168
6  351 1 103.5814348  73.166614
7  401 1 121.0131061  90.598285
8  451 1 135.8270827 105.412262
9  501 1 152.7179565 122.303136
10 551 1 165.2928662 134.878045
11 601 1 181.1899238 150.775103
12 651 1 197.8600462 167.445225
13 701 1 210.0112723 179.596451
14 751 1 224.1807064 193.765885
15 801 1 237.5717249 207.156904
16 103 2   8.2411801   0.00
17 153 2  14.7415660   6.500386
18 203 2  20.9944483  12.753268
19 253 2  23.4369433  15.195763


On Wed, Apr 25, 2012 at 10:57 AM, Carly Huitema carly.huit...@gmail.com wrote:
 Hello R-help list,

 I would really appreciate help with my factoring problem.

 My generated data is this:

 df - expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2))
 df$curve - as.factor(rep(1:6, each=length(seq(10,80, by=5
 df$counts - 3*df$T/df$conc + rnorm(df$T,0,2)

 plot(counts~T, df)


 What I would like to do add a new column to the dataframe of zeroed
 data (say df$counts.zeroed). For each curve (designated by factor
 df$curve) I want to take the value in counts and subtract the minimum
 value for that curve. However, I don't really have an idea of how to
 approach this problem and haven't found anything in my searches.

 And just as a second question, my second line of code assigns the
 factors, but if there is a nicer way of doing this I would really
 appreciate knowing how.

 Thanks for any help!
 Carly

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



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

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


Re: [R] transforming data based on factors in a dataframe

2012-04-25 Thread David Winsemius


On Apr 25, 2012, at 10:57 AM, Carly Huitema wrote:


Hello R-help list,

I would really appreciate help with my factoring problem.

My generated data is this:

df - expand.grid(T=seq(10,80, by=5), conc=rep(c(1, 3, 7), 2))
df$curve - as.factor(rep(1:6, each=length(seq(10,80, by=5



df$counts - 3*df$T/df$conc + rnorm(df$T,0,2)

plot(counts~T, df)


What I would like to do add a new column to the dataframe of zeroed
data (say df$counts.zeroed). For each curve (designated by factor
df$curve) I want to take the value in counts and subtract the minimum
value for that curve.


translated to R that request would be something along these minimally  
tested lines:


df$counts.zeroed - with( df, ave(counts, curve, FUN=function(x){ x- 
min(x) }) )



However, I don't really have an idea of how to
approach this problem and haven't found anything in my searches.

And just as a second question, my second line of code assigns the
factors, but if there is a nicer way of doing this I would really
appreciate knowing how.


There is a `gl` function that I think creates grouping factors, but I  
generally use `rep` because I understand it better.




Thanks for any help!
Carly

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

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


Re: [R] fill a dataframe with zeros where the rows are a smaller subset of a larger dataframe (species by site)

2012-04-25 Thread Stephen Sefick

Thank you all very much, that did the trick.

Stephen

On Wed 25 Apr 2012 09:59:38 AM CDT, Sarah Goslee wrote:

The clarification helps; the original description was rather terse.

What about:


row- c(a,b,c,d,e,f,g) #rows from larger data frame

x- data.frame(sp1=rnorm(4), sp2=rnorm(4), sp3=rnorm(4), sp4=rnorm(4))

rownames(x)- row.1

merge(x, matrix(row, ncol=1), by.x=0, by.y=1, all=TRUE)

   Row.namessp1sp2sp3sp4
1 a  0.4964272  1.4989159  0.4302415  0.9648854
2 b  1.4137142  0.9430609  0.0728391 -0.6275084
3 c -0.8103023 -1.3375148 -0.3799518  0.4523287
4 d NA NA NA NA
5 e NA NA NA NA
6 f NA NA NA NA
7 g -0.1914184  0.5156566  0.5626614  0.8068154

Sarah

On Wed, Apr 25, 2012 at 10:42 AM, Stephen Seficksas0...@auburn.edu  wrote:

I am subsetting a larger data frame that contains macroinverterate taxa.  I
am subsetting them at different levels of taxonomic resolution.  Some of the
sites do not have say Tipulidae present, so the rows are removed completely
for this site.  I would like to fill in the sites that were removed during
the subsetting and fill these with 0.  I have the non-subsetted dataframe
which contains all of the sites.  I would like to use the sites from this
complete data set to expand the dataframe that is a subset of the sites in
the original.  Is that more clear.

Stephen



--
Stephen Sefick
**
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**
sas0...@auburn.edu
http://www.auburn.edu/~sas0025
**

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


   -K. Mullis

A big computer, a complex algorithm and a long time does not equal 
science.


 -Robert Gentleman

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

2012-04-25 Thread R. Michael Weylandt michael.weyla...@gmail.com
http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf

A new paper out on R the language -- I'm not all the way through it but it's 
been an interesting read so far. Thought it might be of interest to the list. 

Michael Weylandt
[[alternative HTML version deleted]]

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


Re: [R] Using apply() with a function involving ode()

2012-04-25 Thread Adam Zeilinger

Dear Berend,

Yes, the wnv.sim function should have included wnv.model instead of 
wnv.incubation.  Sorry for the typo.


Although I had inspected the expand.grid() object, I had not connected 
the error with a naming problem.  Thanks so much for the help!  The 
function works perfectly.


Sincerely,
Adam


On 4/25/2012 2:02 AM, Berend Hasselman wrote:

See inline comments.

On 25-04-2012, at 08:40, Adam Zeilinger wrote:


Hello,

I am trying to get the output from the numerical simulation of a system of 
ordinary differential equations for a range of values for three parameters.  I 
am using the ode() function (deSolve package) to run the numerical simulation 
and apply() to run the simulation function for each set of parameter values.  I 
am having trouble getting the apply() function to work.

Here is an example.  Consider an epidemiology model of West Nile Virus:

wnv.model- function(Time, State, Pars){
  with(as.list(c(State, Pars)), {
dSB- -(alphaB*betaB*SB*IM)/(SB + IB)
dIB- (alphaB*betaB*SB*IM)/(SB + IB) - deltaB*IB
dSM- bM*(SM + EM + IM) - (alphaM*betaB*IB*SM)/(SB + IB) - 
dM*SM
dEM- (alphaM*betaB*SM*IB)/(SB + IB) - kappaM*EM - dM*EM
dIM- kappaM*EM - dM*IM
return(list(c(dSB, dIB, dSM, dEM, dIM)))
  })
}

# I would like to run a numerical simulation of this model for each combination 
of values for the parameters alphaB, betaB, # and kappaM:

av- seq(0, 1, by = 0.2) # vector of values for alphaB
bv- seq(0, 1, by = 0.2) # vector of values for betaB
kv- seq(0, 1, by = 0.2) # vector of values for kappaM

# Here is my function with ode() for the numerical simulation.  The function returns the last value 
of the simulation for the # IB state variable (Infected Birds).

library(deSolve)
wnv.sim- function(x){
 Pars- c(alphaB = x[1], betaB = x[2], deltaB = 0.2, bM = 0.03, dM = 
0.03, alphaM = 0.69, kappaM = x[3])
 State- c(SB = 100, IB = 0, SM = 1500, EM = 0, IM = 0.0001)
 Time- seq(0, 60, by = 1)
 model.out- as.data.frame(ode(func = wnv.incubation,

There is no function wnv.incubation.
Assuming you mean wnv.model


   y = State,
   parms = Pars,
   times = Time))
 model.out[nrow(model.out),]$IB
}

# Finally, here is my apply() function:
dat- apply(expand.grid(av, bv, kv), 1, wnv.sim)

However, the apply() function returns an error:
Error in eval(expr, envir, enclos) : object 'alphaB' not found

Have you inspected the object returned by expand.grid?
Do head(expand.grid(av,bv,kv))
and you will see that the columns have names which confuse the rest of your 
code.

I was able to repair by doing

pars.grid- expand.grid(av, bv, kv)
names(pars.grid)- NULL
dat- apply(pars.grid, 1, wnv.sim)

HTH,

Berend


--
Adam Zeilinger
Post Doctoral Scholar
Department of Entomology
University of California Riverside
www.linkedin.com/in/adamzeilinger

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


Re: [R] pca biplot.princomp has a bug?

2012-04-25 Thread Kevin Wright
The arrows are not pointing in the most-varying direction of the data.  The
principal components are pointing in the most-varying direction of the
data.  But you are not plotting the data on the original scale, you are
plotting the data on the rotated scale, and thus the horizontal axis is the
most-varying direction of the data.

The arrows are pointing in the direction of the variables, as projected
into the 2-d plane of the biplot.

There is no bug.

Kevin Wright



On Wed, Apr 25, 2012 at 11:29 AM, Michael comtech@gmail.com wrote:

x=rmvnorm(2000, rep(0, 6), diag(c(5, rep(1,5
x=scale(x, center=T, scale=F)
pc - princomp(x)
biplot(pc)

 There are a bunch of red arrows plotted, what do they mean? I knew that the
 first arrow labelled with Var1 should be pointing the most varying
 direction of the data-set (if we think them as 2000 data points, each being
 a vector of size 6). I also read from somewhere, the most varying direction
 should be the direction of the 1st eigen vector.

 However, reading into the code of biplot in R. The line about the arrows
 is:

  if(var.axes)
  arrows(0, 0, y[,1L] * 0.8, y[,2L] * 0.8, col = col[2L],

 Where `y` is the actually the loadings matrix, which is the eigenvector
 matrix. So it looks like the 1st arrow is actually pointing from `(0, 0)`
 to `(y[1, 1], y[1, 2])`. I understand that we are trying to plot a high
 dimensional arrow onto a 2D plane. That's why we are taking the 1st and 2nd
 element of the `y[1, ]` vector. However what I don't understand is:

 Shouldn't the 1st eigenvector direction be the vector denoted by `y[, 1]`,
 instead of `y[1, ]`?  (Again, here `y` is the eigenvector matrix, obtained
 by PCA or by eigendecomposition of `t(x) %*% x`.) i.e. the eigenvectors
 should be column vectors, not those horizontal vectors.

 Even though we are plotting them on 2D plane, we should draw the 1st
 direction to be from `(0, 0)` pointing to `(y[1, 1], y[2, 1])`?



 I think the R code biplot.princomp has a bug: the loading matrix
 (eigenvector matrix) should be transposed before being sent into
 biplot.princomp... Any thoughts?

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




-- 
Kevin Wright

[[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] On the Design of the R Language

2012-04-25 Thread Thomas Adams
Hmmm… an 'objective' assessment? Maybe. But it looks to me that some
commercial enterprise paid for this study as a means to argue against the
use of R in favor of a commercial package…

On Wed, Apr 25, 2012 at 1:48 PM, R. Michael Weylandt 
michael.weyla...@gmail.com michael.weyla...@gmail.com wrote:

 http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf

 A new paper out on R the language -- I'm not all the way through it but
 it's been an interesting read so far. Thought it might be of interest to
 the list.

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




-- 

Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  thomas.ad...@noaa.gov
VOICE:  937-383-0528
FAX:937-383-0033

[[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] locate values to their positions based on their pixel and line in other files

2012-04-25 Thread Amen
I have 3 files A ,B ,C as binary files. C represents the values of tepm
measured every 3 hours for one month so it has 674200 columns and 248
rows.values of A represent the correspond lines(these values could be within
1to360) and , while values of B represent the correspond pixel(1to720) for
each point in file C(so both they have 1 row and 67420rows).Now I will
create a new matrix ,M ,which has this dim(360,720).for example the first
value in C it will be represented in the creatd matrix based on the
corspding pixl and lines.assume the first value is 54(row 1 and column 1)in
C so in order to locate it in my new matrix we need to know what its pixl
and line that this point shoud be assocated with ,therfore I need to tell R
that take its pixl value from A and its line from B and locate it in my new
matrix. this is to be done for first row out of 248 rows and write it to new
file then do the same for the second row and write to a new file and so on
for all 248 rows.

 library(Matrix)
 M - Matrix(-, 360, 720)## creat matrix with 720 columns and 360 rows
with valus of -
 long - file(C:\\New folder (5)\\inra.bin, rb)
  A=readBin(long, integer(), size=2,n=1*67420, signed=TRUE)
lot - file(C:\\New folder (5)\\lat.img, rb)
  B=readBin(lot, integer(), size=2,n=1*67420, signed=TRUE)

   for (i in c(1:67420)) {
   wind - file(C:\\Wind_WFD_200201.bin, rb)
C=readBin(wind, integer(), size=2,n=248*67420, signed=TRUE)##it has 67420
columns and 248 rows
M(A(i),B(i))= C(i)}
I wrote the above code but didn't work.I am so sorry for this long
description and thanks in advance

--
View this message in context: 
http://r.789695.n4.nabble.com/locate-values-to-their-positions-based-on-their-pixel-and-line-in-other-files-tp4587563p4587563.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] On the Design of the R Language

2012-04-25 Thread Marc Schwartz
I have not read it yet, but the acknowledgements at the end of the paper note 
that:

1. It was supported by an NSF grant.

2. At least two members of R Core are recognized amongst the list of names.

Regards,

Marc Schwartz

On Apr 25, 2012, at 1:07 PM, Thomas Adams wrote:

 Hmmm∑ an 'objective' assessment? Maybe. But it looks to me that some
 commercial enterprise paid for this study as a means to argue against the
 use of R in favor of a commercial package∑
 
 On Wed, Apr 25, 2012 at 1:48 PM, R. Michael Weylandt 
 michael.weyla...@gmail.com michael.weyla...@gmail.com wrote:
 
 http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf
 
 A new paper out on R the language -- I'm not all the way through it but
 it's been an interesting read so far. Thought it might be of interest to
 the list.
 
 Michael Weylandt
   [[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] Equate two (or more) functions

2012-04-25 Thread pannigh
Dear List,
I was wondering if there is a simple way to solve (equate) two functions in
R. For example:

(1) 5x + 3y = 30
(2) 12x - 2y = 26

I would like R to finde x = 3 and y = 5
Is there an implemented function in R or would I have to write an own
function?

Thank you very much for your help.
 

--
View this message in context: 
http://r.789695.n4.nabble.com/Equate-two-or-more-functions-tp4587302p4587302.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] Average for Huge file

2012-04-25 Thread rafitoariaz
Hi. I would use the function aggregate, but first you will have to tag each
row with a special code so R can recognize the group of data and apply the
function you desire. For example, with your data I would do this:

Date Pm  FF LL  
KKHH NNWwDD  code
 01/01/2012 00:00:00  349 120   10 8 1178  
12922005  762 01_01_2012_1
 01/01/01/2012 00:00:05 356 119   127 1167  
1289 1992778 01_01_2012_1
 01/01/2012 00:00:10   360 115   15   8  189 
1302 2010   770  01_01_2012_1
 01/01/2012 00:00:15  349 120   10 8 1178  
12922005  762 01_01_2012_1
 01/01/01/2012 00:00:20 356 119   127 1167  
1289 1992778 01_01_2012_2
 01/01/2012 00:00:25   360 115   15   8  189 
1302 2010   770  01_01_2012_2
 01/01/2012 00:00:30   360 115   15   8  189 
1302 2010   770  01_01_2012_2

##Then apply the function aggregate
aggregate(name  of the variable you want to obtain the mean,
by=list(variable used for grouping),FUN=mean)
For example, if you want to aggregate Pm by groups of 15 min, you write it
like this
aggregate(Pm,by=list(code),FUN=sum)
and you'll obtain the mean of the rows that have the same code . In this
example, you'll obtain the mean of  two groups: the Pm measurments wich
their labels are 01_01_2012_1 and 01_01_2012_2.
Hope it works

M.C. Luis Antonio Arias Medellín
National Institute of Public Health
Cuernavaca, Morelos, Mexico

--
View this message in context: 
http://r.789695.n4.nabble.com/Average-for-Huge-file-tp4586926p4587482.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] Intercept between two lines

2012-04-25 Thread pannigh
Dear List,
I know this is not the first post on this topic, but I need basic help I
guess. Assuming the simple case of two lines with one intercept, how can I
make R calculate this intercept, NOT using locator().

par (xaxs=i, yaxs=i)
plot( 1, bty=n ,xlim=c(0,300) , ylim=c(0,300) , xlab=X, ylab=Y)
curve(100-0.5*x, -50,250, add=T, col=blue)
curve(150- x   , -50,250, add=T, col=red)

I want R to come up with the coordinates X=100, Y=50.

Thank you for your help!



--
View this message in context: 
http://r.789695.n4.nabble.com/Intercept-between-two-lines-tp4587343p4587343.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] Equate two (or more) functions

2012-04-25 Thread Rui Barradas
Hello,

Try

(x - matrix(c(5, 12, 3, -2), ncol=2))
(y - c(30, 26))

solve(x, y)
solve.qr(qr(x), y)

(Use the second.)
Also, see section 5.7.5 of the R-intro.pdf that comes with your (any)
installation of R.

Hope this helps,

Rui Barradas


--
View this message in context: 
http://r.789695.n4.nabble.com/Equate-two-or-more-functions-tp4587302p4587523.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] Intercept between two lines

2012-04-25 Thread Jorge I Velez
Hi pannigh,

The following might get you started:

 x0 - uniroot(function(x) 100-0.5*x - (150- x), c(0, 150))$root
 x0
[1] 100
 100- 0.5*x0
[1] 50

HTH,
Jorge.-


On Wed, Apr 25, 2012 at 1:01 PM, pannigh  wrote:

 Dear List,
 I know this is not the first post on this topic, but I need basic help I
 guess. Assuming the simple case of two lines with one intercept, how can I
 make R calculate this intercept, NOT using locator().

 par (xaxs=i, yaxs=i)
 plot( 1, bty=n ,xlim=c(0,300) , ylim=c(0,300) , xlab=X, ylab=Y)
curve(100-0.5*x, -50,250, add=T, col=blue)
curve(150- x   , -50,250, add=T, col=red)

 I want R to come up with the coordinates X=100, Y=50.

 Thank you for your help!



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Intercept-between-two-lines-tp4587343p4587343.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] On the Design of the R Language

2012-04-25 Thread peter dalgaard

On Apr 25, 2012, at 20:19 , Marc Schwartz wrote:

 I have not read it yet, but the acknowledgements at the end of the paper note 
 that:
 
 1. It was supported by an NSF grant.
 
 2. At least two members of R Core are recognized amongst the list of names.

Also, most of the overall content is hardly a surprise to R Core (not that I 
have read it properly either). R as a language has many weaknesses and Luke can 
certainly attest the difficulties in writing compilers for R due to the fact 
that semantics can change at any moment (I believe that's what the authors 
refer to as extreme dynamism). 

Competent critical review by computer scientist should be welcomed, and in my 
opinion is long overdue. As has been said, the good _and_ the bad thing about R 
is that it was designed by statisticians...

-pd

 
 Regards,
 
 Marc Schwartz
 
 On Apr 25, 2012, at 1:07 PM, Thomas Adams wrote:
 
 Hmmm∑ an 'objective' assessment? Maybe. But it looks to me that some
 commercial enterprise paid for this study as a means to argue against the
 use of R in favor of a commercial package∑
 
 On Wed, Apr 25, 2012 at 1:48 PM, R. Michael Weylandt 
 michael.weyla...@gmail.com michael.weyla...@gmail.com wrote:
 
 http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf
 
 A new paper out on R the language -- I'm not all the way through it but
 it's been an interesting read so far. Thought it might be of interest to
 the list.
 
 Michael Weylandt
  [[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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] Equate two (or more) functions

2012-04-25 Thread Berend Hasselman

On 25-04-2012, at 18:52, pannigh wrote:

 Dear List,
 I was wondering if there is a simple way to solve (equate) two functions in
 R. For example:
 
 (1) 5x + 3y = 30
 (2) 12x - 2y = 26
 
 I would like R to finde x = 3 and y = 5
 Is there an implemented function in R or would I have to write an own
 function?

And if your functions are nonlinear there is package nleqslv and BB.

Berend

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


Re: [R] On the Design of the R Language

2012-04-25 Thread Bert Gunter
Thanks Michael:
Interesting!

Is it legitimate to comment on this in this list? It would only be my
opinions, not real R-Help stuff. Where would be a better place to post
such UN-expert opinion?

-- Bert


On Wed, Apr 25, 2012 at 10:48 AM, R. Michael Weylandt
michael.weyla...@gmail.com michael.weyla...@gmail.com wrote:
 http://www.cs.purdue.edu/homes/jv/pubs/ecoop12.pdf

 A new paper out on R the language -- I'm not all the way through it but it's 
 been an interesting read so far. Thought it might be of interest to the list.

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Rprofile.site on Windows

2012-04-25 Thread Duncan Murdoch

On 12-04-25 4:04 PM, Trevor Miles wrote:

Thanks Duncan.

The only .site files I have are Reviron.site and Rprofile.site, which
are both in C:\Program Files\R\R-2.14.1\etc.


My advice was about 2.15.0, but I don't remember any of this changing 
recently.




Copying these files to C:\Program Files\R\R-2.14.1\etc\x64 and
C:\Program Files\R\R-2.14.1\etc\i386 makes no difference.

Sys.getenv returns R_ENVIRON =  and R_HOME =
C:/PROGRA~1/R/R-214~1.1. Should I set R_ENVIRON in the Windows Registry?


R_ENVIRON doesn't affect the search for the Rprofile.site file, other 
than defining where to find environment variables.  You want to look at 
R_PROFILE, and possibly set it in your Renviron.site file.


Duncan Murdoch


  Date: Tue, 24 Apr 2012 22:50:21 -0400
  From: murdoch.dun...@gmail.com
  To: trevor.mi...@live.ca
  CC: r-help@r-project.org
  Subject: Re: [R] Rprofile.site on Windows
 
  On 12-04-24 10:43 PM, Duncan Murdoch wrote:
   On 12-04-24 4:13 PM, Trevor Miles wrote:
   Hi All
  
   I am struggling to get R to read the Rprofile.site file from the
R_HOME/etc folder.
  
   I know it isn't working because I change the prompt in the
Rprofile.site file. In addition, when I run
source('R_HOME'/etc/Rprofile.site) from the prompt, the prompt gets
changed and other environmental variables get set.
  
   Any ideas?
  
   I don't think the documentation has completely caught up, but that
would
   now normally be put in R_HOME/etc/i386 or R_HOME/etc/x64, depending
   which version you're running.
 
  Sorry, that's not quite right. It will look where R_PROFILE says to
  look, then in the spots mentioned above, but finally will look in
  R_HOME/etc if a file hasn't already been found. So maybe you have
  another Rprofile.site file that is being read instead of your new one.
 
  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] Help confidence interval graphics

2012-04-25 Thread Michael Bibo
rafitoariaz rafitoariaz at hotmail.com writes:

 
 Hi everybody. I'm making a confidence interval plot using the function
 plotCI. I would like to decrease the space between the lines. How can I do
 that? Thanks alot 

There may be a better answer than this, but here goes:

The lines are plotted at 1, 2, 3, 4, etc on the 'categorical' axis, and that
axis automatically displays just the range of values necessary.  So if you have
four confidence intervals plotted, the 'categorical' axis will range from 1 to
4.  You can reduce the distance between the lines by changing the aspect ratio
of your plot device, ie, make the plot narrower along that categorical axis and
the plot will be adjusted accordingly.

Alternatively (or additionally), you can alter the range of the categorical
axis, using the xlim or ylim argument (depending on whether your lines run
vertically or horizontally).  By making the range on that axis larger, you
create more 'white space' at each end of the scale and the lines cluster
together in the centre more.

Note that you can also customise your axes with axis(), like other plots.


Hope this helps,

Michael Bibo
Queensland Health

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


Re: [R] Re : Design of experiments for Choice-Based Conjoint Analysis (CBC)

2012-04-25 Thread jhelvy
Hi,

I came across this paper which is essentially a tutorial on how to generate
designs in R using the AlgDesign package. Hope it's helpful. 

I'm not trying to generate designs in R using priors, but haven't found a
way to do it yet. Anyone out there have any ideas?

Cheers,
John Paul

--
View this message in context: 
http://r.789695.n4.nabble.com/Design-of-experiments-for-Choice-Based-Conjoint-Analysis-CBC-tp2254142p4587666.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] On the Design of the R Language

2012-04-25 Thread Steve Lianoglou
Hi,

On Wed, Apr 25, 2012 at 4:06 PM, Bert Gunter gunter.ber...@gene.com wrote:
 Thanks Michael:
 Interesting!

 Is it legitimate to comment on this in this list? It would only be my
 opinions, not real R-Help stuff.

FWIW, I'd be interested in hearing opinions about it from R-folk ...

 Where would be a better place to post
 such UN-expert opinion?

I didn't realize you were also an expert on foreign affairs?  Nice.

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

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


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-25 Thread Greg Snow
You can also use range( MC.pH, MV.pH, na.rm=TRUE).

On Tue, Apr 24, 2012 at 1:29 PM, David Doyle kydaviddo...@gmail.com wrote:
 Hi Greg,

 Sloved my own problem.

 I had some missing data NA in the datasets.  So I manually entered the
 ylim=range(4,6)
 and it worked!!!

 Thanks!!
 David


 On Tue, Apr 24, 2012 at 1:55 PM, David Doyle kydaviddo...@gmail.com wrote:

 Hi Greg,

 Thanks,

 I got the 1st example to work using the following code:


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)

 par(mfrow=c(2,1))
 scatter.smooth( Year, MC.pH )
 scatter.smooth( Year, MV.pH )


 This is good but what I'm really looking for is to have them on the same
 graph.


 I tried your second example using the code below but got:

 Error in plot.window(...) : need finite 'ylim' values

 here is the code I used


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)


 plot( Year, MC.pH, ylim=range(MC.pH,MV.pH) , col='blue')

 points( Year, MV.pH, col='green' )

 lines( loess.smooth(Year,MC.pH), col='blue')

 lines( loess.smooth(Year,MV.pH), col='green')


 Thanks again

 David



 On Tue, Apr 24, 2012 at 1:45 PM, Greg Snow 538...@gmail.com wrote:

 Assuming that you want event as the x-axis (horizontal) you can do
 something like (untested without reproducible data):

 par(mfrow=c(2,1))
 scatter.smooth( event, pH1 )
 scatter.smooth( event, pH2 )

 or

 plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
 points( event, pH2, col='green' )
 lines( loess.smooth(event,pH1), col='blue')
 lines( loess.smooth(event,pH2), col='green')

 Only do the second one if pH1 and pH2 are measured on the same scale
 in a way that the comparison and any crossings are meaningful or if
 there is enough separation (but not too much) that there is no
 overlap, but still enough detail.



 On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  The scatter plot is easy:
 
  plot(pH1 ~ pH2, data = OBJ)
 
  When you say a loess for each -- how do you break them up? Are there
  repeat values for pH1? If so, this might be hard to do in base
  graphics, but ggplot2 would make it easy:
 
  library(ggplot2)
  ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
  facet_wrap(~factor(pH1))
 
  or something similar.
 
  Michael
 
  On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com
  wrote:
  Hi folks.
 
  If I have the following in my data
 
  event    pH1    pH2
  1            4.0     6.0
  2            4.3     5.9
  3            4.1     6.1
  4            4.0     5.9
  and on and on. for about 400 events
 
  Is there a way I can get R to plot event vs. pH1  and event vs. pH2
  and
  then do a loess or lowess line for each??
 
  Thanks in advance
  David
 
         [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com






-- 
Gregory (Greg) L. Snow Ph.D.
538...@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 to test if a slope is different than 1?

2012-04-25 Thread Greg Snow
Doesn't the p-value from using offset work for you?  if you really
need a p-value.  The confint method is a quick and easy way to see if
it is significantly different from 1 (see Rolf's response), but does
not provide an exact p-value.  I guess you could do confidence
intervals at different confidence levels until you find the level such
that one of the limits is close enough to 1, but that seems like way
to much work.  You could also compute the p-value by taking the slope
minus 1 divided by the standard error and plug that into the pt
function with the correct degrees of freedom.  You could even write a
function to do that for you, but it still seems more work than adding
the offset to the formula.

On Tue, Apr 24, 2012 at 8:17 AM, Mark Na mtb...@gmail.com wrote:
 Hi Greg. Thanks for your reply. Do you know if there is a way to use the
 confint function to get a p-value on this test?

 Thanks, Mark



 On Mon, Apr 23, 2012 at 3:10 PM, Greg Snow 538...@gmail.com wrote:

 One option is to subtract the continuous variable from y before doing
 the regression (this works with any regression package/function).  The
 probably better way in R is to use the 'offset' function:

 formula = I(log(data$AB.obs + 1, 10)-log(data$SIZE,10)) ~
 log(data$SIZE, 10) + data$Y
 formula = log(data$AB.obs + 1) ~ offset( log(data$SIZE,10) ) +
 log(data$SIZE,10) + data$Y

 Or you can use a function like 'confint' to find the confidence
 interval for the slope and see if 1 is in the interval.

 On Mon, Apr 23, 2012 at 12:11 PM, Mark Na mtb...@gmail.com wrote:
  Dear R-helpers,
 
  I would like to test if the slope corresponding to a continuous variable
  in
  my model (summary below) is different than one.
 
  I would appreciate any ideas for how I could do this in R, after having
  specified and run this model?
 
  Many thanks,
 
  Mark Na
 
 
 
  Call:
  lm(formula = log(data$AB.obs + 1, 10) ~ log(data$SIZE, 10) +
    data$Y)
 
  Residuals:
     Min       1Q   Median       3Q      Max
  -0.94368 -0.13870  0.04398  0.17825  0.63365
 
  Coefficients:
                   Estimate Std. Error t value  Pr(|t|)
  (Intercept)        -1.18282    0.09120 -12.970    2e-16 ***
  log(data$SIZE, 10)  0.56009    0.02564  21.846    2e-16 ***
  data$Y2008          0.16825    0.04366   3.854  0.000151 ***
  data$Y2009          0.20310    0.04707   4.315 0.238 ***
  ---
  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 
  Residual standard error: 0.2793 on 228 degrees of freedom
  Multiple R-squared: 0.6768,     Adjusted R-squared: 0.6726
  F-statistic: 159.2 on 3 and 228 DF,  p-value:  2.2e-16
 
         [[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.
 



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com





-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] Accessing a list

2012-04-25 Thread Greg Snow
I believe that fortune(312) applies here.  As my current version of
fortunes does not show this I am guessing that it is in the
development version and so here is what fortune(312) will eventually
print (unless something changes or I got something wrong):

The problem here is that the $ notation is a magical shortcut and like
any other magic if used
incorrectly is likely to do the programmatic equivalent of turning
yourself into a toad.
—Greg Snow (in response to a user that wanted to access a column whose name is
stored in y via x$y rather than x[[y]])
R-help (February 2012)

On Tue, Apr 24, 2012 at 9:42 PM, Jim Silverton jim.silver...@gmail.com wrote:
 Hi,
 I have the following problem- I want to access a list whose elements are
 imp1, imp2, imp3 etc I tried theusing the paste comand in a for loop see
 the last for loop below. But I keep calling it df but df = imp1 (for the
 first run). Any ideas on how I can access the elements of the list?

 Isaac



 require(Amelia)
 library(Amelia)
 data.use - read.csv(multiplecarol.CSV, header=T)
 names(data.use) = c(year, dischargex1, y, pressurex2 , windx3)

 ts - c (c(1:12), c(1:12), c(1:12), c(1:12), c(1:12), c(1:12), c(1:12),
 c(1:6) )
 length(ts)
 data.use = cbind(ts, data.use)

 #a.out2 - amelia(data.use, m = 1000, idvars = year)


 n.times = 100
 a.out.time - amelia(data.use, m = n.times, ts=ts, idvars=year,
 polytime=2)

 constant.col = dischargex1.col = pressurex2.col = windx3.col =
 rep(0,n.times)

 for (i in 1: n.times)
 {
 x = c(imp,i)
 df = paste(x, collapse = )
 data1 = a.out.time[[1]]$df
 attach(data1)
 y = as.numeric(y)
 dischargex1 = as.numeric(dischargex1)
 pressurex2 = as.numeric(pressurex2)
 windx3 = as.numeric(windx3)
 multi.regress = lm(y~ dischargex1 + pressurex2 + windx3)
 constant.col[i] = as.numeric(multi.regress[[1]][1])
 dischargex1.col[i] = as.numeric(multi.regress[[1]][2])
 pressurex2.col[i] = as.numeric(multi.regress[[1]][3])
 windx3.col[i] = as.numeric(multi.regress[[1]][4])
 }


 --
 Thanks,
 Jim.

        [[alternative HTML version deleted]]

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



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


[R] comparison of bivariate normal distributions

2012-04-25 Thread Fabian Roger
sorry for cross-posting

Dear all,

I have tow (several) bivariate distributions with a known mean and 
variance-covariance structure (hence a known density function) that I would 
like to compare in order to get an intersect that tells me something about how 
different these distributions are (as t-statistics for univariate 
distributions).

In order to visualize what I mean hear a little code example:


library(mvtnorm)

c-data.frame(rnorm(1000,5,sd=1),rnorm(1000,6,sd=1))
c2-data.frame(rnorm(1000,10,sd=2),rnorm(1000,7,sd=1))

xx=seq(0,20,0.1)
yy=seq(0,20,0.1)
xmult=cbind(rep(yy,201),rep(xx,each=201))
dens=dmvnorm(xmult,mean(c),cov(c))
dmat=matrix(dens,ncol=length(yy),nrow=length(xx),byrow=F)

dens2=dmvnorm(xmult,mean(c2),cov(c2))
dmat2=matrix(dens2,ncol=length(yy),nrow=length(xx),byrow=F)
contour(xx,yy,dmat,lwd=2)
contour(xx,yy,dmat2,lwd=2,add=T)
##

Is their an easy way to do this (maybe with dmvnorm()?) and could I interpret 
the intersect (shared volume) in the sense of a t-statistic?

Thanks a lot for your help!

_
Fabian Roger, Ph.D. student
Dept of Biological and Environmental Sciences
University of Gothenburg
Box 461
SE-405 30 Göteborg
Sweden
Tel. +46 31 786 2933




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


  1   2   >