[R] Finding root of quadratic equation

2010-11-28 Thread Amy Milano
Dear R Helpers,

I need to find the root of following equation. 

0.0016^2 = (0.001*x)^2 + (0.002 * (1-x))^2 + 2 * 0.7 *0.001*0.002 * x * (1-x).

I had tried using animation  package as follows.



# My Code


library(animation)
ani.options(nmax = 500)


solu = newton.method(function(x) 0.0016^2 - 0.001^2*x^2 - 0.002^2*(1-x)^2 - 
2*0.7*0.001*0.002*x*(1-x), 1, c(-1,1))

solu$root


# However, I am not getting the solution. Please guide.

Amy







  
[[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] Finding root of quadratic equation

2010-11-28 Thread Jorge Ivan Velez
Hi Amy,

Not using animation, but this seems to work:

f - function(x) 0.0016^2 - 0.001^2*x^2 - 0.002^2*(1-x)^2 -
2*0.7*0.001*0.002*x*(1-x)
curve(f, -1, 1)
abline(h = 0, lty = 2, col = 'gray')
uniroot(f, c(-1,1))
abline(v = .3203, lty = 2, col = 2)

HTH,
Jorge


On Sun, Nov 28, 2010 at 3:43 AM, Amy Milano  wrote:

 Dear R Helpers,

 I need to find the root of following equation.

 0.0016^2 = (0.001*x)^2 + (0.002 * (1-x))^2 + 2 * 0.7 *0.001*0.002 * x *
 (1-x).

 I had tried using animation  package as follows.



 # My Code


 library(animation)
 ani.options(nmax = 500)


 solu = newton.method(function(x) 0.0016^2 - 0.001^2*x^2 - 0.002^2*(1-x)^2 -
 2*0.7*0.001*0.002*x*(1-x), 1, c(-1,1))

 solu$root


 # However, I am not getting the solution. Please guide.

 Amy








[[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] Finding root of quadratic equation

2010-11-28 Thread Amy Milano
Dear Jorge Ivan Velez sir,

Thanks a million for your great solution. You have made my Sunday. Thanks again.

Regards

Amy



--- On Sun, 11/28/10, Jorge Ivan Velez jorgeivanve...@gmail.com wrote:

From: Jorge Ivan Velez jorgeivanve...@gmail.com
Subject: Re: [R] Finding root of quadratic equation
To: Amy Milano milano_...@yahoo.com
Cc: R mailing list r-help@r-project.org
Date: Sunday, November 28, 2010, 8:49 AM

Hi Amy,
Not using animation, but this seems to work:


f - function(x) 0.0016^2 - 0.001^2*x^2 - 0.002^2*(1-x)^2 - 
2*0.7*0.001*0.002*x*(1-x)

curve(f, -1, 1)abline(h = 0, lty = 2, col = 'gray')

uniroot(f, c(-1,1))abline(v = .3203, lty = 2, col = 2)


HTH,Jorge

On Sun, Nov 28, 2010 at 3:43 AM, Amy Milano  wrote:


Dear R Helpers,



I need to find the root of following equation.



0.0016^2 = (0.001*x)^2 + (0.002 * (1-x))^2 + 2 * 0.7 *0.001*0.002 * x * (1-x).



I had tried using animation  package as follows.







# My Code





library(animation)

ani.options(nmax = 500)





solu = newton.method(function(x) 0.0016^2 - 0.001^2*x^2 - 0.002^2*(1-x)^2 - 
2*0.7*0.001*0.002*x*(1-x), 1, c(-1,1))



solu$root





# However, I am not getting the solution. Please guide.



Amy

















        [[alternative HTML version deleted]]



__

R-help@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html

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






  
[[alternative HTML version deleted]]

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


[R] Comparing two functions

2010-11-28 Thread Ira Sharenow
Hi. I am new to R and facing a problem that I cannot solve.

 

I am writing some basic functions. Then I would like to have a master function 
that allows me to call one of the functions which I created, but I cannot 
figure out how to do so.

 

Below is an example. The functions rnormIra and runifIra both seem to work 
fine. I do not get an error message when entering the definition of the master 
function randomIra; however, it fails when I use it to call another function.

 

Can someone please help?

 

Thanks.

 

Ira



rnormIra = function(n, mean) {
  return(rnorm(n,mean,1))
}
rnormIra(10,100) #works fine



runifIra = function(n,min,max) {
  return(runif(n,min,max))
}
runifIra(5,20,30) #works fine



randomIra = function(f, ...) {
  if(f == rnormIra) {
   return(rnormIra(n,mean))
  }
  else {
return(runifIra(n,min,max))
  }
} #no error messages



randomIra(rnormIra, n = 5, mean = 20) #FAILS
randomIra(runifIra, n = 5, min = 10, max = 25) #FAILS

do.call(randomIra,list(rnormIra,5,20)) #FAILS


[[alternative HTML version deleted]]

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


Re: [R] How to remove a package.

2010-11-28 Thread Stefan Grosse
Am 27.11.2010 09:48, schrieb Stephen Liu:

 I found the datasets of AER 

cool.

 detach(package:AER, unload = TRUE)

detach(package:AER) works for me.

 data()
 still found car there.

you mean cars ? This is not part of AER but in a base R installation.

 install.packages(EcDat)

 Where can I download/install EcDat?  TIA

It is case sensitive, try install.packages(Ecdat) it works for me...

Maybe you should try a little bit more...

hth
Stefan

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


[R] Where is gdata?

2010-11-28 Thread Stephen Liu
Hi folks,

Win 7 64 bit
R 32 bit

 install.packages(gregmisc)
Installing package(s) into 
‘C:\Users\satimiswin764\Documents/R/win-library/2.12’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependency ‘gmodels’

trying URL 
'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/gmodels_2.15.0.zip'
Content type 'application/zip' length 76016 bytes (74 Kb)
opened URL
downloaded 74 Kb

trying URL 
'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/gregmisc_2.1.1.zip'
Content type 'application/zip' length 97482 bytes (95 Kb)
opened URL
downloaded 95 Kb

package 'gmodels' successfully unpacked and MD5 sums checked
package 'gregmisc' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Users\satimiswin764\AppData\Local\Temp\RtmpP3dNfa\downloaded_packages

Installation went through without problem.


 library(gregmisc)
Loading required package: gmodels
Loading required package: gplots
Loading required package: gtools
Loading required package: caTools
Loading required package: bitops
Loading required package: grid

Attaching package: 'gplots'

The following object(s) are masked from 'package:stats':

lowess

Warning message:

The `gregmisc' *package* has converted into a *bundle*
containing four sub-packages: gdata, gtools, gmodels, and gplots.
Please load these packages directly. 


 library(gdata)
 gdata
Error: object 'gdata' not found

 gdata()
Error: could not find function gdata


Please advise what mistake I have committed.  TIA


B.R.
Stephen L



[[alternative HTML version deleted]]

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


[R] Where to download R .xls sample files?

2010-11-28 Thread Stephen Liu
Hi folks,

Which R packages containing sample .xls files?  TIA

B.R.
Stephen L



[[alternative HTML version deleted]]

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


Re: [R] Where to download R .xls sample files?

2010-11-28 Thread Jinsong Zhao

On 2010-11-28 19:46, Stephen Liu wrote:

Hi folks,

Which R packages containing sample .xls files?  TIA



why do you need .xls format data file?


B.R.
Stephen L




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 load data file without attribute names?

2010-11-28 Thread 44whyfrog

Thank you very much.

What I actually do was


data1 - read.delim(path,head=FALSE,sep=,)
motor_UPDRS -data1[5]
qqnorm(motor_UPDRS)

I eventually noticed that I missed a , in the second command. And I cannot
retrieve a vector correctly.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-load-data-file-without-attribute-names-tp3061489p3062333.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to remove a package.

2010-11-28 Thread Stephen Liu
Hi Stefan,

Tks for your advice.

 detach(package:AER)
 data()

Data sets in package ‘car’:

 detach(package:car)
 data()

Data sets in package ‘datasets’.  I have to run detach twice getting back 
to 
package 'datasets'


 install.packages(Ecdat)
Installing package(s) into 
‘C:\Users\satimiswin764\Documents/R/win-library/2.12’
(as ‘lib’ is unspecified)
trying URL 
'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/Ecdat_0.1-6.zip'
Content type 'application/zip' length 2817531 bytes (2.7 Mb)
opened URL
downloaded 2.7 Mb

package 'Ecdat' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Users\satimiswin764\AppData\Local\Temp\RtmpP3dNfa\downloaded_packages
d
Package installed.

Installation went through w/o problem.

 library(Ecdat)
 data()

Data sets in package ‘datasets’  NOT 'Ecdat'

 ??Ecdat
...
Ecdat::Caschool The California Test Score Data Set
Ecdat::GrilichesWage Datas
Ecdat::MCAS The Massashusets Test Score Data Set
Ecdat::MunExp   Municipal Expenditure Data
Ecdat::Orange   The Orange Juice Data Set
Ecdat::SolowSolow's Technological Change Data
Ecdat::TranspEq Statewide Data on Transportation Equipment
Manufacturing



Those files are in Ecdat packages.

 Caschool
Error: object 'Caschool' not found

 MCAS
Error: object 'MCAS' not found

Please help.  TIA

B.R.
Stephen L









From: Stefan Grosse singularit...@gmx.net

Sent: Sun, November 28, 2010 7:23:19 PM
Subject: Re: [R] How to remove a package.

Am 27.11.2010 09:48, schrieb Stephen Liu:

 I found the datasets of AER 

cool.

 detach(package:AER, unload = TRUE)

detach(package:AER) works for me.

 data()
 still found car there.

you mean cars ? This is not part of AER but in a base R installation.

 install.packages(EcDat)

 Where can I download/install EcDat?  TIA

It is case sensitive, try install.packages(Ecdat) it works for me...

Maybe you should try a little bit more...

hth
Stefan



[[alternative HTML version deleted]]

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


Re: [R] Where to download R .xls sample files?

2010-11-28 Thread Stephen Liu
Hi,

 why do you need .xls format data file?

For learning.

I found following video:
http://www.youtube.com/watch?v=Hq0JmSnBX8Ifeature=mfu_in_orderlist=UL

I need econdat.xls, Excel file

B.R.
Stephen L






From: Jinsong Zhao jsz...@yeah.net
To: r-help@r-project.org
Sent: Sun, November 28, 2010 7:54:14 PM
Subject: Re: [R] Where to download R .xls sample files?

On 2010-11-28 19:46, Stephen Liu wrote:
 Hi folks,

 Which R packages containing sample .xls files?  TIA


why do you need .xls format data file?

 B.R.
 Stephen L



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



[[alternative HTML version deleted]]

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


Re: [R] Where is gdata?

2010-11-28 Thread Liviu Andronic
On Sun, Nov 28, 2010 at 12:44 PM, Stephen Liu sati...@yahoo.com wrote:
 library(gdata)
 gdata
 Error: object 'gdata' not found

 gdata()
 Error: could not find function gdata


 Please advise what mistake I have committed.  TIA

Try
help(package=gdata)

Regards
Liviu



 B.R.
 Stephen L



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





-- 
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] Comparing two functions

2010-11-28 Thread baptiste auguie
Hi,

Your function fails for a number of reasons. One of them is your
comparison (use browser() to see what is the value taken by f in your
function). Also, n, mean, min and max could not be extracted from ...
with your construction.

Here's my suggestion,

randomIra = function(f=runif, ...){
switch(f,
   rnorm = do.call(rnorm, c(sd=1, list(...))) ,
   runif = , # will use the next one, which is also the default
   runif(...))
}

randomIra(rnorm, n = 5, mean = 20)
randomIra(runif, n=5, min = 10, max = 25)
randomIra(, n=5, min = 10, max = 25) # default


HTH,

baptiste




On 28 November 2010 11:53, Ira Sharenow irasharenow...@yahoo.com wrote:
 Hi. I am new to R and facing a problem that I cannot solve.



 I am writing some basic functions. Then I would like to have a master 
 function that allows me to call one of the functions which I created, but I 
 cannot figure out how to do so.



 Below is an example. The functions rnormIra and runifIra both seem to work 
 fine. I do not get an error message when entering the definition of the 
 master function randomIra; however, it fails when I use it to call another 
 function.



 Can someone please help?



 Thanks.



 Ira



 rnormIra = function(n, mean) {
  return(rnorm(n,mean,1))
 }
 rnormIra(10,100) #works fine



 runifIra = function(n,min,max) {
  return(runif(n,min,max))
 }
 runifIra(5,20,30) #works fine



 randomIra = function(f, ...) {
  if(f == rnormIra) {
   return(rnormIra(n,mean))
  }
  else {
        return(runifIra(n,min,max))
  }
 } #no error messages



 randomIra(rnormIra, n = 5, mean = 20) #FAILS
 randomIra(runifIra, n = 5, min = 10, max = 25) #FAILS

 do.call(randomIra,list(rnormIra,5,20)) #FAILS


        [[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] \Sweaveopts error

2010-11-28 Thread Duncan Murdoch

On 27/11/2010 8:59 PM, John Maindonald wrote:

Actually, I had until I created this file had everything on one line,
or had separate \SweaveOpts commands.

Putting everything on one line ensures that the graphics file
goes to the subdirectory snArt, but the file test1.tex is unchanged.

Note however the difference between the files test1.tex and
test.tex, irrespective of the 1 line or 2 issue.  The first of the
\SweaveOpts lines had an effect, unless I am missing something.


I'm confused now.  Where does test.tex come from?  It's not in the 
directory referred to below, and I don't see it mentioned earlier in 
this thread.


Duncan Murdoch



John.

John Maindonald email: john.maindon...@anu.edu.au
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics  Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
http://www.maths.anu.edu.au/~johnm

On 28/11/2010, at 12:40 PM, Duncan Murdoch wrote:


On 27/11/2010 7:57 PM, John Maindonald wrote:

Actually, I spoke too soon.  The files process without obvious error,
but keep.source=TRUE is ignored.  I have posted small files
test1.Rnw and test2.Rnw that can be used to demonstrate the
problems at:
   http://wwwmaths.anu.edu.au/~johnm/r/issues/


In the test1.Rnw file, your \SweaveOpts statement spans two lines. Sweave() 
doesn't recognize it, so it's completely ignored.

I don't think this is new behaviour; it's a consequence of the way Sweave looks 
for \SweaveOpts via regular expression.

Not quite sure what's going on in the second one yet...

Duncan Murdoch



Sweave(test1)  ## includes SweaveOpts settings

Sweave(test2, keep.source=TRUE)
   ## SweaveOpts settings have been removed.

Comments do not appear in the LaTeX file that results, the code
is reformatted and the graph from test1 goes into the working
directory.

Notice also the NA that mysteriously appears in the second
line of code in output .tex file test2.tex

John.

John Maindonald email: john.maindon...@anu.edu.au
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics   Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
http://www.maths.anu.edu.au/~johnm

On 26/11/2010, at 4:26 PM, John Maindonald wrote:


Yes, that has fixed the problem. (2010-11-24 r53659)

Thanks.

John Maindonald email: john.maindon...@anu.edu.au
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics   Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
http://www.maths.anu.edu.au/~johnm

On 25/11/2010, at 10:56 PM, Duncan Murdoch wrote:


On 25/11/2010 6:34 AM, John Maindonald wrote:

I have a file 4lmetc.Rnw, intended for inclusion in a LaTeX document,
that starts:


I think this may have been fixed in the patched version.  Could you give it a 
try to confirm?  If not, please send me a simplified version of the file, and 
I'll see what's going wrong.

Duncan Murdoch




\SweaveOpts{engine=R, keep.source=TRUE}
\SweaveOpts{eps=FALSE, prefix.string=snArt/4lmetc}

The attempt to process the file through Sweave generates the error:


Sweave(4lmetc)

Writing to file 4lmetc.tex
Processing code chunks ...
1 : keep.source term verbatim
Error in file(srcfile$filename, open = rt, encoding = encoding) :
cannot open the connection
In addition: Warning message:
In file(srcfile$filename, open = rt, encoding = encoding) :
cannot open file '4lmetc': No such file or directory

The same file processes through Stangle() without problems.
If I comment out the \Sweaveopts lines, there is no problem,
except that I do not get the options that I want.

This processed fine in R-2.11.1


sessionInfo()

R version 2.12.0 (2010-10-15)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

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

other attached packages:
[1] lattice_0.19-13 DAAG_1.02   randomForest_4.5-36
[4] rpart_3.1-46MASS_7.3-8  reshape_0.8.3
[7] plyr_1.2.1  proto_0.3-8

loaded via a namespace (and not attached):
[1] ggplot2_0.8.8   latticeExtra_0.6-14

Is there a workaround?

John Maindonald email: john.maindon...@anu.edu.au
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for MathematicsIts Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
http://www.maths.anu.edu.au/~johnm

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













Re: [R] Comparing two functions

2010-11-28 Thread Gabor Grothendieck
On Sun, Nov 28, 2010 at 5:53 AM, Ira Sharenow irasharenow...@yahoo.com wrote:
 Hi. I am new to R and facing a problem that I cannot solve.

 I am writing some basic functions. Then I would like to have a master 
 function that allows me to call one of the functions which I created, but I 
 cannot figure out how to do so.

 Below is an example. The functions rnormIra and runifIra both seem to work 
 fine. I do not get an error message when entering the definition of the 
 master function randomIra; however, it fails when I use it to call another 
 function.

 rnormIra = function(n, mean) {
  return(rnorm(n,mean,1))
 }
 rnormIra(10,100) #works fine

 runifIra = function(n,min,max) {
  return(runif(n,min,max))
 }
 runifIra(5,20,30) #works fine

 randomIra = function(f, ...) {
  if(f == rnormIra) {
   return(rnormIra(n,mean))
  }
  else {
        return(runifIra(n,min,max))
  }
 } #no error messages

 randomIra(rnormIra, n = 5, mean = 20) #FAILS
 randomIra(runifIra, n = 5, min = 10, max = 25) #FAILS

 do.call(randomIra,list(rnormIra,5,20)) #FAILS


Try this:

randomIra - function(f, ...) if (identical(f, rnormIra))
rnormIra(...) else runifIra(...)

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

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


Re: [R] return vector of element names for vector, matrix or array

2010-11-28 Thread Michael Friendly

On 11/27/2010 6:13 PM, Joshua Wiley wrote:

Interesting use of outer, but I think you're overthinking it ;)

expand.grid(dimnames(x3))

Ah, thanks.  I guess I was thinking outer the box ;-)

If you want it as a vector separated by colons...

apply(expand.grid(dimnames(x3)), 1, paste, collapse = :)





--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


Re: [R] How to remove a package.

2010-11-28 Thread David Winsemius


On Nov 28, 2010, at 7:16 AM, Stephen Liu wrote:


Hi Stefan,

Tks for your advice.


snipped


Installation went through w/o problem.


library(Ecdat)
data()


Data sets in package ‘datasets’  NOT 'Ecdat'


??Ecdat

...
Ecdat::Caschool The California Test Score Data Set
Ecdat::GrilichesWage Datas
Ecdat::MCAS The Massashusets Test Score Data Set
Ecdat::MunExp   Municipal Expenditure Data
Ecdat::Orange   The Orange Juice Data Set
Ecdat::SolowSolow's Technological Change Data
Ecdat::TranspEq Statewide Data on Transportation Equipment
   Manufacturing



Those files are in Ecdat packages.


Caschool

Error: object 'Caschool' not found


MCAS

Error: object 'MCAS' not found


Because loading the package does not necessarily register the datasets:

 require(Ecdat)
Loading required package: Ecdat
 data()  #-- produces a large list including
Car  Stated Preferences for Car Choice
Caschool The California Test Score Data Set
Catsup   Choice of Brand for Catsup
CigarCigarette Consumption
 str(Caschool)
Error in str(Caschool) : object 'Caschool' not found

 data(Car)
 str(Car)
'data.frame':   4654 obs. of  70 variables:
 $ choice: Factor w/ 6 levels choice1,choice2,..: 1 2 5 5 5 5  
2 5 5 2 ...

 $ college   : num  0 1 0 0 0 0 1 1 0 1 ...
 $ hsg2  : num  0 1 1 0 1 0 1 0 0 0 ...

Note that this dataset was NEVER  spelled car.

--
David.


From: Stefan Grosse singularit...@gmx.net

Sent: Sun, November 28, 2010 7:23:19 PM
Subject: Re: [R] How to remove a package.

Am 27.11.2010 09:48, schrieb Stephen Liu:


I found the datasets of AER


cool.


detach(package:AER, unload = TRUE)


detach(package:AER) works for me.


data()
still found car there.


you mean cars ? This is not part of AER but in a base R  
installation.



install.packages(EcDat)



Where can I download/install EcDat?  TIA


It is case sensitive, try install.packages(Ecdat) it works for me...

Maybe you should try a little bit more...

hth
Stefan



[[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 is gdata?

2010-11-28 Thread Spencer Graves

Hi, Greg, Stephen, Liviu:


  I tried install.packages('gregmisc'), which Stephen said he 
had.  Then  help(pac=gdata) seemed to work normally.  However, when I 
then tried library(gdata), I got an error message from the the 
operating system, saying perl.exe has stopped working.  I cancelled 
past that and got a message gdata: Unable to load perl libaries needed 
by read.xls() ... Run the function 'installXLSXsupport()'.  I tried 
'installXLSXsupport()' and again perl stopped working.  I quit R and 
tried install.packages('gdata') again, and it killed perl again.



  Before installing 'gregmisc', I had tried 
install.packages('gdata') by itself.  That seemed to work.  Then I 
manually removed it and tried 'gregmisc', as Stephen had, and got 
problems I don't know how to solve.



  ???
  Thanks,
  Spencer

##

 library(gdata)
gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.



 sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] gdata_2.8.1

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

On 11/28/2010 4:22 AM, Liviu Andronic wrote:

On Sun, Nov 28, 2010 at 12:44 PM, Stephen Liusati...@yahoo.com  wrote:

library(gdata)
gdata

Error: object 'gdata' not found


gdata()

Error: could not find function gdata


Please advise what mistake I have committed.  TIA


Try
help(package=gdata)

Regards
Liviu



B.R.
Stephen L



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








--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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

2010-11-28 Thread Gabor Grothendieck
On Sun, Nov 28, 2010 at 10:40 AM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:
      I tried install.packages('gregmisc'), which Stephen said he had.
  Then  help(pac=gdata) seemed to work normally.  However, when I then
 tried library(gdata), I got an error message from the the operating
 system, saying perl.exe has stopped working.  I cancelled past that and
 got a message gdata: Unable to load perl libaries needed by read.xls() ...
 Run the function 'installXLSXsupport()'.  I tried 'installXLSXsupport()'
 and again perl stopped working.  I quit R and tried
 install.packages('gdata') again, and it killed perl again.


      Before installing 'gregmisc', I had tried install.packages('gdata') by
 itself.  That seemed to work.  Then I manually removed it and tried
 'gregmisc', as Stephen had, and got problems I don't know how to solve.


      ???
      Thanks,
      Spencer

 ##

 library(gdata)
 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLX' (Excel 97-2004) files.

 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLSX' (Excel 2007+) files.

 gdata: Run the function 'installXLSXsupport()'
 gdata: to automatically download and install the perl
 gdata: libaries needed to support Excel XLS and XLSX formats.


Read ?installXLSXsupport

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

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


Re: [R] How to remove a package.

2010-11-28 Thread Stephen Liu
Hi David,

Thanks for your advice.  I got it.

But I can't resolve:

 library(AER)
Loading required package: car
Loading required package: MASS
Loading required package: nnet
Loading required package: survival
Loading required package: splines
Loading required package: Formula
Loading required package: lmtest
Loading required package: zoo
Loading required package: sandwich
Loading required package: strucchange

 data()
displays Data sets in package ‘AER’:

But;
 library(Ecdat)
 data()
displays Data sets in package ‘datasets’:
a large datasets including those in package Ecdat?  NOt only Ecdat separately.

B.R.
Stephen L





From: David Winsemius dwinsem...@comcast.net

Cc: Stefan Grosse singularit...@gmx.net; r-help@r-project.org
Sent: Sun, November 28, 2010 11:16:34 PM
Subject: Re: [R] How to remove a package.


On Nov 28, 2010, at 7:16 AM, Stephen Liu wrote:

 Hi Stefan,

 Tks for your advice.

snipped

 Installation went through w/o problem.

 library(Ecdat)
 data()

 Data sets in package ‘datasets’  NOT 'Ecdat'

 ??Ecdat
 ...
 Ecdat::Caschool The California Test Score Data Set
 Ecdat::GrilichesWage Datas
 Ecdat::MCAS The Massashusets Test Score Data Set
 Ecdat::MunExp   Municipal Expenditure Data
 Ecdat::Orange   The Orange Juice Data Set
 Ecdat::SolowSolow's Technological Change Data
 Ecdat::TranspEq Statewide Data on Transportation Equipment
Manufacturing
 


 Those files are in Ecdat packages.

 Caschool
 Error: object 'Caschool' not found

 MCAS
 Error: object 'MCAS' not found

Because loading the package does not necessarily register the datasets:

 require(Ecdat)
Loading required package: Ecdat
 data()  #-- produces a large list including
Car  Stated Preferences for Car Choice
Caschool The California Test Score Data Set
Catsup   Choice of Brand for Catsup
CigarCigarette Consumption
 str(Caschool)
Error in str(Caschool) : object 'Caschool' not found

 data(Car)
 str(Car)
'data.frame':4654 obs. of  70 variables:
  $ choice: Factor w/ 6 levels choice1,choice2,..: 1 2 5 5 5 5  
2 5 5 2 ...
  $ college   : num  0 1 0 0 0 0 1 1 0 1 ...
  $ hsg2  : num  0 1 1 0 1 0 1 0 0 0 ...

Note that this dataset was NEVER  spelled car.

-- 
David.
 
 From: Stefan Grosse singularit...@gmx.net

 Sent: Sun, November 28, 2010 7:23:19 PM
 Subject: Re: [R] How to remove a package.

 Am 27.11.2010 09:48, schrieb Stephen Liu:

 I found the datasets of AER

 cool.

 detach(package:AER, unload = TRUE)

 detach(package:AER) works for me.

 data()
 still found car there.

 you mean cars ? This is not part of AER but in a base R  
 installation.

 install.packages(EcDat)

 Where can I download/install EcDat?  TIA

 It is case sensitive, try install.packages(Ecdat) it works for me...

 Maybe you should try a little bit more...

 hth
 Stefan



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


[[alternative HTML version deleted]]

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


Re: [R] How to remove a package.

2010-11-28 Thread Liviu Andronic
On Sun, Nov 28, 2010 at 4:58 PM, Stephen Liu sati...@yahoo.com wrote:
 data()
 displays Data sets in package ‘AER’:

 But;
 library(Ecdat)
 data()
 displays Data sets in package ‘datasets’:
 a large datasets including those in package Ecdat?  NOt only Ecdat 
 separately.

Read ?data. Try
data(package='AER')
data(package='Ecdat')

Regards
Liviu


 B.R.
 Stephen L




 
 From: David Winsemius dwinsem...@comcast.net

 Cc: Stefan Grosse singularit...@gmx.net; r-help@r-project.org
 Sent: Sun, November 28, 2010 11:16:34 PM
 Subject: Re: [R] How to remove a package.


 On Nov 28, 2010, at 7:16 AM, Stephen Liu wrote:

 Hi Stefan,

 Tks for your advice.

 snipped

 Installation went through w/o problem.

 library(Ecdat)
 data()

 Data sets in package ‘datasets’  NOT 'Ecdat'

 ??Ecdat
 ...
 Ecdat::Caschool         The California Test Score Data Set
 Ecdat::Griliches        Wage Datas
 Ecdat::MCAS             The Massashusets Test Score Data Set
 Ecdat::MunExp           Municipal Expenditure Data
 Ecdat::Orange           The Orange Juice Data Set
 Ecdat::Solow            Solow's Technological Change Data
 Ecdat::TranspEq         Statewide Data on Transportation Equipment
                        Manufacturing
 


 Those files are in Ecdat packages.

 Caschool
 Error: object 'Caschool' not found

 MCAS
 Error: object 'MCAS' not found

 Because loading the package does not necessarily register the datasets:

 require(Ecdat)
 Loading required package: Ecdat
 data()  #-- produces a large list including
 Car                              Stated Preferences for Car Choice
 Caschool                         The California Test Score Data Set
 Catsup                           Choice of Brand for Catsup
 Cigar                            Cigarette Consumption
 str(Caschool)
 Error in str(Caschool) : object 'Caschool' not found

 data(Car)
 str(Car)
 'data.frame':    4654 obs. of  70 variables:
  $ choice    : Factor w/ 6 levels choice1,choice2,..: 1 2 5 5 5 5
 2 5 5 2 ...
  $ college   : num  0 1 0 0 0 0 1 1 0 1 ...
  $ hsg2      : num  0 1 1 0 1 0 1 0 0 0 ...

 Note that this dataset was NEVER  spelled car.

 --
 David.
 
 From: Stefan Grosse singularit...@gmx.net

 Sent: Sun, November 28, 2010 7:23:19 PM
 Subject: Re: [R] How to remove a package.

 Am 27.11.2010 09:48, schrieb Stephen Liu:

 I found the datasets of AER

 cool.

 detach(package:AER, unload = TRUE)

 detach(package:AER) works for me.

 data()
 still found car there.

 you mean cars ? This is not part of AER but in a base R
 installation.

 install.packages(EcDat)

 Where can I download/install EcDat?  TIA

 It is case sensitive, try install.packages(Ecdat) it works for me...

 Maybe you should try a little bit more...

 hth
 Stefan



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


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





-- 
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] Where is gdata?

2010-11-28 Thread Spencer Graves

Hello, All:


  Prof. Ripley suggested I remove RTools/perl from my path.  I did 
that leaving Strawberry perl.  Then everything seemed to work 
appropriately.



  Thanks to all.
  Spencer


On 11/28/2010 7:49 AM, Gabor Grothendieck wrote:

On Sun, Nov 28, 2010 at 10:40 AM, Spencer Graves
spencer.gra...@structuremonitoring.com  wrote:

  I tried install.packages('gregmisc'), which Stephen said he had.
  Then  help(pac=gdata) seemed to work normally.  However, when I then
tried library(gdata), I got an error message from the the operating
system, saying perl.exe has stopped working.  I cancelled past that and
got a message gdata: Unable to load perl libaries needed by read.xls() ...
Run the function 'installXLSXsupport()'.  I tried 'installXLSXsupport()'
and again perl stopped working.  I quit R and tried
install.packages('gdata') again, and it killed perl again.


  Before installing 'gregmisc', I had tried install.packages('gdata') by
itself.  That seemed to work.  Then I manually removed it and tried
'gregmisc', as Stephen had, and got problems I don't know how to solve.


  ???
  Thanks,
  Spencer

##


library(gdata)

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.


Read ?installXLSXsupport




--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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

2010-11-28 Thread Stefan Grosse
On Sun, 28 Nov 2010 03:46:45 -0800 (PST) sati...@yahoo.com wrote:

SL Hi folks,
SL 
SL Which R packages containing sample .xls files?  TIA

Help yourself! Create your own! If you do not have Excel use
OpenOffice and save as xls!

Stefan

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


[R] predict.drm not generating confidence intervals

2010-11-28 Thread Brant Inman
R-helpers,

I recently submitted a help request for the predict.drm function found in the 
drc package.  I am still having issues with the function and I am submitting 
reproducible code hoping that somebody can help me figure out what is going on.


library(drc)

# Fit a 4 parameter logistic model to ryegrass dataset
fit - drm(rootl ~ conc, data = ryegrass, fct = LL.4())
summary(fit)

# Generate a fake dataset for prediction
newdt - data.frame( matrix(c(seq(0.2, 9, 0.01), rep(NA,881)), ncol=2))
colnames(newdt) - c('rootl', 'conc')

# Generate prediction intervals and confidence intervals
prd.p - predict(fit, newdata=newdt, interval='prediction')
prd.c - predict(fit, newdata=newdt, interval='confidence')

# Check output
 head(prd.p)
 Prediction Lower Upper
[1,]   7.790812NANA
[2,]   7.790476NANA
[3,]   7.790106NANA
[4,]   7.789702NANA
[5,]   7.789262NANA
[6,]   7.788784NANA  

 head(prd.c)
 Prediction Lower Upper
[1,]   7.790812NANA
[2,]   7.790476NANA
[3,]   7.790106NANA
[4,]   7.789702NANA
[5,]   7.789262NANA
[6,]   7.788784NANA



There appears to be a problem with the predict.drc function.  This code 
previous generated confidence and prediction intervals in columns 2 and 3 of 
the prediction matrices but now fails for reasons unknown to me.  Anyone have 
an idea of what is going on and how I can remedy the situation?

Brant Inman



[[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] Legend symbols mixed char and integer

2010-11-28 Thread Mike Prager
On Sun, 28 Nov 2010 07:54:43 + (GMT), Prof Brian Ripley
rip...@stats.ox.ac.uk wrote:

On Sat, 27 Nov 2010, Mike Prager wrote:

 I need to generate a plot with both open and filled circles. It is
 simple enough, using pch=1 and pch=16.

 The R pdf graphics output is going into pdftex 1.40.10 (MikTeX 2.8).

 The R pdf is correct when viewed in other viewers. However, pdftex
 fills the open circles.  I can work around this problem by using
 pch=o for the open circles. However, that messes up the figure
 legend.

 Is it possible to use the pch argument of legend() to specify both a
 symbol number and a character? I haven't found the way.

You don't need to.  pch=o is the same as pch=111 (the ASCII number). 
See ?points.

 Or is there some known work-around for the pdftex bug?

Well, pdftex is not a viewer and does not of itself process PDF 
inclusions, but see ?pdf and the 'useDingbats' argument.

If you really think this is a bug in your LaTeX system, you should 
report it.  But you haven't shown us reproducible code, and similar 
things have worked for me in the past.

Many thanks to Brian R. I obtained the desired plot by using
'useDingbats = FALSE',  after switching from 'savePlot' to
'dev.copy2pdf', which allows that argument.

Thanks especially for the reference to 'points'. Though I had looked
several other places for a mapping of 'pch' to characters, I hadn't
thought of looking there.

To clarify, I doubt that this is an R bug.  The PDF displays wrong
only when it goes through pdftex. I am not knowledgable enough about
pdf or epstex to trace the error's origin.

If it would help anyone, I will attempt later to develop simple
reproducible code demonstrating this.

--
Mike Prager, NC, USA 
(Remove pi from email to use)

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


Re: [R] predict.drm not generating confidence intervals

2010-11-28 Thread David Winsemius
Puzzled. Why are the data you offer to predict() for the independent  
variable, conc, all NA's? Is there something reversed or inverted  
about how drc functions handle formulas.


--
David.

On Nov 28, 2010, at 2:33 PM, Brant Inman wrote:


R-helpers,

I recently submitted a help request for the predict.drm function  
found in the drc package.  I am still having issues with the  
function and I am submitting reproducible code hoping that somebody  
can help me figure out what is going on.



library(drc)

# Fit a 4 parameter logistic model to ryegrass dataset
fit - drm(rootl ~ conc, data = ryegrass, fct = LL.4())
summary(fit)

# Generate a fake dataset for prediction
newdt - data.frame( matrix(c(seq(0.2, 9, 0.01), rep(NA,881)),  
ncol=2))

colnames(newdt) - c('rootl', 'conc')

# Generate prediction intervals and confidence intervals
prd.p - predict(fit, newdata=newdt, interval='prediction')
prd.c - predict(fit, newdata=newdt, interval='confidence')

# Check output

head(prd.p)

Prediction Lower Upper
[1,]   7.790812NANA
[2,]   7.790476NANA
[3,]   7.790106NANA
[4,]   7.789702NANA
[5,]   7.789262NANA
[6,]   7.788784NANA


head(prd.c)

Prediction Lower Upper
[1,]   7.790812NANA
[2,]   7.790476NANA
[3,]   7.790106NANA
[4,]   7.789702NANA
[5,]   7.789262NANA
[6,]   7.788784NANA



There appears to be a problem with the predict.drc function.  This  
code previous generated confidence and prediction intervals in  
columns 2 and 3 of the prediction matrices but now fails for reasons  
unknown to me.  Anyone have an idea of what is going on and how I  
can remedy the situation?


Brant Inman



[[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] how to divide each column in a matrix by its colSums?

2010-11-28 Thread casperyc

Hi,

I have a matrix, say 
m=matrix(c(
983,679,134,
383,416,84,
2892,2625,570
),nrow=3
)

i can find its row/col sum by

rowSums(m)
colSums(m)

How do I divide each row/column by its rowSum/colSums and still return in
the matrix form?
(i.e. the new rowSums/colSums =1)

Thanks.

Casper

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-divide-each-column-in-a-matrix-by-its-colSums-tp3062739p3062739.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] how to divide each column in a matrix by its colSums?

2010-11-28 Thread Jorge Ivan Velez
Hi Casper,

Try

m/colSums(m)
m/rowSums(m)

HTH,
Jorge

On Sun, Nov 28, 2010 at 3:46 PM, casperyc  wrote:


 Hi,

 I have a matrix, say
 m=matrix(c(
983,679,134,
383,416,84,
2892,2625,570
),nrow=3
 )

 i can find its row/col sum by

 rowSums(m)
 colSums(m)

 How do I divide each row/column by its rowSum/colSums and still return in
 the matrix form?
 (i.e. the new rowSums/colSums =1)

 Thanks.

 Casper

 --
 View this message in context:
 http://r.789695.n4.nabble.com/how-to-divide-each-column-in-a-matrix-by-its-colSums-tp3062739p3062739.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] how to divide each column in a matrix by its colSums?

2010-11-28 Thread casperyc

In that case, there are values 1,
which is clearly not what I wanted.

Thanks.

I think I should use prop.table


-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-divide-each-column-in-a-matrix-by-its-colSums-tp3062739p3062752.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] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread Cory Rieth
Hello!

I stumbled upon something odd that took a while to track down, and I wanted to 
run it by here to see if I should submit a bug report. For randomly generated 
numbers (from a variety of distributions) rounding them to specifically 2 
digits and then multiplying them by 100 produces strange results on about 8% of 
cases. The problematic numbers display as I would have expected, but do not 
logically match the as.integer counterpart (additionally they will not be used 
correctly by functions such as rep()). I realize there are easy workarounds, 
but I wouldn't have expected this result, and it only occurs rounding to 2 
decimals, i.e. changing digits to 3 and multiplying by 1000 after rounding 
gives the expected result.

x-runif(100)   #generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then multiply them 
all by 100. I expected the results to all be integers
sum(y!=as.integer(y))   #but on about 8% of the numbers they do not 
match the integer version
x[which(y!=as.integer(y))]  # a list of the problem numbers from the 
original distribution. They seem to be more common but not exclusive to .54 to 
.57
y[which(y!=as.integer(y))]  #the numbers still display as would be expected, 
i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as the same 
number they are not logically identical to

Thanks, and sorry if I came across something that is known, or it is meant to 
behave this way, I couldn't find anything. 

Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0 
arch   x86_64   
os darwin9.8.0  
system x86_64, darwin9.8.0  
status  
major  2
minor  12.0 
year   2010 
month  10   
day15   
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread David Winsemius


On Nov 28, 2010, at 4:20 PM, Cory Rieth wrote:


Hello!

I stumbled upon something odd that took a while to track down, and I  
wanted to run it by here to see if I should submit a bug report. For  
randomly generated numbers (from a variety of distributions)  
rounding them to specifically 2 digits and then multiplying them by  
100 produces strange results on about 8% of cases. The problematic  
numbers display as I would have expected, but do not logically match  
the as.integer counterpart (additionally they will not be used  
correctly by functions such as rep()). I realize there are easy  
workarounds, but I wouldn't have expected this result, and it only  
occurs rounding to 2 decimals, i.e. changing digits to 3 and  
multiplying by 1000 after rounding gives the expected result.


x-runif(100)#generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then  
multiply them all by 100. I expected the results to all be integers
sum(y!=as.integer(y))		#but on about 8% of the numbers they do not  
match the integer version
x[which(y!=as.integer(y))]	# a list of the problem numbers from the  
original distribution. They seem to be more common but not exclusive  
to .54 to .57
y[which(y!=as.integer(y))]  #the numbers still display as would be  
expected, i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as  
the same number they are not logically identical to


Thanks, and sorry if I came across something that is known, or it is  
meant to behave this way, I couldn't find anything.


It's one of the FAQ and probably the most F-ly of the FAQ's. #21 or  
#31 if I remember (vaguely)  ... the one about why seq(0.1, 1, by=0.1)  
==  (1:11)/10  returns 2 FALSE's.


--
David.



Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0
arch   x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status
major  2
minor  12.0
year   2010
month  10
day15
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] how to divide each column in a matrix by its colSums?

2010-11-28 Thread Spencer Graves

prop.table divides every element by the matrix total, not its colSums:

 m - matrix(1:4, 2)
 m
 [,1] [,2]
[1,]13
[2,]24
 prop.table(m)
 [,1] [,2]
[1,]  0.1  0.3
[2,]  0.2  0.4


  m/rowSums(m) divides every row by its rowSum:

 m/rowSums(m)
  [,1]  [,2]
[1,] 0.250 0.750
[2,] 0.333 0.667


  To divide every element by its colSum:


 t(t(m)/rowSums(t(m)))
  [,1]  [,2]
[1,] 0.333 0.4285714
[2,] 0.667 0.5714286


  Hope this helps.
  Spencer


On 11/28/2010 12:55 PM, casperyc wrote:

In that case, there are values1,
which is clearly not what I wanted.

Thanks.

I think I should use prop.table


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


Re: [R] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread Duncan Murdoch

On 28/11/2010 4:20 PM, Cory Rieth wrote:

Hello!

I stumbled upon something odd that took a while to track down, and I wanted to 
run it by here to see if I should submit a bug report. For randomly generated 
numbers (from a variety of distributions) rounding them to specifically 2 
digits and then multiplying them by 100 produces strange results on about 8% of 
cases. The problematic numbers display as I would have expected, but do not 
logically match the as.integer counterpart (additionally they will not be used 
correctly by functions such as rep()). I realize there are easy workarounds, 
but I wouldn't have expected this result, and it only occurs rounding to 2 
decimals, i.e. changing digits to 3 and multiplying by 1000 after rounding 
gives the expected result.


This is presumably another version of FAQ 7.31.  Very few numbers of the 
form n/100 are exactly representable in floating point, and the rounding 
error sometimes shows up when you multiply by 100.  A simpler version of 
this is the following:


 y - 1:99
 y[(y/100)*100 != y]
[1]  7 14 28 29 55 56 57 58

Duncan Murdoch



x-runif(100)#generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then multiply them 
all by 100. I expected the results to all be integers
sum(y!=as.integer(y))   #but on about 8% of the numbers they do not 
match the integer version
x[which(y!=as.integer(y))]  # a list of the problem numbers from the 
original distribution. They seem to be more common but not exclusive to .54 to 
.57
y[which(y!=as.integer(y))]  #the numbers still display as would be expected, 
i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as the same 
number they are not logically identical to

Thanks, and sorry if I came across something that is known, or it is meant to 
behave this way, I couldn't find anything.

Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0
arch   x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status
major  2
minor  12.0
year   2010
month  10
day15
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread Peter Ehlers

On 2010-11-28 13:20, Cory Rieth wrote:

Hello!

I stumbled upon something odd that took a while to track down, and I wanted to 
run it by here to see if I should submit a bug report. For randomly generated 
numbers (from a variety of distributions) rounding them to specifically 2 
digits and then multiplying them by 100 produces strange results on about 8% of 
cases. The problematic numbers display as I would have expected, but do not 
logically match the as.integer counterpart (additionally they will not be used 
correctly by functions such as rep()). I realize there are easy workarounds, 
but I wouldn't have expected this result, and it only occurs rounding to 2 
decimals, i.e. changing digits to 3 and multiplying by 1000 after rounding 
gives the expected result.

x-runif(100)#generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then multiply them 
all by 100. I expected the results to all be integers
sum(y!=as.integer(y))   #but on about 8% of the numbers they do not 
match the integer version
x[which(y!=as.integer(y))]  # a list of the problem numbers from the 
original distribution. They seem to be more common but not exclusive to .54 to 
.57
y[which(y!=as.integer(y))]  #the numbers still display as would be expected, 
i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as the same 
number they are not logically identical to

Thanks, and sorry if I came across something that is known, or it is meant to 
behave this way, I couldn't find anything.


Hmm, how hard have you looked?
I doubt that I'll be the first to remind you to check the FAQ.

Peter Ehlers


Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0
arch   x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status
major  2
minor  12.0
year   2010
month  10
day15
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 to divide each column in a matrix by its colSums?

2010-11-28 Thread casperyc

I am using 
 prop.table(m,1)
and
 prop.table(m,2)
my aim.
which I think is the most 'easy' way.

Thanks.

Casper
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-divide-each-column-in-a-matrix-by-its-colSums-tp3062739p3062797.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] non-linear fourth-order differential equations

2010-11-28 Thread Yanika Borg
I need to solve a system of non-linear fourth-order differential
equations. Is there a command which solves this system?

Thanks in advance.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 divide each column in a matrix by its colSums?

2010-11-28 Thread Erich Neuwirth
sweep(m,1,rowSums(m),/)
sweep(m,2,colSums(m),/)




On 11/28/2010 9:55 PM, casperyc wrote:
 
 In that case, there are values 1,
 which is clearly not what I wanted.
 
 Thanks.
 
 I think I should use prop.table
 


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


Re: [R] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread Jeff Newmiller

FAQ 7.31

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

You find it odd that the result is not an integer, while I find the fact 
that your calculation actually works reliably with any number of digits 
surprising, and you should avoid assuming such behavior will continue in 
the future. Multiply by the appropriate range and THEN take the integer 
part.


Patient: Doctor, it hurts when I ram my head into the wall!
Doctor: Don't do that!

Cory Rieth wrote:

Hello!

I stumbled upon something odd that took a while to track down, and I wanted to 
run it by here to see if I should submit a bug report. For randomly generated 
numbers (from a variety of distributions) rounding them to specifically 2 
digits and then multiplying them by 100 produces strange results on about 8% of 
cases. The problematic numbers display as I would have expected, but do not 
logically match the as.integer counterpart (additionally they will not be used 
correctly by functions such as rep()). I realize there are easy workarounds, 
but I wouldn't have expected this result, and it only occurs rounding to 2 
decimals, i.e. changing digits to 3 and multiplying by 1000 after rounding 
gives the expected result.

x-runif(100)#generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then multiply them 
all by 100. I expected the results to all be integers
sum(y!=as.integer(y))   #but on about 8% of the numbers they do not 
match the integer version
x[which(y!=as.integer(y))]  # a list of the problem numbers from the 
original distribution. They seem to be more common but not exclusive to .54 to 
.57
y[which(y!=as.integer(y))]  #the numbers still display as would be expected, 
i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as the same 
number they are not logically identical to

Thanks, and sorry if I came across something that is known, or it is meant to behave this way, I couldn't find anything. 


Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0 
arch   x86_64   
os darwin9.8.0  
system x86_64, darwin9.8.0  
status  
major  2
minor  12.0 
year   2010 
month  10   
day15   
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] unexpected behavior using round to 2 digits on randomly generated numbers

2010-11-28 Thread David Winsemius


On Nov 28, 2010, at 4:43 PM, David Winsemius wrote:



On Nov 28, 2010, at 4:20 PM, Cory Rieth wrote:


Hello!

I stumbled upon something odd that took a while to track down, and  
I wanted to run it by here to see if I should submit a bug report.  
For randomly generated numbers (from a variety of distributions)  
rounding them to specifically 2 digits and then multiplying them by  
100 produces strange results on about 8% of cases. The problematic  
numbers display as I would have expected, but do not logically  
match the as.integer counterpart (additionally they will not be  
used correctly by functions such as rep()). I realize there are  
easy workarounds, but I wouldn't have expected this result, and it  
only occurs rounding to 2 decimals, i.e. changing digits to 3 and  
multiplying by 1000 after rounding gives the expected result.


x-runif(100)#generate some random numbers
y-round(x,digits=2)*100  #round them all to two decimals, then  
multiply them all by 100. I expected the results to all be integers
sum(y!=as.integer(y))		#but on about 8% of the numbers they do not  
match the integer version
x[which(y!=as.integer(y))]	# a list of the problem numbers from the  
original distribution. They seem to be more common but not  
exclusive to .54 to .57
y[which(y!=as.integer(y))]  #the numbers still display as would be  
expected, i.e. they are integers
as.integer(y[which(y!=as.integer(y))])  # and sometimes display as  
the same number they are not logically identical to


Thanks, and sorry if I came across something that is known, or it  
is meant to behave this way, I couldn't find anything.


It's one of the FAQ and probably the most F-ly of the FAQ's. #21 or  
#31 if I remember


(vaguely)  ... the one about why seq(0.1, 1, by=0.1) ==  (1:11)/10   
returns 2 FALSE's.

er, make that /. ^(1:10)^


--
David.



Cory Rieth

R.version() output:
platform   x86_64-apple-darwin9.8.0
arch   x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status
major  2
minor  12.0
year   2010
month  10
day15
svn rev53317
language   R
version.string R version 2.12.0 (2010-10-15)
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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.


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] how to divide each column in a matrix by its colSums?

2010-11-28 Thread Spencer Graves

Thanks:  I didn't read the prop.table help page with sufficient care.


On 11/28/2010 1:48 PM, casperyc wrote:

I am using

prop.table(m,1)

and

prop.table(m,2)

my aim.
which I think is the most 'easy' way.

Thanks.

Casper



--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


Re: [R] predict.drm not generating confidence intervals

2010-11-28 Thread Peter Ehlers

Brant,
See below.

On 2010-11-28 12:25, David Winsemius wrote:

Puzzled. Why are the data you offer to predict() for the independent
variable, conc, all NA's? Is there something reversed or inverted
about how drc functions handle formulas.

-- David. On Nov 28, 2010, at 2:33 PM, Brant Inman wrote:

  R-helpers,

  I recently submitted a help request for the predict.drm function
  found in the drc package.  I am still having issues with the
  function and I am submitting reproducible code hoping that somebody
  can help me figure out what is going on.

  
  library(drc)

  # Fit a 4 parameter logistic model to ryegrass dataset
  fit- drm(rootl ~ conc, data = ryegrass, fct = LL.4())
  summary(fit)

  # Generate a fake dataset for prediction
  newdt- data.frame( matrix(c(seq(0.2, 9, 0.01), rep(NA,881)),
  ncol=2))
colnames(newdt)- c('rootl', 'conc')

  # Generate prediction intervals and confidence intervals
  prd.p- predict(fit, newdata=newdt, interval='prediction')
  prd.c- predict(fit, newdata=newdt, interval='confidence')

  # Check output

  head(prd.p)

   Prediction Lower Upper
  [1,]   7.790812NANA
  [2,]   7.790476NANA
  [3,]   7.790106NANA
  [4,]   7.789702NANA
  [5,]   7.789262NANA
  [6,]   7.788784NANA


  head(prd.c)

   Prediction Lower Upper
  [1,]   7.790812NANA
  [2,]   7.790476NANA
  [3,]   7.790106NANA
  [4,]   7.789702NANA
  [5,]   7.789262NANA
  [6,]   7.788784NANA

  

  There appears to be a problem with the predict.drc function.  This
  code previous generated confidence and prediction intervals in
  columns 2 and 3 of the prediction matrices but now fails for reasons
  unknown to me.  Anyone have an idea of what is going on and how I
  can remedy the situation?


As David points out, you seem to have your dose and response
mixed up. But even assuming that you mean to predict rootl
from conc, the predict.drc function needs to be used in a
certain way (and that is not clear in the documentation).

Try this:

 fit - drm(rootl ~ conc, data = ryegrass, fct = LL.4())
 newdat - data.frame(conc = seq(0, 30, len=101), apples=1)
 ypred - predict(fit, newdata=newdat, interval=confidence)
 head(ypred, 3)

 PredictionLowerUpper
[1,]   7.792958 7.399614 8.186303
[2,]   7.785771 7.400046 8.171495
[3,]   7.736545 7.380584 8.092505

Wondering about the 'apples'? That's just to show that
predict.drc doesn't care what you call your second column.
It seems that predict.drc requires either *no* newdata
or a *two*-variable data.frame in which the first column
(it, too, can have *any* name) contains the dose at which
to predict and the second column contains the 'curveid',
aka the grouping variable (if you have one). In your
case, the grouping reduces to a single group, i.e. a
vector of all '1's.

This could all be made considerably clearer in the documentation.

Peter Ehlers



  Brant Inman



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


Re: [R] predict.drm not generating confidence intervals

2010-11-28 Thread David Winsemius
I interpreted the to be that predict.drc was expecting a third  
argument,  curveid, which had no default, and that creating a  
dataframe like this was going to solve the problem.


 newdt - data.frame( conc= seq(0.2, 9, 0.01) , CURVE=1)
 prd.p - predict(fit, newdata=newdt, curveid=CURVE,  
interval=confidence)

 head(prd.p)
 PredictionLowerUpper
[1,]   7.790812 7.400131 8.181492
[2,]   7.790476 7.400161 8.180791
[3,]   7.790106 7.400185 8.180028
[4,]   7.789702 7.400203 8.179202
[5,]   7.789262 7.400213 8.178311
[6,]   7.788784 7.400215 8.177352

--
David


On Nov 28, 2010, at 5:19 PM, Peter Ehlers wrote:


Brant,
See below.

On 2010-11-28 12:25, David Winsemius wrote:

Puzzled. Why are the data you offer to predict() for the independent
variable, conc, all NA's? Is there something reversed or inverted
about how drc functions handle formulas.

-- David. On Nov 28, 2010, at 2:33 PM, Brant Inman wrote:

  R-helpers,

  I recently submitted a help request for the predict.drm function
  found in the drc package.  I am still having issues with the
  function and I am submitting reproducible code hoping that  
somebody

  can help me figure out what is going on.

  
  library(drc)

  # Fit a 4 parameter logistic model to ryegrass dataset
  fit- drm(rootl ~ conc, data = ryegrass, fct = LL.4())
  summary(fit)

  # Generate a fake dataset for prediction
  newdt- data.frame( matrix(c(seq(0.2, 9, 0.01), rep(NA,881)),
  ncol=2))
colnames(newdt)- c('rootl', 'conc')

  # Generate prediction intervals and confidence intervals
  prd.p- predict(fit, newdata=newdt, interval='prediction')
  prd.c- predict(fit, newdata=newdt, interval='confidence')

  # Check output

  head(prd.p)

   Prediction Lower Upper
  [1,]   7.790812NANA
  [2,]   7.790476NANA
  [3,]   7.790106NANA
  [4,]   7.789702NANA
  [5,]   7.789262NANA
  [6,]   7.788784NANA


  head(prd.c)

   Prediction Lower Upper
  [1,]   7.790812NANA
  [2,]   7.790476NANA
  [3,]   7.790106NANA
  [4,]   7.789702NANA
  [5,]   7.789262NANA
  [6,]   7.788784NANA

  

  There appears to be a problem with the predict.drc function.   
This

  code previous generated confidence and prediction intervals in
  columns 2 and 3 of the prediction matrices but now fails for  
reasons

  unknown to me.  Anyone have an idea of what is going on and how I
  can remedy the situation?


As David points out, you seem to have your dose and response
mixed up. But even assuming that you mean to predict rootl
from conc, the predict.drc function needs to be used in a
certain way (and that is not clear in the documentation).

Try this:

fit - drm(rootl ~ conc, data = ryegrass, fct = LL.4())
newdat - data.frame(conc = seq(0, 30, len=101), apples=1)
ypred - predict(fit, newdata=newdat, interval=confidence)
head(ypred, 3)

PredictionLowerUpper
[1,]   7.792958 7.399614 8.186303
[2,]   7.785771 7.400046 8.171495
[3,]   7.736545 7.380584 8.092505

Wondering about the 'apples'? That's just to show that
predict.drc doesn't care what you call your second column.
It seems that predict.drc requires either *no* newdata
or a *two*-variable data.frame in which the first column
(it, too, can have *any* name) contains the dose at which
to predict and the second column contains the 'curveid',
aka the grouping variable (if you have one). In your
case, the grouping reduces to a single group, i.e. a
vector of all '1's.

This could all be made considerably clearer in the documentation.

Peter Ehlers



  Brant Inman



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] weighted x variables with glm

2010-11-28 Thread Wendy Anderson
I have a glm regression (quasi-poisson) of log(mu) on x but I have varying
degrees of confidence in the x values, and can attach a numerical weighting
to each. Can anyone help me with suggestions of how to analysise this. Is
there an R package that would help?

Wendy

[[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] periodic time series

2010-11-28 Thread pengcafe

Hi all,

A beginner's question: I have to analyse univariate, strongly periodic data
collected every hour for a period of 1 week and I need to compare 5
different groups for significant differences between them.

Is there a better way to do this in R, other than pairwise t-tests of
summary statistics?

Thanks in advance,
Andy 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/periodic-time-series-tp3062866p3062866.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] Plotting a cloud/fog of variable density in rgl

2010-11-28 Thread JiHO
Thanks for both the replies.

 I think you can come closest to what you want within rgl by using
 sprites rather than rendering transparent spheres. See
 examples(sprites3d).

Sprites helps a lot indeed. With enough transparency I am close to what I want.

 If you only have 2 things with simple properties, namely point emitters
 as your organisms and a uniform concsntration of transparent scatters ( the
 fog) you can probably derive geometrical optics expressions for the ray trace
 results and just integrate those over your source distribution. This should
 be reasonably easy in R. I haven't been to siggraph since 1983 so can't help
 much but you can probably find analyitcal solutions for fog on google
 and just sum up your source distribution. I guess you could even do some
 wave optics etc as presumably the fog could be done as a function
 of wavelength just as easily. In any case, if you only have two basic things
 with simple disto should be reasonably easy to do in R with your own code.

I am afraid this is a bit too advanced for me. I know next to nothing
regarding digital 3D imaging and, even if I could compute this, I am
not sure how I would plot the result. My goal is really to add this to
my R-plotting arsenal and use it in routine, not to develop something
very specific for this particular application. But thank you for
taking the time to reply, maybe I'll come back to this when I know
more.

JiHO
---
http://maururu.net

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


Re: [R] non-linear fourth-order differential equations

2010-11-28 Thread Wu Gong

Hi Yanika,

Please try ?uniroot and ?ployroot

f - function(x) x^4-16
uniroot(f, lower= -3, upper=0)
polyroot(c(-16,0,0,0,1))

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/non-linear-fourth-order-differential-equations-tp3062805p3062894.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] periodic time series

2010-11-28 Thread Wu Gong

Hi Andy,

If you could provide a sample data set, it would help others to give a
solution.

I suggest look at the data and select a model, then anova. Take group as one
variable, record time (1 to 24 ) as the second variable and the week day
(Monday to Friday) as the third variable. Then test the interaction between
three variables at first. I hope the following code helps.

df - data.frame(value = rnorm(24*5*5),
group = rep(1:5,5*24),
time = rep(1:24,each=5),
day = rep(c(M,T,W,R,F),each=24))

anova(lm(value ~ group*time*day,data=df),lm(value ~
group*time*day-group:time:day,data=df))




-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/periodic-time-series-tp3062866p3062908.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] sqlUpdate error with MS acces

2010-11-28 Thread Jorge Nieves

Hi,


I am running the RODBC examples form the help guide. I am trying to
UPDATE a table in an Access data base but I am having an error.


library(RODBC)
library(termstrc)


path = getwd()
setwd(getwd())


dbName = data.mdb
pathdbname = paste(path,/,dbName,sep=)


accesChannel = odbcConnectAccess(pathdbname, uid = , pwd = )
sqlSave(accesChannel, USArrests, rownames = state, addPK=TRUE)
sqlFetch(accesChannel , USArrests, rownames = state) # get the lot

foo - cbind(state=row.names(USArrests), USArrests)[1:3, c(1,3)]
foo[1:3,2] - 

sqlUpdate(accesChannel , foo, USArrests)


The sqlSave and sqlFetch command seem to work fine.


 foo

 state Assault

Alabama Alabama

Alaska   Alaska

Arizona Arizona

 sqlUpdate(accesChannel , foo, USArrests)

Error in sqlUpdate(accesChannel, foo, USArrests) :

 cannot update 'USArrests' without unique column





I am using R 2.12.0(2010-10-15)
Using Microsoft access 2003.


Furthermore, the sqlColumns(accesChannel , USArrests)   returns the
following information



 sqlColumns(accesChannel , USArrests)

  TABLE_CAT TABLE_SCHEM
TABLE_NAME

1 C:\\ARTIFICALDESKTOP\\CurrentDownloads\\termstrc\\dataNA
USArrests

2 C:\\ARTIFICALDESKTOP\\CurrentDownloads\\termstrc\\dataNA
USArrests

3 C:\\ARTIFICALDESKTOP\\CurrentDownloads\\termstrc\\dataNA
USArrests

4 C:\\ARTIFICALDESKTOP\\CurrentDownloads\\termstrc\\dataNA
USArrests

5 C:\\ARTIFICALDESKTOP\\CurrentDownloads\\termstrc\\dataNA
USArrests

 COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH
DECIMAL_DIGITS

1   state12   VARCHAR 255   510
NA

2  Murder 8DOUBLE  53 8
NA

3 Assault 4   INTEGER  10 4
0

4UrbanPop 4   INTEGER  10 4
0

5Rape 8DOUBLE  53 8
NA

 NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF SQL_DATA_TYPE
SQL_DATETIME_SUB

1 NA1NA   NA12
NA

2  21NA   NA 8
NA

3 101NA   NA 4
NA

4 101NA   NA 4
NA

5  21NA   NA 8
NA

 CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE ORDINAL

1   5101 YES   1

2NA2 YES   2

3NA3 YES   3

4NA4 YES   4

5NA5 YES   5




Any ideas as of what might I have missed?

Thanks,

Jorge

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


Re: [R] weighted x variables with glm

2010-11-28 Thread Michael Bedward
Hi Wendy,

In case you haven't see it, the glm function accepts an optional
weights argument.

Michael

On 29 November 2010 09:42, Wendy Anderson newhorizonscand...@gmail.com wrote:
 I have a glm regression (quasi-poisson) of log(mu) on x but I have varying
 degrees of confidence in the x values, and can attach a numerical weighting
 to each. Can anyone help me with suggestions of how to analysise this. Is
 there an R package that would help?

 Wendy

        [[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] weighted x variables with glm

2010-11-28 Thread Michael Bedward
 In case you haven't see it, the glm function accepts an optional
 weights argument.


 Thanks for the reply. But the philosopy behind weighting is the assumption
 of unequal variance in the y values. In normal regression one assumes that
 the x values are known without error

 Wendy

Sorry Wendy - I posted my reply prior to engaging my brain (ie. didn't
read your question properly).

You're talking about Model II / major axis type methods. The smatr
package might cater for what you're trying to do.

Hope this helps (more).

Michael

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


Re: [R] weighted x variables with glm

2010-11-28 Thread Michael Bedward
Hello again Wendy,

Actually, the simex package is probably a more useful suggestion...

http://www.stat.uni-muenchen.de/~helmut/Texte/Simex_Rnews.pdf

Michael

On 29 November 2010 13:55, Michael Bedward michael.bedw...@gmail.com wrote:
 In case you haven't see it, the glm function accepts an optional
 weights argument.


 Thanks for the reply. But the philosopy behind weighting is the assumption
 of unequal variance in the y values. In normal regression one assumes that
 the x values are known without error

 Wendy

 Sorry Wendy - I posted my reply prior to engaging my brain (ie. didn't
 read your question properly).

 You're talking about Model II / major axis type methods. The smatr
 package might cater for what you're trying to do.

 Hope this helps (more).

 Michael


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


[R] How do I subtract sequential values ?

2010-11-28 Thread eric

Just starting to learn R so excuse me if this is a simple question. I'm
wondering how I get the percent difference in sequential values in one
column of a dataframe. If I had a dataframe and one of the columns was
value, how would I go about calculating  (v2-v1)/v1 (v3-v2)/v2
(v4-v3)/v3 ...etc ?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-do-I-subtract-sequential-values-tp3063019p3063019.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] Array help

2010-11-28 Thread bfhancock

Hi! I am learning R and have a question that is probably fairly simple for
those of you much more learned than I.  

I am messing with Arrays and am doing some simple stuff to get the hang of
them.  I will have a seperate array already pulled up and it will have
columns and rows.  I figured out that I can seperate these out with commands
like array_name[,1,1].  Now, I have an array where I want to make a single
array from a two ranges in the original array.  from 1:7 and 12:34.  I know
if i just did it with 1:7 it is just array_name[1:7,,] and that is it. 
But i wanted 12:34 in there as well. I assumed at first that it would just
be array_name[1:7  12:34,,] but was wrong.  Can anyone help me with this?
Thanks so much!

-B
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Array-help-tp3062992p3062992.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] Where is gdata?

2010-11-28 Thread Spencer Graves

Hi, Stephen:


  What operating system do you have?  From the path you cite, I 
assume you are using some version of Windows.



  Wikipedia on perl says there are two primary version of perl 
for Windows  Strawberry perl, which is free, open source, and 
ActivePerl, which is free but not open source.  I've been using 
Strawberry perl without any apparent problems due to the version.  When 
I removed ~Rtools/perl from my path, it still had Strawberry perl, and 
'installXLSXsupport()' worked with my installation of Strawberry perl, 
when it had not worked with ~Rtools/perl.  You can download Strawberry 
perl from http://strawberryperl.com;.  However,  
RSiteSearch('strawberry perl') produced 0 matches, while 
RSiteSearch(ActivePerl) returned 2 matches and RSiteSearch(Active 
Perl) found 10 matches.



   After downloading and installing one of these, if 
'installXLSXsupport()' still does not work, you need to check the path:  
If 'installXLSXsupport()' does not work with Strawberry perl as the 
first perl in your path, then you may need to install an appropriate 
package from CPAN.  More than that, I cannot answer.  However, if you 
download and install one of these two versions of perl and still have 
the problem, please report what you've done and they symptoms you get to 
this list.  Also, please include sessionInfo() with your reply.



  Hope this helps.
  Spencer


On 11/28/2010 6:38 PM, Stephen Liu wrote:

Hi Spencer,

Win 7

I can't find the folders RTools\perl

perl is on C:\Users\satimis\My Document\R\win-library\2.12\gdata\perl

Nor I can find the folder Strawberry perl.  Can you help?  TIA


B.R.
Stephen L





From: Spencer Gravesspencer.gra...@structuremonitoring.com
To: Stephen Liusati...@yahoo.com
Sent: Mon, November 29, 2010 12:58:25 AM
Subject: Re: [R] Where is gdata?

Hi, Stephen:  Have you solved the problem yet?  If no, see below.  Spencer

###
Hello, All:


Prof. Ripley suggested I remove RTools/perl from my path.  I did
that leaving Strawberry perl.  Then everything seemed to work appropriately.


Thanks to all.
Spencer


On 11/28/2010 7:49 AM, Gabor Grothendieck wrote:

On Sun, Nov 28, 2010 at 10:40 AM, Spencer Graves
spencer.gra...@structuremonitoring.com   wrote:

   I tried install.packages('gregmisc'), which Stephen said he had.
   Then  help(pac=gdata) seemed to work normally.  However, when I then
tried library(gdata), I got an error message from the the operating
system, saying perl.exe has stopped working.  I cancelled past that and
got a message gdata: Unable to load perl libaries needed by read.xls() ...
Run the function 'installXLSXsupport()'.  I tried 'installXLSXsupport()'
and again perl stopped working.  I quit R and tried
install.packages('gdata') again, and it killed perl again.


   Before installing 'gregmisc', I had tried install.packages('gdata') by
itself.  That seemed to work.  Then I manually removed it and tried
'gregmisc', as Stephen had, and got problems I don't know how to solve.


   ???
   Thanks,
   Spencer

##


library(gdata)

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLX' (Excel 97-2004) files.

gdata: Unable to load perl libaries needed by read.xls()
gdata: to support 'XLSX' (Excel 2007+) files.

gdata: Run the function 'installXLSXsupport()'
gdata: to automatically download and install the perl
gdata: libaries needed to support Excel XLS and XLSX formats.


Read ?installXLSXsupport






--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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

2010-11-28 Thread Joshua Wiley
Hi Eric,

I think this does what you want.  It may be a simple question, but
that does not necessarily mean the easiest/fastest answer is
intuitive.  Welcome to R!

dat - data.frame(v = 1:100)
## the with() is just a convenient way to avoid having to type
## dat$v every single time---similar to attach(), but cleaner
## the idea is to create three vectors, that are offset by removing
## either the first observation or the last
with(dat, (v[-1] - v[-length(v)])/v[-length(v)])

HTH,

Josh

On Sun, Nov 28, 2010 at 7:29 PM, eric ericst...@aol.com wrote:

 Just starting to learn R so excuse me if this is a simple question. I'm
 wondering how I get the percent difference in sequential values in one
 column of a dataframe. If I had a dataframe and one of the columns was
 value, how would I go about calculating  (v2-v1)/v1 (v3-v2)/v2
 (v4-v3)/v3 ...etc ?
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/How-do-I-subtract-sequential-values-tp3063019p3063019.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Array help

2010-11-28 Thread Joshua Wiley
Hi B,

What you need to do is pass a vector with the indices you want to
extract.  So, you have 1:7 (which expands to 1, 2, 3, ... 7) and 12:34
(which again expands).  How would you combine two sets of numbers?
c(), the combine or concatenate function.  Putting this in action:

mya - array(1:510, dim = c(34, 5, 3))

mya[c(1:7, 12:34), , ]

Do note that the row numbers will update unless they were explicitly
named.  So they will be numbered 1:30, not 1:7 and 12:34.

Cheers,

Josh


On Sun, Nov 28, 2010 at 6:36 PM, bfhancock brianfhanc...@gmail.com wrote:

 Hi! I am learning R and have a question that is probably fairly simple for
 those of you much more learned than I.

 I am messing with Arrays and am doing some simple stuff to get the hang of
 them.  I will have a seperate array already pulled up and it will have
 columns and rows.  I figured out that I can seperate these out with commands
 like array_name[,1,1].  Now, I have an array where I want to make a single
 array from a two ranges in the original array.  from 1:7 and 12:34.  I know
 if i just did it with 1:7 it is just array_name[1:7,,] and that is it.
 But i wanted 12:34 in there as well. I assumed at first that it would just
 be array_name[1:7  12:34,,] but was wrong.  Can anyone help me with this?
 Thanks so much!

 -B
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Array-help-tp3062992p3062992.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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Replacing several rows of a matrix at once

2010-11-28 Thread Bryan Hanson
Hello Folks.  This must be a silly question with a (not) obvious (to me)
answer.

Consider this:

tmp - matrix(1:200, nrow = 20)
vec - 300:309

tmp[9,] - vec # replacing one row works fine

p - c(3, 11, 17)
tmp[p,] - vec
# replacing multple rows pastes the values down a column and recycles vec.

What I want to do is replace multiple rows simultaneously at once.  I
suppose I can write a function, but this seems pretty fundamental so I feel
I must be missing some obvious alternative.  I'm feeling like I'm in the
Inferno!

TIA.  Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA

 sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

attached base packages:
 [1] splines   datasets  tools grid  grDevices graphics  utils
stats
 [9] methods   base

other attached packages:
 [1] survival_2.35-8gridExtra_0.7  GGally_0.2.2   xtable_1.5-6
 [5] mvbutils_2.5.1 ggplot2_0.8.8  proto_0.3-8reshape_0.8.3
 [9] ChemoSpec_1.46 seriation_1.0-2colorspace_1.0-1   TSP_1.0-1
[13] R.utils_1.5.3  R.oo_1.7.4 R.methodsS3_1.2.1  rgl_0.92.794
[17] lattice_0.19-13mvoutlier_1.4  plyr_1.2.1
RColorBrewer_1.0-2
[21] chemometrics_1.0   som_0.3-5  robustbase_0.5-0-1 rpart_3.1-46
[25] pls_2.1-0  pcaPP_1.8-3mvtnorm_0.9-92 nnet_7.3-1
[29] mclust_3.4.6   MASS_7.3-8 lars_0.9-7 gclus_1.3
[33] cluster_1.13.1 e1071_1.5-24   class_7.3-2

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


Re: [R] Array help

2010-11-28 Thread bfhancock

Josh, the data set is called StatTemps and is in the PASWR package.  I want
to make an array that involves only the 8 a.m. and a separate array that
involves only the 9 a.m. so i can get info on the temperatures in those
groups. So I still want it in the format of StatTemps but in two arrays that
are based on 8 a.m. or 9 a.m.I have been messing with this for a while.
And no it's not homework, I am just trying to learn R so I am more appealing
out in the field eventually.  They book I am using is confusing!  Hopefully
what I am trying to do isn't confusing.  I want to do an array that holds
the info from 1:6  12:22 for 8am and then 7:11  23:34 for 9am.  I was able
easily make two arrays based on sex by just putting in StatTemps[1:11,,] 
StatTemps[12:34,,] and assumed I could just go StatTemps[1:612:22,,] and
StatTemps[7:1123:34,,] but that didn't work. Any ideas? Thanks so much!

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

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


Re: [R] How do I subtract sequential values ?

2010-11-28 Thread Peter Ehlers

On 2010-11-28 19:38, Joshua Wiley wrote:

Hi Eric,

I think this does what you want.  It may be a simple question, but
that does not necessarily mean the easiest/fastest answer is
intuitive.  Welcome to R!

dat- data.frame(v = 1:100)
## the with() is just a convenient way to avoid having to type
## dat$v every single time---similar to attach(), but cleaner
## the idea is to create three vectors, that are offset by removing
## either the first observation or the last
with(dat, (v[-1] - v[-length(v)])/v[-length(v)])

HTH,

Josh



That's a good first-time user solution.
Then, since this is R, here's the next step:

 v - sample(50, 100, replace = TRUE)
 result - diff(v) / v[-length(v)]

Peter Ehlers


On Sun, Nov 28, 2010 at 7:29 PM, ericericst...@aol.com  wrote:


Just starting to learn R so excuse me if this is a simple question. I'm
wondering how I get the percent difference in sequential values in one
column of a dataframe. If I had a dataframe and one of the columns was
value, how would I go about calculating  (v2-v1)/v1 (v3-v2)/v2
(v4-v3)/v3 ...etc ?
--
View this message in context: 
http://r.789695.n4.nabble.com/How-do-I-subtract-sequential-values-tp3063019p3063019.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] Replacing several rows of a matrix at once

2010-11-28 Thread Michael Sumner
vec is being recycled column wise, so you can repeat each element the
required number of times:

tmp[p,] - rep(vec, each = length(p))

There's many ways to achieve this though, so it depends on what other
variations you might want to deal with.

Cheers, Mike.

On Mon, Nov 29, 2010 at 2:53 PM, Bryan Hanson han...@depauw.edu wrote:
 Hello Folks.  This must be a silly question with a (not) obvious (to me)
 answer.

 Consider this:

 tmp - matrix(1:200, nrow = 20)
 vec - 300:309

 tmp[9,] - vec # replacing one row works fine

 p - c(3, 11, 17)
 tmp[p,] - vec
 # replacing multple rows pastes the values down a column and recycles vec.

 What I want to do is replace multiple rows simultaneously at once.  I
 suppose I can write a function, but this seems pretty fundamental so I feel
 I must be missing some obvious alternative.  I'm feeling like I'm in the
 Inferno!

 TIA.  Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA

 sessionInfo()
 R version 2.12.0 (2010-10-15)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

 attached base packages:
  [1] splines   datasets  tools     grid      grDevices graphics  utils
 stats
  [9] methods   base

 other attached packages:
  [1] survival_2.35-8    gridExtra_0.7      GGally_0.2.2       xtable_1.5-6
  [5] mvbutils_2.5.1     ggplot2_0.8.8      proto_0.3-8        reshape_0.8.3
  [9] ChemoSpec_1.46     seriation_1.0-2    colorspace_1.0-1   TSP_1.0-1
 [13] R.utils_1.5.3      R.oo_1.7.4         R.methodsS3_1.2.1  rgl_0.92.794
 [17] lattice_0.19-13    mvoutlier_1.4      plyr_1.2.1
 RColorBrewer_1.0-2
 [21] chemometrics_1.0   som_0.3-5          robustbase_0.5-0-1 rpart_3.1-46
 [25] pls_2.1-0          pcaPP_1.8-3        mvtnorm_0.9-92     nnet_7.3-1
 [29] mclust_3.4.6       MASS_7.3-8         lars_0.9-7         gclus_1.3
 [33] cluster_1.13.1     e1071_1.5-24       class_7.3-2

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




-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsum...@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] Replacing several rows of a matrix at once

2010-11-28 Thread Joshua Wiley
Hi Bryan,

The reason vec gets recycled is that you are replacing more values
than vec has.  Just look at:

tmp[p, ]

this is 3 x 10 matrix, which you are trying to replace with a vector
of length 10.  If you want the replacement to occur without any
recycling, you'll need to make vec be a matrix itself or at least a
vector of length 30 (i.e., 3 * 10).  Or do you want it recycled but in
a different way than it is currently being recycled?  (see Michael's
response for that).

Cheers,

Josh

On Sun, Nov 28, 2010 at 7:53 PM, Bryan Hanson han...@depauw.edu wrote:
 Hello Folks.  This must be a silly question with a (not) obvious (to me)
 answer.

 Consider this:

 tmp - matrix(1:200, nrow = 20)
 vec - 300:309

 tmp[9,] - vec # replacing one row works fine

 p - c(3, 11, 17)
 tmp[p,] - vec
 # replacing multple rows pastes the values down a column and recycles vec.

 What I want to do is replace multiple rows simultaneously at once.  I
 suppose I can write a function, but this seems pretty fundamental so I feel
 I must be missing some obvious alternative.  I'm feeling like I'm in the
 Inferno!

 TIA.  Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA

 sessionInfo()
 R version 2.12.0 (2010-10-15)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

 attached base packages:
  [1] splines   datasets  tools     grid      grDevices graphics  utils
 stats
  [9] methods   base

 other attached packages:
  [1] survival_2.35-8    gridExtra_0.7      GGally_0.2.2       xtable_1.5-6
  [5] mvbutils_2.5.1     ggplot2_0.8.8      proto_0.3-8        reshape_0.8.3
  [9] ChemoSpec_1.46     seriation_1.0-2    colorspace_1.0-1   TSP_1.0-1
 [13] R.utils_1.5.3      R.oo_1.7.4         R.methodsS3_1.2.1  rgl_0.92.794
 [17] lattice_0.19-13    mvoutlier_1.4      plyr_1.2.1
 RColorBrewer_1.0-2
 [21] chemometrics_1.0   som_0.3-5          robustbase_0.5-0-1 rpart_3.1-46
 [25] pls_2.1-0          pcaPP_1.8-3        mvtnorm_0.9-92     nnet_7.3-1
 [29] mclust_3.4.6       MASS_7.3-8         lars_0.9-7         gclus_1.3
 [33] cluster_1.13.1     e1071_1.5-24       class_7.3-2

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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


Re: [R] How do I subtract sequential values ?

2010-11-28 Thread Joshua Wiley
On Sun, Nov 28, 2010 at 7:58 PM, Peter Ehlers ehl...@ucalgary.ca wrote:
 Then, since this is R, here's the next step:

  v - sample(50, 100, replace = TRUE)
  result - diff(v) / v[-length(v)]

Very nice!  It did not even occur to me to use diff() in this case,
though that is exactly what is needed and I've used it a hundred times
in other situations (I hope I'm like wine and get better with age
or)

Josh


 Peter Ehlers


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


Re: [R] Replacing several rows of a matrix at once

2010-11-28 Thread Peter Ehlers

On 2010-11-28 19:53, Bryan Hanson wrote:

Hello Folks.  This must be a silly question with a (not) obvious (to me)
answer.

Consider this:

tmp- matrix(1:200, nrow = 20)
vec- 300:309

tmp[9,]- vec # replacing one row works fine

p- c(3, 11, 17)
tmp[p,]- vec
# replacing multple rows pastes the values down a column and recycles vec.

What I want to do is replace multiple rows simultaneously at once.  I
suppose I can write a function, but this seems pretty fundamental so I feel
I must be missing some obvious alternative.  I'm feeling like I'm in the
Inferno!


Since matrices in R use column-major order, transpose first:

 ttmp - t(tmp)
 ttmp[, p] - vec
 (ans - t(ttmp))

Peter Ehlers



TIA.  Bryan
*
Bryan Hanson
Professor of Chemistry  Biochemistry
DePauw University, Greencastle IN USA


sessionInfo()

R version 2.12.0 (2010-10-15)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

attached base packages:
  [1] splines   datasets  tools grid  grDevices graphics  utils
stats
  [9] methods   base

other attached packages:
  [1] survival_2.35-8gridExtra_0.7  GGally_0.2.2   xtable_1.5-6
  [5] mvbutils_2.5.1 ggplot2_0.8.8  proto_0.3-8reshape_0.8.3
  [9] ChemoSpec_1.46 seriation_1.0-2colorspace_1.0-1   TSP_1.0-1
[13] R.utils_1.5.3  R.oo_1.7.4 R.methodsS3_1.2.1  rgl_0.92.794
[17] lattice_0.19-13mvoutlier_1.4  plyr_1.2.1
RColorBrewer_1.0-2
[21] chemometrics_1.0   som_0.3-5  robustbase_0.5-0-1 rpart_3.1-46
[25] pls_2.1-0  pcaPP_1.8-3mvtnorm_0.9-92 nnet_7.3-1
[29] mclust_3.4.6   MASS_7.3-8 lars_0.9-7 gclus_1.3
[33] cluster_1.13.1 e1071_1.5-24   class_7.3-2

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Replacing several rows of a matrix at once

2010-11-28 Thread Bryan Hanson
Thanks to Michael, Josh and Jorge - Problem fixed.  Michael's suggestion was
what I needed, but I wouldn't have ever conceptualized it that way, and
Jorge showed me how simple the function could be (at this hour, I was
imagining it would be more work).  Thanks guys.  Bryan


On 11/28/10 11:03 PM, Michael Sumner mdsum...@gmail.com wrote:

 vec is being recycled column wise, so you can repeat each element the
 required number of times:
 
 tmp[p,] - rep(vec, each = length(p))
 
 There's many ways to achieve this though, so it depends on what other
 variations you might want to deal with.
 
 Cheers, Mike.
 
 On Mon, Nov 29, 2010 at 2:53 PM, Bryan Hanson han...@depauw.edu wrote:
 Hello Folks.  This must be a silly question with a (not) obvious (to me)
 answer.
 
 Consider this:
 
 tmp - matrix(1:200, nrow = 20)
 vec - 300:309
 
 tmp[9,] - vec # replacing one row works fine
 
 p - c(3, 11, 17)
 tmp[p,] - vec
 # replacing multple rows pastes the values down a column and recycles vec.
 
 What I want to do is replace multiple rows simultaneously at once.  I
 suppose I can write a function, but this seems pretty fundamental so I feel
 I must be missing some obvious alternative.  I'm feeling like I'm in the
 Inferno!
 
 TIA.  Bryan
 *
 Bryan Hanson
 Professor of Chemistry  Biochemistry
 DePauw University, Greencastle IN USA
 
 sessionInfo()
 R version 2.12.0 (2010-10-15)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
  [1] splines   datasets  tools     grid      grDevices graphics  utils
 stats
  [9] methods   base
 
 other attached packages:
  [1] survival_2.35-8    gridExtra_0.7      GGally_0.2.2       xtable_1.5-6
  [5] mvbutils_2.5.1     ggplot2_0.8.8      proto_0.3-8        reshape_0.8.3
  [9] ChemoSpec_1.46     seriation_1.0-2    colorspace_1.0-1   TSP_1.0-1
 [13] R.utils_1.5.3      R.oo_1.7.4         R.methodsS3_1.2.1  rgl_0.92.794
 [17] lattice_0.19-13    mvoutlier_1.4      plyr_1.2.1
 RColorBrewer_1.0-2
 [21] chemometrics_1.0   som_0.3-5          robustbase_0.5-0-1 rpart_3.1-46
 [25] pls_2.1-0          pcaPP_1.8-3        mvtnorm_0.9-92     nnet_7.3-1
 [29] mclust_3.4.6       MASS_7.3-8         lars_0.9-7         gclus_1.3
 [33] cluster_1.13.1     e1071_1.5-24       class_7.3-2
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Where is gdata?

2010-11-28 Thread Gabor Grothendieck
On Sun, Nov 28, 2010 at 11:54 AM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:
 Hello, All:


      Prof. Ripley suggested I remove RTools/perl from my path.  I did that
 leaving Strawberry perl.  Then everything seemed to work appropriately.


1. If you have the Rtools perl prior to any other perl on your path
then it does not use your path to find perl but rather it checks which
perl executable is associated with the .pl extension on your machine
and uses that.  Thus it should not be necessary to remove rtools from
your path if you have pl associated with perl.

2. If you have multiple versions of perl installed and you want
read.xls to use one which is not first on your path and you don't want
to change your system configuration you can use the perl= argument to
installXLSXsupport and to read.xls to specify the path to the perl.exe
that you do want to  use.

That being said its best not to have Rtools on your path, not only
because of its version of perl but also because it puts a find command
on your path which overrides Windows' own find command.  There is an
Rtools.bat command at http://batchtools.googlecode.com that will
temporarily put Rtools on your path in the current Windows console
session only so that you can normally keep it off your path and only
put it on your path in console sessions that need it.  You simply run
it without arguments, e.g.

Rtools
Rcmd build mypackage
etc.

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

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


Re: [R] Array help

2010-11-28 Thread David Winsemius


On Nov 28, 2010, at 10:56 PM, bfhancock wrote:



Josh, the data set is called StatTemps and is in the PASWR package.   
I want
to make an array that involves only the 8 a.m. and a separate array  
that
involves only the 9 a.m. so i can get info on the temperatures in  
those
groups. So I still want it in the format of StatTemps but in two  
arrays that
are based on 8 a.m. or 9 a.m.I have been messing with this for a  
while.
And no it's not homework, I am just trying to learn R so I am more  
appealing
out in the field eventually.  They book I am using is confusing!   
Hopefully
what I am trying to do isn't confusing.  I want to do an array that  
holds
the info from 1:6  12:22 for 8am and then 7:11  23:34 for 9am.  I  
was able
easily make two arrays based on sex by just putting in  
StatTemps[1:11,,] 
StatTemps[12:34,,] and assumed I could just go  
StatTemps[1:612:22,,] and
StatTemps[7:1123:34,,] but that didn't work. Any ideas? Thanks so  
much!




It may not be an array (since time values don't play very well with  
that data structure.)  If there is time as an index, it may be a more  
complex object such as a time-series or zoo. Check with str().


--
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] formulas with non-syntactic names and an Error() term

2010-11-28 Thread RICHARD M. HEIBERGER
## This is an example where ``-quoted non-syntactic names work in
## simple formulas, but not in formulas with an Error() term.
## Is this intentional or an oversight when ``-quoted names were added?

tmp - data.frame(y=1:6,
  `x^1`=factor(c(1,2,1,2,1,2)),
  `x^2`=factor(c(1,1,2,2,3,3)),
  check.names=FALSE)
tmp
aov(y ~ `x^1` + `x^2`, data=tmp) ## ok
aov(y ~ `x^1` + `x^2` + Error(1), data=tmp) ## error
## Error in `[.data.frame`(mf, xvars) : undefined columns selected

tmp2 - data.frame(tmp)
tmp2
aov(y ~ x.1 + x.2 + Error(1), data=tmp2) ## this is ok

## this is Windows R-2.12.0
## Rich

[[alternative HTML version deleted]]

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


Re: [R] How do I subtract sequential values ?

2010-11-28 Thread Michael Bedward
On 29 November 2010 15:09, Joshua Wiley jwiley.ps...@gmail.com wrote:
 (I hope I'm like wine and get better with age or)


Sigh, me too - but I suspect I'm heading more towards vinegar

Michael

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


Re: [R] Where is gdata?

2010-11-28 Thread Stephen Liu
Hi Spencer,

I don't have RTools installed.  Therefore I can't find RTools/perl

 library(RTools)
Error in library(RTools) : there is no package called 'RTools'

 library(Ecdat)
no complaint

 data()
The datasets on Ecdat are added to the big list.

However
 data(package='Ecdat')
displays the datasets list of Ecdat

B.R.
Stephen L







From: Spencer Graves spencer.gra...@structuremonitoring.com

Sent: Mon, November 29, 2010 11:33:12 AM
Subject: Re: [R] Where is gdata?

Hi, Stephen:


   What operating system do you have?  From the path you cite, I 
assume you are using some version of Windows.


   Wikipedia on perl says there are two primary version of perl 
for Windows  Strawberry perl, which is free, open source, and 
ActivePerl, which is free but not open source.  I've been using 
Strawberry perl without any apparent problems due to the version.  When 
I removed ~Rtools/perl from my path, it still had Strawberry perl, and 
'installXLSXsupport()' worked with my installation of Strawberry perl, 
when it had not worked with ~Rtools/perl.  You can download Strawberry 
perl from http://strawberryperl.com;.  However,  
RSiteSearch('strawberry perl') produced 0 matches, while 
RSiteSearch(ActivePerl) returned 2 matches and RSiteSearch(Active 
Perl) found 10 matches.


After downloading and installing one of these, if 
'installXLSXsupport()' still does not work, you need to check the path: 
If 'installXLSXsupport()' does not work with Strawberry perl as the 
first perl in your path, then you may need to install an appropriate 
package from CPAN.  More than that, I cannot answer.  However, if you 
download and install one of these two versions of perl and still have 
the problem, please report what you've done and they symptoms you get to 
this list.  Also, please include sessionInfo() with your reply.


   Hope this helps.
   Spencer


On 11/28/2010 6:38 PM, Stephen Liu wrote:
 Hi Spencer,

 Win 7

 I can't find the folders RTools\perl

 perl is on C:\Users\satimis\My Document\R\win-library\2.12\gdata\perl

 Nor I can find the folder Strawberry perl.  Can you help?  TIA


 B.R.
 Stephen L




 
 From: Spencer Gravesspencer.gra...@structuremonitoring.com

 Sent: Mon, November 29, 2010 12:58:25 AM
 Subject: Re: [R] Where is gdata?

 Hi, Stephen:  Have you solved the problem yet?  If no, see below.  Spencer

 ###
 Hello, All:


 Prof. Ripley suggested I remove RTools/perl from my path.  I did
 that leaving Strawberry perl.  Then everything seemed to work appropriately.


 Thanks to all.
 Spencer


 On 11/28/2010 7:49 AM, Gabor Grothendieck wrote:
 On Sun, Nov 28, 2010 at 10:40 AM, Spencer Graves
 spencer.gra...@structuremonitoring.com   wrote:
I tried install.packages('gregmisc'), which Stephen said he had.
Then  help(pac=gdata) seemed to work normally.  However, when I then
 tried library(gdata), I got an error message from the the operating
 system, saying perl.exe has stopped working.  I cancelled past that and
 got a message gdata: Unable to load perl libaries needed by read.xls() ...
 Run the function 'installXLSXsupport()'.  I tried 'installXLSXsupport()'
 and again perl stopped working.  I quit R and tried
 install.packages('gdata') again, and it killed perl again.


Before installing 'gregmisc', I had tried install.packages('gdata') 
by
 itself.  That seemed to work.  Then I manually removed it and tried
 'gregmisc', as Stephen had, and got problems I don't know how to solve.


???
Thanks,
Spencer

 ##

 library(gdata)
 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLX' (Excel 97-2004) files.

 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLSX' (Excel 2007+) files.

 gdata: Run the function 'installXLSXsupport()'
 gdata: to automatically download and install the perl
 gdata: libaries needed to support Excel XLS and XLSX formats.

 Read ?installXLSXsupport




-- 
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567


[[alternative HTML version deleted]]

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


Re: [R] Where is gdata?

2010-11-28 Thread Spencer Graves
Hi, Stephen:


   RTools is not a standard R package.  It is a collection of 
software tools for building R packages.  If you use R much, I highly 
recommend you learn about R package development, because I believe doing 
so can increase your software development productivity.


   However, for this, you do NOT need RTools.  For now, please 
ignore RTools, and install either Strawberry perl or ActivePerl.  I 
suggest you go to http://strawberryperl.com 
http://strawberryperl.com/ and click on Download Strawberry Perl 
5.12.1.0.  This is the version I have.  Then do the obvious things to 
install it.  If it fixed your problem, great.  Otherwise, please report 
to this list what you've tried, the error you got, and sessionInfo().


   Hope this helps.
   Spencer


On 11/28/2010 8:49 PM, Stephen Liu wrote:
 Hi Spencer,

 I don't have RTools installed.  Therefore I can't find RTools/perl

 library(RTools)
 Error in library(RTools) : there is no package called 'RTools'

 library(Ecdat)
 no complaint

 data()
 The datasets on Ecdat are added to the big list.

 However
 data(package='Ecdat')
 displays the datasets list of Ecdat

 B.R.
 Stephen L






 
 From: Spencer Gravesspencer.gra...@structuremonitoring.com
 To: Stephen Liusati...@yahoo.com; r-helpr-help@r-project.org
 Sent: Mon, November 29, 2010 11:33:12 AM
 Subject: Re: [R] Where is gdata?

 Hi, Stephen:


 What operating system do you have?  From the path you cite, I
 assume you are using some version of Windows.


 Wikipedia on perl says there are two primary version of perl
 for Windows  Strawberry perl, which is free, open source, and
 ActivePerl, which is free but not open source.  I've been using
 Strawberry perl without any apparent problems due to the version.  When
 I removed ~Rtools/perl from my path, it still had Strawberry perl, and
 'installXLSXsupport()' worked with my installation of Strawberry perl,
 when it had not worked with ~Rtools/perl.  You can download Strawberry
 perl from http://strawberryperl.com;.  However,
 RSiteSearch('strawberry perl') produced 0 matches, while
 RSiteSearch(ActivePerl) returned 2 matches and RSiteSearch(Active
 Perl) found 10 matches.


  After downloading and installing one of these, if
 'installXLSXsupport()' still does not work, you need to check the path:
 If 'installXLSXsupport()' does not work with Strawberry perl as the
 first perl in your path, then you may need to install an appropriate
 package from CPAN.  More than that, I cannot answer.  However, if you
 download and install one of these two versions of perl and still have
 the problem, please report what you've done and they symptoms you get to
 this list.  Also, please include sessionInfo() with your reply.


 Hope this helps.
 Spencer


 On 11/28/2010 6:38 PM, Stephen Liu wrote:
 Hi Spencer,

 Win 7

 I can't find the folders RTools\perl

 perl is on C:\Users\satimis\My Document\R\win-library\2.12\gdata\perl

 Nor I can find the folder Strawberry perl.  Can you help?  TIA


 B.R.
 Stephen L




 
 From: Spencer Gravesspencer.gra...@structuremonitoring.com
 To: Stephen Liusati...@yahoo.com
 Sent: Mon, November 29, 2010 12:58:25 AM
 Subject: Re: [R] Where is gdata?

 Hi, Stephen:  Have you solved the problem yet?  If no, see below.  Spencer

 ###
 Hello, All:


  Prof. Ripley suggested I remove RTools/perl from my path.  I did
 that leaving Strawberry perl.  Then everything seemed to work appropriately.


  Thanks to all.
  Spencer


 On 11/28/2010 7:49 AM, Gabor Grothendieck wrote:
 On Sun, Nov 28, 2010 at 10:40 AM, Spencer Graves
 spencer.gra...@structuremonitoring.comwrote:
 I tried install.packages('gregmisc'), which Stephen said he had.
 Then  help(pac=gdata) seemed to work normally.  However, when I then
 tried library(gdata), I got an error message from the the operating
 system, saying perl.exe has stopped working.  I cancelled past that and
 got a message gdata: Unable to load perl libaries needed by read.xls() ...
 Run the function 'installXLSXsupport()'.  I tried 'installXLSXsupport()'
 and again perl stopped working.  I quit R and tried
 install.packages('gdata') again, and it killed perl again.


 Before installing 'gregmisc', I had tried install.packages('gdata')
 by
 itself.  That seemed to work.  Then I manually removed it and tried
 'gregmisc', as Stephen had, and got problems I don't know how to solve.


 ???
 Thanks,
 Spencer

 ##

 library(gdata)
 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLX' (Excel 97-2004) files.

 gdata: Unable to load perl libaries needed by read.xls()
 gdata: to support 'XLSX' (Excel 2007+) files.

 gdata: Run the function 'installXLSXsupport()'
 gdata: to automatically download and install the perl
 gdata: libaries needed to support 

Re: [R] Where is gdata?

2010-11-28 Thread Gabor Grothendieck
On Sun, Nov 28, 2010 at 11:49 PM, Stephen Liu sati...@yahoo.com wrote:
 Hi Spencer,

 I don't have RTools installed.  Therefore I can't find RTools/perl

 library(RTools)
 Error in library(RTools) : there is no package called 'RTools'


Rtools is not an R package. Its a collection of UNIX-like windows
software and other software such as perl.   It is used by R package
authors to supply the additional tools that are needed on Windows to
build R packages from source.  If you don't need to build R packages
(that is you are content to use the Windows binaries) then you don't
need Rtools.  Also I don't think this or my other comments have
anything to do with your problem.  My comments were primarily in
response to Spencer's comments.

Regarding your question about gdata,

1. if gdata did not get installed then just do this from within R:

install.packages(gdata)

(or use the Packages | Install Package(s) menu to accomplish same).
If that still does not result in gdata being installed then try a
different mirror.

2. there is no gdata() function in the gdata package so your line
which tries to call it would be expected to return an error even if
gdata were present.

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

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


Re: [R] Where is gdata?

2010-11-28 Thread Gabor Grothendieck
On Mon, Nov 29, 2010 at 12:06 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Regarding your question about gdata,

 1. if gdata did not get installed then just do this from within R:

 install.packages(gdata)

 (or use the Packages | Install Package(s) menu to accomplish same).
 If that still does not result in gdata being installed then try a
 different mirror.

 2. there is no gdata() function in the gdata package so your line
 which tries to call it would be expected to return an error even if
 gdata were present.


3. If you are not sure whether or not you have gdata installed try:

library(gdata)

If that works (i.e. you get no error message) then you have gdata
installed and you can get help like this:

library(help = gdata)

and for each topic listed you can get help like this:

?read.xls

and so on.

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

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


Re: [R] Where is gdata?

2010-11-28 Thread Stephen Liu
Hi Gabor,

 library(gdata)
no complaint

 library(help = gdata)
It works.  Thanks

 ?read.xls
I must run ??read.xls

All the topics I tested must use ??topic_name

B.R.
Stephen L





From: Gabor Grothendieck ggrothendi...@gmail.com

Cc: Spencer Graves spencer.gra...@structuremonitoring.com; r-help 
r-help@r-project.org
Sent: Mon, November 29, 2010 1:16:35 PM
Subject: Re: [R] Where is gdata?

On Mon, Nov 29, 2010 at 12:06 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Regarding your question about gdata,

 1. if gdata did not get installed then just do this from within R:

 install.packages(gdata)

 (or use the Packages | Install Package(s) menu to accomplish same).
 If that still does not result in gdata being installed then try a
 different mirror.

 2. there is no gdata() function in the gdata package so your line
 which tries to call it would be expected to return an error even if
 gdata were present.


3. If you are not sure whether or not you have gdata installed try:

library(gdata)

If that works (i.e. you get no error message) then you have gdata
installed and you can get help like this:

library(help = gdata)

and for each topic listed you can get help like this:

?read.xls

and so on.

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Where is gdata?

2010-11-28 Thread Liviu Andronic
On Mon, Nov 29, 2010 at 7:01 AM, Stephen Liu sati...@yahoo.com wrote:
 ?read.xls
 I must run ??read.xls

Not if you
 library(gdata)

first. Then
 ?read.xls

should work.

Regards
Liviu

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

2010-11-28 Thread Spencer Graves

Hi, Liviu:


  Doesn't he need a version of perl installed with a particular 
perl package for read.xls to work properly?



  Spencer


On 11/28/2010 10:40 PM, Liviu Andronic wrote:

On Mon, Nov 29, 2010 at 7:01 AM, Stephen Liusati...@yahoo.com  wrote:

?read.xls

I must run ??read.xls


Not if you

library(gdata)

first. Then

?read.xls

should work.

Regards
Liviu

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





--
Spencer Graves, PE, PhD
President and Chief Operating Officer
Structure Inspection and Monitoring, Inc.
751 Emerson Ct.
San José, CA 95126
ph:  408-655-4567

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


Re: [R] Comparing two functions

2010-11-28 Thread Bert Gunter
It is perhaps worth mentioning in this context that in the R language,
functions and language components (like formulas, expressions, etc.)
are full first class objects -- which means basically that they can be
treated like any data object: e.g. passed as arguments to a function,
returned as values of a function, etc.

So, for example, Gabor's suggestion to pass the function as the
argument of your master function is a common R construct that
returns the values computed by the function you passed as an argument.
But you could also do it this way:

masterf - function(rng=c(norm,unif))
{
   rng - match.arg(rng)
   switch(rng,
 norm = rnormlra,
 unif = runiflra
   )
}

Note that the return object is the function matching the possibly
abbreviated argument name (courtesy of match.arg()), _not_ the value
of the function. So this function could be called as, e.g.

masterf(n)(n=100, mean=10)

To be sure, this is a silly and cumbersome way to do things
here.Gabor's solution is what you want I think.**  But this kind of
approach can be very handy in certain circumstances and does give you
some sense of what can be done in R that may be unfamiliar to those
used to procedural languages like C or Fortran (or Java?).

Cheers,
Bert Gunter
Genentech Nonclinical Statistics

** His approach also has the advantage of explicitly passing the
function you want to masterf rather than forcing R to look for it (in
the environment in which masterf was defined). More typically, the
function would actually be defined within masterf using the arguments
passed to masterf. But that's another story (scoping).

On Sun, Nov 28, 2010 at 4:58 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Sun, Nov 28, 2010 at 5:53 AM, Ira Sharenow irasharenow...@yahoo.com 
 wrote:
 Hi. I am new to R and facing a problem that I cannot solve.

 I am writing some basic functions. Then I would like to have a master 
 function that allows me to call one of the functions which I created, but I 
 cannot figure out how to do so.

 Below is an example. The functions rnormIra and runifIra both seem to work 
 fine. I do not get an error message when entering the definition of the 
 master function randomIra; however, it fails when I use it to call another 
 function.

 rnormIra = function(n, mean) {
  return(rnorm(n,mean,1))
 }
 rnormIra(10,100) #works fine

 runifIra = function(n,min,max) {
  return(runif(n,min,max))
 }
 runifIra(5,20,30) #works fine

 randomIra = function(f, ...) {
  if(f == rnormIra) {
   return(rnormIra(n,mean))
  }
  else {
        return(runifIra(n,min,max))
  }
 } #no error messages

 randomIra(rnormIra, n = 5, mean = 20) #FAILS
 randomIra(runifIra, n = 5, min = 10, max = 25) #FAILS

 do.call(randomIra,list(rnormIra,5,20)) #FAILS


 Try this:

 randomIra - function(f, ...) if (identical(f, rnormIra))
 rnormIra(...) else runifIra(...)

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

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


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

2010-11-28 Thread Liviu Andronic
Dear Spencer

On Mon, Nov 29, 2010 at 8:05 AM, Spencer Graves
spencer.gra...@structuremonitoring.com wrote:
      Doesn't he need a version of perl installed with a particular perl
 package for read.xls to work properly?

I really don't know. I assume that, if the package was installed and
could be loaded, the object 'read.xls' would  be present in the
environment along with the associated ?read.xls help page. It felt as
if the original poster failed to load the package before trying to
access the help pages. The question didn't pertain to the actual
functionality of read.xls().

Best regards
Liviu



      Spencer


 On 11/28/2010 10:40 PM, Liviu Andronic wrote:

 On Mon, Nov 29, 2010 at 7:01 AM, Stephen Liusati...@yahoo.com  wrote:

 ?read.xls

 I must run ??read.xls

 Not if you

 library(gdata)

 first. Then

 ?read.xls

 should work.

 Regards
 Liviu

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




 --
 Spencer Graves, PE, PhD
 President and Chief Operating Officer
 Structure Inspection and Monitoring, Inc.
 751 Emerson Ct.
 San José, CA 95126
 ph:  408-655-4567





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