Re: [R] help with R

2010-06-13 Thread Berend Hasselman


li li-13 wrote:
 
 Hi all,
I want to solve the following equation for x with rho - 0.5
 
pnorm(-x)*pnorm((rho*dnorm(x)/pnorm(x)-x)/sqrt(1-rho^2))==0.05
 
Is there a function in R to do this?
 

Or if you wish to try different values of rho

f - function(x, rho) {
 pnorm(-x)*pnorm((rho*dnorm(x)/pnorm(x)-x)/sqrt(1-rho^2))-0.05 
}

uniroot(f,c(-3,3),rho=.5)
uniroot(f,c(-3,3),rho=.3)

/Berend

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

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


[R] How to output text to sink without initial line number [1], and data frame line by line without column names

2010-06-13 Thread Nevil Amos
I want to output a text file assembeld from various soruces within r ( 
actually as a genepop file)


the output should be formatted line 1 text comment
   line 2:n  selected 
column names from data frame
line n+1on lines of 
selected columns  from data frame one row at a time



I have the following code, but cannot see how to remove the line numbers 
and omit column names form the line by line data frame output


col1-c(2,45,67)
col2-c(a,B,C)
col3-c(234,44,566)
mydf-as.data.frame(cbind(col1,col2,col3))
n-ncol(mydf)
nr-nrow(mydf)
sink(test.txt)

print(I will be including text of various sorts in this file so cannot 
use print table or similar command)

for (i in 1:n){
print(colnames(mydf[i]),quote=F) }
for (j in 1:nr){
print(mydf[j,c(2:n)],quote=F,row.names=F)}
sink()

The test.txt contains:

[1] I will be including text of various sorts in this file so cannot 
use print table or similar command

[1] col1
[1] col2
[1] col3
 col2 col3
a  234
 col2 col3
B   44
 col2 col3
C  566

what I would like in test.txt  is:

I will be including text of various sorts in this file so cannot use 
print table or similar command

col1
col2
col3
 a  234
 B   44
 C  566

Many thanks

Nevil Amos

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 output text to sink from data frame line by line without column names

2010-06-13 Thread Nevil Amos
OK I see how to remove the line numbers[1] etc by using cat instead of 
print, but cannot work out how to remove the column names from the data 
frame output


On 13/06/2010 4:21 PM, Nevil Amos wrote:
I want to output a text file assembeld from various soruces within r ( 
actually as a genepop file)


the output should be formatted line 1 text comment
   line 2:n  selected 
column names from data frame
line n+1on lines 
of selected columns  from data frame one row at a time



I have the following code, but cannot see how to remove the line 
numbers and omit column names form the line by line data frame output


col1-c(2,45,67)
col2-c(a,B,C)
col3-c(234,44,566)
mydf-as.data.frame(cbind(col1,col2,col3))
n-ncol(mydf)
nr-nrow(mydf)
sink(test.txt)

print(I will be including text of various sorts in this file so 
cannot use print table or similar command)

for (i in 1:n){
print(colnames(mydf[i]),quote=F) }
for (j in 1:nr){
print(mydf[j,c(2:n)],quote=F,row.names=F)}
sink()

The test.txt contains:

[1] I will be including text of various sorts in this file so cannot 
use print table or similar command

[1] col1
[1] col2
[1] col3
 col2 col3
a  234
 col2 col3
B   44
 col2 col3
C  566

what I would like in test.txt  is:

I will be including text of various sorts in this file so cannot use 
print table or similar command

col1
col2
col3
 a  234
 B   44
 C  566

Many thanks

Nevil Amos


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

2010-06-13 Thread vijaysheegi

Yes i am asking how to install RSQLite packagein windows.Please help on this
regards

On 6/11/10, david.jessop [via R] 
ml-node+2251498-1601505055-288...@n4.nabble.comml-node%2b2251498-1601505055-288...@n4.nabble.com
wrote:

 Are you asking how to install the RSQLite package or how to create a
 SQLite database?  The two are somewhat distinct questions. RSQLite is
 just a package of functions for R to be able to access data in an SQLite
 database. There isn't a separate SQLite program - just a library that is
 compiled into RSQLite.

 Regards

 David


 -Original Message-
 From: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2251498i=0[mailto:[hidden
 email] http://user/SendEmail.jtp?type=nodenode=2251498i=1]
 On Behalf Of vijaysheegi
 Sent: 10 June 2010 16:22
 To: [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=2
 Subject: [R] HOW to install RSQLite database


 Please let me know where i have to type below thing to  RSQLite database
 get installed.Please let me know the solution.Thanks in advance





 RSQLite -- Embedding the SQLite engine in R

 (The RSQLite package includes a recent copy of the SQLite distribution
 from http://www.sqlite.org http://www.sqlite.org/?by-user=t.)

 Installation
 

 There are 3 alternatives for installation:

 1. Simple installation:

   R CMD INSTALL RSQLite-.tar.gz

the installation automatically detects whether SQLite is
available in any of your system directories;  if it's not
available, it installs the SQLite engine and the R-SQLite
interface under the package directory $R_PACKAGE_DIR/sqlite.

 2. If you have SQLite installed in a non-system directory (e.g,
in $HOME/sqlite),

a) You can use

   export PKG_LIBS=-L$HOME/sqlite/lib -lsqlite
   export PKG_CPPFLAGS=-I$HOME/sqlite/include

   R CMD INSTALL RSQLite-.tar.gz

b) or you can use the --with-sqlite-dir configuration argument

   R CMD INSTALL --configure-args=--with-sqlite-dir=$HOME/sqlite \
 RSQLite-.tar.gz

 3. If you don't have SQLite but you rather install the version we
 provide
into a directory different than the RSQLite package, for instance,
$HOME/app/sqlite, use

   R CMD INSTALL --configure-args=--enable-sqlite=$HOME/app/sqlite \
 RSQLite-.tar.gz

 Usage
 -

 Note that if you use an *existing* SQLite library that resides in a
 non-system directory (e.g., other than /lib, /usr/lib, /usr/local/lib)
 you may need to include it in our LD_LIBRARY_PATH, prior to invoking R.

 For instance

 export LD_LIBRARY_PATH=$HOME/sqlite/lib:$LD_LIBRARY_PATH
 R
  library(help=RSQLite)
  library(RSQLite)

 (if you use the --enable-sqlite=DIR configuration argument, the SQLite
 library is statically linked to the RSQLite R package, and you need not
 worry about setting LD_LIBRARY_PATH.)



 --
 View this message in context:
 http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604phttp://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p?by-user=t
 2250604.html
 Sent from the R help mailing list archive at Nabble.com.

 [[alternative HTML version deleted]]

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=3mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 Issued by UBS AG or affiliates to professional investors...{{dropped:30}}

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=4mailing 
 list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 --
 View message @
 http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p2251498.html
 To unsubscribe from HOW to install RSQLite database, click here (link 
 removed) =.





-- 
vijayamahantesh

-- 
View this message in context: 
http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p2253249.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

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


[R] Weighted Average application on Summary Dataset

2010-06-13 Thread RaoulD

Hi,

I have 2 huge datasets - May and Jun - a miniscule sample of one is given
below. I am trying to do 2 things with these datasets. I need to verify if
the weighted average of variable A for a Reason in Jun is same/different
from the same for May. To do this I am first computing the weighted average
for each SubReason using a function I wrote. 

Where I need help is applying the function on both the datasets to arrive at
weighted averages for each SubReason. Then, I would like to know what the
best way would be, to compare the weighted average for a sub reason across 2
datasets to be able to state that there is a difference - t-test,ANOVA?
Would greatly appreciate any help!! The function I wrote for weighted
average computation is given below the dataset.

One of the datasets:

Reason  SubReasonA  N
A  SR11115  29
B  SR2734   24
B  SR21054  31
A  Sr1600   43
A  SR31033  60
A  Sr11163  30
B  SR4732   43
B  SR4988   70
A  SR3569   25
B  SR41073  65

Output I require:
R   SR  WA_A   N (Sum of N)
A   SR1912.0098  102
SR3896.5294118   85
B   SR2914.3636364   55
SR4957.1966292   178
(Weighted Average 
of A for N weights)

# FUNCTION TO CALCULATE THE WEIGHTED AVERAGE FOR A WEIGHTED BY N   
WA-function(A,N) {
 sp_A-c(A %*% N)
 sum_N-sum(N)
 WA-sp_A/sum_N   
 return(WA)  
 }

Thanks in advance!
Raoul




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Weighted-Average-application-on-Summary-Dataset-tp2253239p2253239.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] calling a function with new inputs every 1 minute

2010-06-13 Thread schuster

How about  
Sys.sleep(60)
in a loop from 1 to 500?

?Sys.sleep 

On Saturday 12 June 2010 08:45:32 pm KstuS wrote:
 I have inputs to a function which are changing all the time - I pull these
 values from the internet.  I then apply a function to the values.  What I'd
 like to do is automate the process so it runs every one minute and adds the
 output of the function as a new element of a vector.  Pseudo code:
 
 at Start time:
 input1_t0, input2_t0, input3_t0
 function(input1_t0, input2_t0, input3_t0)
 function_result_0
 
 at Time T2 (say one minute later)
 input1_t1, input2_t1, input3_t1
 function(input1_t1, input2_t1, input3_t1
 function_result_1
 ...
 
 end_result - c(function_result_0, function_result_1, function_result_2,
 ..., n)
 
 Ideally I'd want to do this every 1 minute for the next 500 minutes.
 

-- 

Friedrich Schuster
Dompfaffenweg 6
69123 Heidelberg

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

2010-06-13 Thread Data Monkey
I'm pretty new to R, but have experience with other languages, both OO and 
scripting.

I'm trying to add support for R to my text editor of choice and to do this I 
need a list of installed commands I can markup with XML.
I'd then simply feed in the marked up list into my text editor's library and 
I'm off.

I've done this in Stata before using the following command:
getcmds using ~/Desktop/StataCommands.txt

Does anyone know of a way to do this in R?

Any pointers much appreciated.

Thanks!

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


[R] How to write a customized hclust algorithm in R?

2010-06-13 Thread Tal Galili
Hello dear R-help mailing list members,

I wish to create an hclust object which will be based on
a customized hierarchical clustering algorithm, programmed in R.

After looking into the hclust function, I noticed that the algorithms
themselves are implemented in Fortran.  In order for me to implement my
algorithm in R, it would be very helpful if there was some example of
implementing (even one of) these algorithms in R.  Which leads me to my
question:
*Is there an R implementation of hclust internal Fortran algorithmic
functions?*

Thanks in advance for any help,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] Scope and sapply

2010-06-13 Thread Berend Hasselman


Worik R wrote:
 
 ...
 
 N - 10
 ## x simulate a return series
 x - runif(N)-.5
 
 ## Build an array of cumulative returns of a portfolio starting with $1 as
 it changes over time
 y - rep(0, length(x))
 y[1] - 1+1*x[1]
 for(i in 2:N){
   y[i] - y[i-1]+y[i-1]*x[i]
 }
 
 ## y is that return series.  Use
 test.1 - function(r.in){
   v - rep(0, length(r.in))
   foo - function(i, r){
 if(i == 1){
   s - 1
 }else{
   s - v[i-1]
 }
 v[i] - s + s*r[i]
 return(v[i])
   }
   return(sapply(1:length(r.in), foo, r.in))
 }
 

How about

cumprod(1+x)

/Berend
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Scope-and-sapply-tp2253158p2253313.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] Break in the y-axis

2010-06-13 Thread Jim Lemon

On 06/13/2010 01:48 PM, beloitstudent wrote:


Hello all,

I have been having trouble getting a break in my y-axis.  All of my data
points are up around 100-200, but the graph has to start at zero, so i would
like to remove all the white space using a break symbol.  I have been able
to get the break and labels to be correct, however, I can't seem to get the
data to match the axis anymore.  I must be using the axis.break() in plotrix
incorrectly, but I cannot see where my issue is.  This is what I have so
far.

##
library(plotrix)

par(mar=c(6,8,4,4))
###Data
Saline- structure(list(Time = c(-20L, 0, 30L, 45L, 60L, 80L,
110L,140L,200L, 260L, 320L), Average =
c(119.250,118.750,117.500,132.75,151.875,159.75,142.75,160,168,167.125,143),SEM=c(2.211,2.569,2.665,5.435146394,6.208741369,8.363550657,8.51349469,14.30284687,15.93865792,16.76541326,13.796)),
.Names = c(Time (min), Arterial Plasma Glucose (µg/mL), SEM), class =
data.frame, row.names = c(1, 2,3, 4, 5, 6, 7, 8, 9,
10, 11))

Ex- structure(list(Time = c(-20L, 0, 30L, 45L, 60L, 80L, 110L,140L,200L,
260L, 320L), Average =
c(117.500,117.625,117.375,134.5,166.25,173.5,164.25,162.5,160.375,150.25,139.875),SEM
=
c(1.484614978,1.748906364,1.761,5.613395058,9.642063459,9.493284415,8.220804866,8.967059901,11.91626825,11.27169111,10.92915498)),
.Names = c(Time (min), Arterial Plasma Glucose (µg/mL), SEM), class =
data.frame, row.names = c(1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11))

plotted data with error bars
plotCI(x=Saline [,1],y=Saline [,2], uiw=Saline [,3], err=y,
pt.bg=par(bg),pch=19, cex=2.5 ,gap=0, sfrac=0.005,
xlim=c(-20,340),xaxp=c(-20,320,12), xlab=Time (min),
ylim=c(0,200),yaxp=c(0,200,10), ylab=Arterial Plasma\nGlucose (µg/mL),
las=1, axes=FALSE, font.lab=2.2,cex.lab=1.6)

plotCI(x=Ex [,1],y=Ex [,2], uiw=Ex [,3], err=y,pt.bg=white,pch=21,
col=black,cex=2.5 ,gap=0, sfrac=0.005, xlim=c(-20,340),xaxp=c(-20,320,12),
xlab=Time (min), ylim=c(0,200),  yaxp=c(0,200,10), ylab=Arterial
Plasma\nGlucose (µg/mL), las=1, font.lab=2.2, axes=FALSE, add=TRUE,
cex.lab=1.9)

##x-axis
axis(1, at=c(-20, 0, 30, 45, 60, 80, 110, 140, 200, 260,
320), lwd=2, font=2, pos=0,cex.axis=.9)

y-axis
axis(2, las=1, at=c(0,40,60,80,100,120, 140), labels=c(0, 100, 120,
140, 160, 180, 200), lwd=2, font=2, pos=-20, cex.axis=1.7)

#axis break
axis.break(2, 20, style=slash)


As you can see, my data does not fit my axis anymore.  Any help with this
problem would be fantastic.  Thanks!


Hi beloitstudent,
You have two problems here. First, if you want the plotted values to 
match the offset labels on the y-axis, you are going to have to apply 
the same offset to the y values.


plotCI(x=Saline [,1],y=Saline [,2]-60,...
plotCI(x=Ex [,1],y=Ex [,2]-60,...

The other problem is mine, I guess. I hadn't thought of offset axes when 
writing axis.break, so I've added an argument for pos as in the axis 
function. The modified function is attached, and will be in the next 
version of plotrix. Thanks for bringing my attention to this.


Jim

# axis.break places a break marker at the position breakpos 
# in user coordinates on the axis nominated - see axis().

axis.break-function(axis=1,breakpos=NULL,pos=NA,bgcol=white,breakcol=black,
 style=slash,brw=0.02) {
 
 # get the coordinates of the outside of the plot
 figxy-par(usr)
 # flag if either axis is logarithmic
 xaxl-par(xlog)
 yaxl-par(ylog)
 # calculate the x and y offsets for the break
 xw-(figxy[2]-figxy[1])*brw
 yw-(figxy[4]-figxy[3])*brw
 if(!is.na(pos)) figxy-rep(pos,4)
 # if no break position was given, put it just off the plot origin
 if(is.null(breakpos))
  breakpos-ifelse(axis%%2,figxy[1]+xw*2,figxy[3]+yw*2)
 if(xaxl  (axis == 1 || axis == 3)) breakpos-log10(breakpos)
 if(yaxl  (axis == 2 || axis == 4)) breakpos-log10(breakpos)
 # set up the blank rectangle (left, bottom, right, top)
 switch(axis,
  br-c(breakpos-xw/2,figxy[3]-yw/2,breakpos+xw/2,figxy[3]+yw/2),
  br-c(figxy[1]-xw/2,breakpos-yw/2,figxy[1]+xw/2,breakpos+yw/2),
  br-c(breakpos-xw/2,figxy[4]-yw/2,breakpos+xw/2,figxy[4]+yw/2),
  br-c(figxy[2]-xw/2,breakpos-yw/2,figxy[2]+xw/2,breakpos+yw/2),
  stop(Improper axis specification.))
 # get the current setting of xpd
 old.xpd-par(xpd)
 # don't cut the break off at the edge of the plot
 par(xpd=TRUE)
 # correct for logarithmic axes
 if(xaxl) br[c(1,3)]-10^br[c(1,3)]
 if(yaxl) br[c(2,4)]-10^br[c(2,4)]
 if(style == gap) {
  if(xaxl) {
   figxy[1]-10^figxy[1]
   figxy[2]-10^figxy[2]
  }
  if(yaxl) {
   figxy[3]-10^figxy[3]
   figxy[4]-10^figxy[4]
  }
  # blank out the gap area and calculate the line segments
  if(axis == 1 || axis == 3) {
   rect(breakpos,figxy[3],breakpos+xw,figxy[4],col=bgcol,border=bgcol)
   xbegin-c(breakpos,breakpos+xw)
   ybegin-c(figxy[3],figxy[3])
   xend-c(breakpos,breakpos+xw)
   yend-c(figxy[4],figxy[4])
   if(xaxl) {
xbegin-10^xbegin
xend-10^xend
   }
  }
  else {
   rect(figxy[1],breakpos,figxy[2],breakpos+yw,col=bgcol,border=bgcol)
   xbegin-c(figxy[1],figxy[1])
   

Re: [R] Get a list of installed commands

2010-06-13 Thread Joris Meys
Hi,

Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
with StatET,... They contain lists you can use. Also the listings
package of LaTeX contains a wordlist for R.

Getting all installed commands out of R is not doable with a single
command as far as I know. R works completely different than Stata; R
is a fullblown programming language, not a statistical program. Try to
find a list of all installed Perl commands for example...

Attached is the recognition file of Tinn-R. Reserved 1 are special
keywords, Reserved 2 is a list of the most commonly used commands in
the pre-installed packages, and Reserved 3 is a list of common
parameters of those functions. It's submitted with Tinn-R under the
GNU license, so keep that in mind when using it.

But instead of re-inventing the wheel and constructing your own
editor, you could take a look at one of those mentioned above. On
Windows, I recommend Tinn-R for daily scripting, and Eclipse for
developing packages and the likes. Both offer the advantage of direct
communication with the R console.

Cheers
Joris

On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey coco.datamon...@gmail.com wrote:
 I'm pretty new to R, but have experience with other languages, both OO and 
 scripting.

 I'm trying to add support for R to my text editor of choice and to do this I 
 need a list of installed commands I can markup with XML.
 I'd then simply feed in the marked up list into my text editor's library and 
 I'm off.

 I've done this in Stata before using the following command:
 getcmds using ~/Desktop/StataCommands.txt

 Does anyone know of a way to do this in R?

 Any pointers much appreciated.

 Thanks!

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




-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Scope and sapply

2010-06-13 Thread Gabor Grothendieck
On Sat, Jun 12, 2010 at 11:40 PM, Worik R wor...@gmail.com wrote:
 I was careless.

 Here is a better example of what I am trying to.  With the '-' you
 offered.

 ?-

 That was exactly what I needed, thankyou.


Just as an aside I am assuming these are just examples to illustrate
scope.  In reality you would rarely use -  and instead would just
return the computed value as the value of the function.  Also see
cumsum and cumprod and check out this page:
http://cran.r-project.org/web/views/Finance.html

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


Re: [R] Get a list of installed commands

2010-06-13 Thread Gabor Grothendieck
On Sun, Jun 13, 2010 at 3:31 AM, Data Monkey coco.datamon...@gmail.com wrote:
 I'm pretty new to R, but have experience with other languages, both OO and 
 scripting.

 I'm trying to add support for R to my text editor of choice and to do this I 
 need a list of installed commands I can markup with XML.
 I'd then simply feed in the marked up list into my text editor's library and 
 I'm off.

 I've done this in Stata before using the following command:
 getcmds using ~/Desktop/StataCommands.txt

 Does anyone know of a way to do this in R?

 Any pointers much appreciated.


If installed commands means reserved words in R's parser then see: ?Reserved

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


Re: [R] Get a list of installed commands

2010-06-13 Thread Data Monkey
Thanks Joris. Very helpful.

I had thought of that, just curious to see if it was possible to get a fresh 
list in R.
After reading your email I think perhaps my wording was a bit loose. I meant 
commands in the pre-installed packages.
So basically, out of the box what commands will R recognize.

I had found the full reference manual for R online and parsed the table of 
contents into a nice XML file I could use as a possible solution.
However, your attached file looks a bit more complete (haven't really given 
much thought to the reason yet). Thanks again for sending it.

I'm using Coda on OS X, which is really designed for Web dev, but I like it so 
much I've added support for Stata and now want R. It's got Terminal bult-in, so 
I can invoke R through there.
Anyway, my ultimate goal is to not only get syntax highlighting, but also 
autocompletion. If possible in the prediction, also get the method (where 
applicable) signature. Coda allows all this.
I use this a lot when coding in PHP in Coda and C# in Visual Studio - I think 
Microsoft call it Intellisense or something.

Cheers for the help.

On 13/06/2010, at 9:47 PM, Joris Meys wrote:

 Hi,
 
 Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
 with StatET,... They contain lists you can use. Also the listings
 package of LaTeX contains a wordlist for R.
 
 Getting all installed commands out of R is not doable with a single
 command as far as I know. R works completely different than Stata; R
 is a fullblown programming language, not a statistical program. Try to
 find a list of all installed Perl commands for example...
 
 Attached is the recognition file of Tinn-R. Reserved 1 are special
 keywords, Reserved 2 is a list of the most commonly used commands in
 the pre-installed packages, and Reserved 3 is a list of common
 parameters of those functions. It's submitted with Tinn-R under the
 GNU license, so keep that in mind when using it.
 
 But instead of re-inventing the wheel and constructing your own
 editor, you could take a look at one of those mentioned above. On
 Windows, I recommend Tinn-R for daily scripting, and Eclipse for
 developing packages and the likes. Both offer the advantage of direct
 communication with the R console.
 
 Cheers
 Joris
 
 On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey coco.datamon...@gmail.com 
 wrote:
 I'm pretty new to R, but have experience with other languages, both OO and 
 scripting.
 
 I'm trying to add support for R to my text editor of choice and to do this I 
 need a list of installed commands I can markup with XML.
 I'd then simply feed in the marked up list into my text editor's library and 
 I'm off.
 
 I've done this in Stata before using the following command:
 getcmds using ~/Desktop/StataCommands.txt
 
 Does anyone know of a way to do this in R?
 
 Any pointers much appreciated.
 
 Thanks!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Joris Meys
 Statistical consultant
 
 Ghent University
 Faculty of Bioscience Engineering
 Department of Applied mathematics, biometrics and process control
 
 tel : +32 9 264 59 87
 joris.m...@ugent.be
 ---
 Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
 Tinn-R_recognized words.r

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


Re: [R] setting the current working directory to the location of the source file

2010-06-13 Thread Marcin Gomulka
Charles' hint was what I was looking for. Thanks!

mg.



On Fri, Jun 11, 2010 at 7:40 AM, Charles C. Berry cbe...@tajo.ucsd.eduwrote:



  cat(print(eval(sys.calls()[[1]][[2]])),file='test.R')




 See

?sys.calls



[[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] setting the current working directory to the location of the source file

2010-06-13 Thread Marcin Gomulka
On Fri, Jun 11, 2010 at 11:30 AM, Henrik Bengtsson 
h...@stat.berkeley.eduwrote:

 Isn't this what source(..., chdir=TRUE) is for?  See help(source).


not really. Imagine you give someone a script, but you have no control over
where and how they run it. They shouldn't be required to put in the chdir
parameter.
Say, the script outputs a plot to a file (pdf,png,...) and you want the file
to be created next to the source script, as the user would expect it.

mg.

[[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] setting the current working directory to the location of the source file

2010-06-13 Thread Gabor Grothendieck
On Thu, Jun 10, 2010 at 8:33 PM, Marcin Gomulka mrgo...@gmail.com wrote:
 AFAIK a script run through source() does not have any legit way to learn
 about it's own location.

 I need this to make sure that the script will find its datafiles after I
 move the whole directory. (The datafiles are in the same directory.)

 Here is a hack I invented to work around it:

 print(getwd())
 source_pathname  = get(ofile,envir = parent.frame())
 source_dirname = dirname(source_pathname )
 setwd(source_dirname)
 print(getwd())


This variation is nearly the same:

https://stat.ethz.ch/pipermail/r-help/2010-May/238804.html

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


Re: [R] How to output text to sink from data frame line by line without column names

2010-06-13 Thread Joris Meys
col1-c(2,45,67)
col2-c(a,B,C)
col3-c(234,44,566)
mydf-as.data.frame(cbind(col1,col2,col3),stringsAsFactors=F)
n-ncol(mydf)
nr-nrow(mydf)
#sink(test.txt)

cat(I will be including text of various sorts in this file so cannot
use print table or similar command)
for (i in 1:n){
cat(colnames(mydf[i]), )
cat(\n) }
for (j in 1:nr){
cat(unlist(mydf[j,c(2:n)]), )
cat(\n)}
#sink()

Cheers
Joris

On Sun, Jun 13, 2010 at 8:41 AM, Nevil Amos nevil.a...@gmail.com wrote:
 OK I see how to remove the line numbers[1] etc by using cat instead of
 print, but cannot work out how to remove the column names from the data
 frame output

 On 13/06/2010 4:21 PM, Nevil Amos wrote:

 I want to output a text file assembeld from various soruces within r (
 actually as a genepop file)

 the output should be formatted     line 1 text comment
                                                   line 2:n  selected
 column names from data frame
                                                    line n+1on lines of
 selected columns  from data frame one row at a time


 I have the following code, but cannot see how to remove the line numbers
 and omit column names form the line by line data frame output

 col1-c(2,45,67)
 col2-c(a,B,C)
 col3-c(234,44,566)
 mydf-as.data.frame(cbind(col1,col2,col3))
 n-ncol(mydf)
 nr-nrow(mydf)
 sink(test.txt)

 print(I will be including text of various sorts in this file so cannot
 use print table or similar command)
 for (i in 1:n){
 print(colnames(mydf[i]),quote=F) }
 for (j in 1:nr){
 print(mydf[j,c(2:n)],quote=F,row.names=F)}
 sink()

 The test.txt contains:

 [1] I will be including text of various sorts in this file so cannot use
 print table or similar command
 [1] col1
 [1] col2
 [1] col3
  col2 col3
    a  234
  col2 col3
    B   44
  col2 col3
    C  566

 what I would like in test.txt  is:

 I will be including text of various sorts in this file so cannot use
 print table or similar command
 col1
 col2
 col3
  a  234
  B   44
  C  566

 Many thanks

 Nevil Amos

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




-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


Re: [R] Can one get a list of recommended packages?

2010-06-13 Thread Uwe Ligges



On 13.06.2010 01:09, Dr. David Kirkby wrote:

On 06/12/10 05:27 PM, Douglas Bates wrote:

On Sat, Jun 12, 2010 at 8:37 AM, Dr. David Kirkby
david.kir...@onetel.net wrote:

R 2.10.1 is used in the Sage maths project. Several recommended packages
(Matrix, class, mgcv, nnet, rpart, spatial, and survival) are failing to
build on Solaris 10 (SPARC).


Have you checked the dependencies for those packages? Some require GNU
make.


We used GNU make.


We would like to be able to get a list of the recommended packages for R
2.10.1, but ideally via a call to R, so it is not necessary to update
that
list every time a new version of R is released. We do not want to
access the
Internet to get this information.



Is there a way in R to list the recommended packages?


I'm not sure I understand the logic of this. If you are going to
build R then presumably you have the tar.gz file which contains the
sources for the recommended packages in the subdirectory
src/library/Recommended/. Why not get the list from there?


The reason is when the version of R gets updated in Sage, then someone
will have to check that list again, and more than likely fail to do so,
with the result tests will fail since packages do not exist, or worst
still we will be unaware they have failed to build properly.

Therefore, being able to get them from a command would be useful, but
can understand if that is not possible.


$ cd ~/src/R-devel/src/library/Recommended/
$ ls *.tgz
boot.tgz codetools.tgz lattice.tgz mgcv.tgz rpart.tgz
class.tgz foreign.tgz MASS.tgz nlme.tgz spatial.tgz
cluster.tgz KernSmooth.tgz Matrix.tgz nnet.tgz survival.tgz


OK, thank you for that list.


Better still, is there a way to list the recommended packages which
have not
been installed, so getting a list of any failures?


Again, this seems to be a rather convoluted approach. Why not check
why the packages don't install properly?


R had built, and the failure of the packages to build was not very
obvious, since it did not cause make to exit with a non-zero exit code.
Nobody had noticed until very recently that there was a problem.

Therefore I proposed to make a test of the packages that should have
been installed, and ensure they actually all had.

You need to be aware that R is just one part of Sage. Building the whole
of Sage takes a long time (24 hours on some computers) so needless to
say, people will not view every line of error messages. The fact that
'make' succeeded left us a false sense of security, when later it was
realsed there were problems when R run its self-tests.

Dave



But if you really want to sense some security, you should really run
make check-all
after the installation, particularly since you are on a platform that is 
not really mainstream any more.


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ERROR need finite 'ylim' values

2010-06-13 Thread Giuseppe

Hello:
I use R with MAC
I have a simple data table, numeric and text columns, named dt. The table is
imported through read.csv from a csv file. Row numbers are automatically
assigned, header is set to TRUE. there are 599 rows and several columns.

I am trying to plot using the stripchart command: one numeric variable (say
dt$fnatg) vs a text column (say dt$pat). dt$pat contains one of 3 values:
pos, neg, 

So I issue the following command:

stripchart (dt$fnatg~dt$pat)

and works well. it works well also with several options and nuances:

stripchart (dt$fnatg ~ dt$pat, method =jitter, jitter = 0.3, vertical
=TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)

Now I want my graph to exclude values for which dt$pat == 

I tried:
 
stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,
dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin
(ng/mL),xlab=Surgical Pathology)

there is no effect: the plot contains the same values as before

the I tried first subsetting the table:

patonly-(dt, dt$pat!=) which works well in creating a new table
excluding the unwanted rows. I have noticed that the new table keeps the
same row numbers assigned in the previous table. So row numbers now go 1 to
599 but with some intervals (for example there is no row 475 etc.).

then I use:

stripchart (patonly$fnatg ~ patonly$pat, method =jitter, jitter = 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)

and I get the following error:

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

I f I try the same command but I use another text variable (for example
patonly$gr) in the same table to split the plot, it now works:

stripchart (patonly$fnatg ~ patonly$gr, method =jitter, jitter = 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)


My question is two fold: 
Why does not the subset command work within the stripchart command?

Why the subsetted table cannot be used in the stripchart command, when the
plotting variable is the same previously used in the subsetting process?

Thank you
Giuseppe
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ERROR-need-finite-ylim-values-tp2253388p2253388.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] Simulating a Poisson Process in R by calling C Code over .Call

2010-06-13 Thread Fabian Zäpernick
Hi

I want to write a C function for the R Code below and call it with .Call:

SimPoisson - function(lambda,tgrid,T2M)
#Simulation eines Poissonprozesses
{
NT - 0
Ni - rep(0,length(tgrid))
tau - 0
sign - 0
if(lambda != 0)
{
i=1
j=1
while (1)
{
EVar - rexp(1,lambda)
sign - sign + EVar
if (sign  T2M)
{
break
}
tau[i] - sign
i = i+1
for (j in j:length(tgrid))
{
if (tgrid[j]  sign)
{
Ni[j] - NT
}else
{
break
}
}
NT - NT + 1
}
for (j in j:length(tgrid))
{
Ni[j] - NT
}
}
return(list(NT=NT,Ni=Ni,tau=tau))
}

I read the manual writing R extensions over and over again, but i have
no idea, how to solve the problem with tau because i dont no the length
of tau at the begining of the function

Fabian

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

2010-06-13 Thread RCulloch

Hi R users,

This seems like a simple problem but I have searched nabble for the answer
and can't seem to find it. 

All I want to do is produce a boxplot where I have two boxes for one
Individual but on the xaxis I only have one tick mark centred between the
boxes so I can add the Individuals' name. I have 30 IDs and have shown the
code I use below for a couple of IDs, I figure the data is not important
here so it's not included.

boxplot (ID1[,8],ID1[,9],ID2[,8],ID2[,9],xaxt='n')
 
I have put all the ID names in as 'names1'

and I have tried numerous variations on axis, e.g.

axis(1,at=1:30,labels=names1)

but nothing works: the boxplot appears to 'know' that there are 60 tick
marks (data) and therefore only puts ticks half way up the graph, and using:

axis(1,at=1:30,labels=names1)

complains that there is a difference of length, which of course there is! 

I must be missing something simple here, but any suggestions would be
gratefully received,

Ross 




-- 
View this message in context: 
http://r.789695.n4.nabble.com/Boxplot-intervals-combining-names-tp2253442p2253442.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] Clustering algorithms don't find obvious clusters

2010-06-13 Thread Joris Meys
Henrik,

the methods you use are NOT applicable to directed graphs, in the
contrary even. They will split up what you want to put together. In
your data, an author never cites himself. Hence, A and B are far more
different than B and D according to the techniques you use.

Please check out Etiennes solution, that is what you want.
Cheers
Joris

On Sat, Jun 12, 2010 at 8:43 PM, Henrik Aldberg
henrik.aldb...@gmail.com wrote:
 Dave,

 I used daisy with the default settings (daisy(M) where M is the matrix).


 Henrik

 On 11 June 2010 21:57, Dave Roberts dvr...@ecology.msu.montana.edu wrote:

 Henrik,

    The clustering algorithms you refer to (and almost all others) expect
 the matrix to be symmetric.  They do not seek a graph-theoretic solution,
 but rather proximity in geometric or topological space.

    How did you convert y9oru matrix to a dissimilarity?

 Dave Roberts

 Henrik Aldberg wrote:

 I have a directed graph which is represented as a matrix on the form


 0 4 0 1

 6 0 0 0

 0 1 0 5

 0 0 4 0


 Each row correspond to an author (A, B, C, D) and the values says how many
 times this author have cited the other authors. Hence the first row says
 that author A have cited author B four times and author D one time. Thus
 the
 matrix represents two groups of authors: (A,B) and (C,D) who cites each
 other. But there is also a weak link between the groups. In reality this
 matrix is much bigger and very sparce but it still consists of distinct
 groups of authors.


 My problem is that when I cluster the matrix using pam, clara or agnes the
 algorithms does not find the obvious clusters. I have tried to turn it
 into
 a dissimilarity matrix before clustering but that did not help either.


 The layout of the clustering is not that important to me, my primary
 interest is the to get the right nodes into the right clusters.



 Sincerely


 Henrik

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




-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


Re: [R] Boxplot intervals combining names

2010-06-13 Thread Sarah Goslee
Hi Ross,

You are indeed missing something simple. If there are 60 bars, the axis
runs from 1 to 60, and you want a label at every second one, rather than
at every one.

Like this (with 10 instead of 60):


testdata - matrix(runif(100), ncol=10)
boxplot(testdata, xaxt=n)
axis(1, at=seq(1.5, 9.5, by=2), labels=letters[1:5])

Sarah

On Sun, Jun 13, 2010 at 9:40 AM, RCulloch ross.cull...@dur.ac.uk wrote:

 Hi R users,

 This seems like a simple problem but I have searched nabble for the answer
 and can't seem to find it.

 All I want to do is produce a boxplot where I have two boxes for one
 Individual but on the xaxis I only have one tick mark centred between the
 boxes so I can add the Individuals' name. I have 30 IDs and have shown the
 code I use below for a couple of IDs, I figure the data is not important
 here so it's not included.

 boxplot (ID1[,8],ID1[,9],ID2[,8],ID2[,9],xaxt='n')

 I have put all the ID names in as 'names1'

 and I have tried numerous variations on axis, e.g.

 axis(1,at=1:30,labels=names1)

 but nothing works: the boxplot appears to 'know' that there are 60 tick
 marks (data) and therefore only puts ticks half way up the graph, and using:

 axis(1,at=1:30,labels=names1)

 complains that there is a difference of length, which of course there is!

 I must be missing something simple here, but any suggestions would be
 gratefully received,

 Ross




 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Boxplot-intervals-combining-names-tp2253442p2253442.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.




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

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


[R] Finding an order for an hclust (dendrogram) object without intersections

2010-06-13 Thread Tal Galili
Hello all,

I manually created an hclust object.
Now I am looking to reorder the leafs so they won't intersect with each
other, and would be happy for advises on how to do that.

Here is an example code:


#-
a - list()  # initialize empty object
# define merging pattern:
#negative numbers are leaves,
#positive are merged clusters (defined by row number in $merge)
a$merge - matrix(c(-1, -2,
-3, -4,
 1,  2,
 -5,-6,
 3,4), nc=2, byrow=TRUE )
a$height - c(1, 1.5, 3,4,4.5)# define merge heights
a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
hand-entered)
a$labels - 1:6# LETTERS[1:4]# labels of leaves
class(a) - hclust# make it an hclust object
plot(a) # look at the result

#-

A working order solution in this example would be 1:6.
The question is how can I find it.


Thanks,
Tal







Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

[[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] add only selected labels using thigmophobe

2010-06-13 Thread joerg

hi,

I am trying to label data points within a scatter plot using thigmophobe. 
While the data set consists of about 3000 points I only would like to label
a subset of these points. 

I read the x and y coordinates in from a txt file and define them as:

 MLPM1-log2(Ratio.M.L.G2.PM)
 HLG2-log2(Ratio.H.L..G2.PM)

the names and a corresponding ID are read in from the same txt file as:

GENE-(Gene.Names)
ID-(id)

plotting is:

plot(x=MLPM1,y=HLG2,main='G2 vs PM',xlab='Fold change M/L PM',ylab='Fold
change H/L G2)',xlim=c(-7,7),ylim=c(-7,7))

labelling of the whole dataset I can do with:

thigmophobe.labels(MLPM1,HLG2,labels=c(GENE),col=c(2:6,8:12),font=2) 

but how can I label only a few points from the whole dataset with names or
IDs ?? 

Thanks a lot for help and sorry for the simple question. Just started to use
R.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/add-only-selected-labels-using-thigmophobe-tp2253497p2253497.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] Finding an order for an hclust (dendrogram) object without intersections

2010-06-13 Thread Charles C. Berry

On Sun, 13 Jun 2010, Tal Galili wrote:


Hello all,

I manually created an hclust object.
Now I am looking to reorder the leafs so they won't intersect with each
other, and would be happy for advises on how to do that.


Have a look at the code for hclust().


If you can instead create an object like 'hcl', then pass the results to 
.Fortran(hcass2,...), you should be done.


HTH,

Chuck



Here is an example code:


#-
a - list()  # initialize empty object
# define merging pattern:
#negative numbers are leaves,
#positive are merged clusters (defined by row number in $merge)
a$merge - matrix(c(-1, -2,
   -3, -4,
1,  2,
-5,-6,
3,4), nc=2, byrow=TRUE )
a$height - c(1, 1.5, 3,4,4.5)# define merge heights
a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
hand-entered)
a$labels - 1:6# LETTERS[1:4]# labels of leaves
class(a) - hclust# make it an hclust object
plot(a) # look at the result

#-

A working order solution in this example would be 1:6.
The question is how can I find it.


Thanks,
Tal







Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--

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



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

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


Re: [R] Finding an order for an hclust (dendrogram) object without intersections

2010-06-13 Thread Tal Galili
Thanks Charles.

In the meantime, I found out the following code does the trick.
But I am wondering if:
1) I might have made a mistake in it somewhere
2) If there are other (smarter) ways of going about this.

Here is the solution I wrote:



# -

order.a.tree - function(tree)
{
num.of.leafs - length(tree$order)
for(i in 2:(num.of.leafs-1))
 {
tree$order -  order( cutree(tree, k = i))
 }
return(tree)
}


#Example:
a - list()  # initialize empty object
# define merging pattern:
#negative numbers are leaves,
#positive are merged clusters (defined by row number in $merge)
a$merge - matrix(c(-1, -2,
  -3, -4,
   1,  2,
-5,-6,
3,4), nc=2, byrow=TRUE )
a$height - c(1, 1.5, 3,4,4.5)# define merge heights
a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
hand-entered)
a$labels - 1:6# LETTERS[1:4]# labels of leaves
class(a) - hclust# make it an hclust object
par(mfrow = c(1,2))
plot(a) # look at the result
plot(order.a.tree(a))

# -



Any comments, or other solutions will be very welcomed.

Best,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Jun 13, 2010 at 7:08 PM, Charles C. Berry cbe...@tajo.ucsd.eduwrote:

 On Sun, 13 Jun 2010, Tal Galili wrote:

  Hello all,

 I manually created an hclust object.
 Now I am looking to reorder the leafs so they won't intersect with each
 other, and would be happy for advises on how to do that.


 Have a look at the code for hclust().


 If you can instead create an object like 'hcl', then pass the results to
 .Fortran(hcass2,...), you should be done.

 HTH,

 Chuck


 Here is an example code:


 #-
 a - list()  # initialize empty object
 # define merging pattern:
 #negative numbers are leaves,
 #positive are merged clusters (defined by row number in $merge)
 a$merge - matrix(c(-1, -2,
   -3, -4,
1,  2,
 -5,-6,
 3,4), nc=2, byrow=TRUE )
 a$height - c(1, 1.5, 3,4,4.5)# define merge heights
 a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
 hand-entered)
 a$labels - 1:6# LETTERS[1:4]# labels of leaves
 class(a) - hclust# make it an hclust object
 plot(a) # look at the result

 #-

 A working order solution in this example would be 1:6.
 The question is how can I find it.


 Thanks,
 Tal







 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)

 --

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


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




[[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] Mid-P value for a chi-squared test

2010-06-13 Thread David Winsemius


On Jun 1, 2010, at 4:17 AM, Wilson, Andrew wrote:

Can anyone tell me how to calculate a mid-p value for a chi-squared  
test

in R?


I cannot see that this has been answered. It has a date from 12 days  
ago but I cannot see a reply in the archives.


So, what is a mid-p value and which chi-square test are you asking  
about? A simple data setup in R code with expected output  would speed  
this discussion along.


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] Simulating a Poisson Process in R by calling C Code over .Call

2010-06-13 Thread Thomas Lumley

On Sun, 13 Jun 2010, Fabian Zäpernick wrote:


Hi

I want to write a C function for the R Code below and call it with .Call:

SimPoisson - function(lambda,tgrid,T2M)
#Simulation eines Poissonprozesses

snip

return(list(NT=NT,Ni=Ni,tau=tau))
}

I read the manual writing R extensions over and over again, but i have
no idea, how to solve the problem with tau because i dont no the length
of tau at the begining of the function



The standard approach is to start off with some reasonable guess at the length 
of tau and then if the vector fills up, allocate one that is twice as large and 
copy the current values of tau into the new vector.

In this case you can do better, since you have a very good initial guess for 
how long tau will be.  If you make the vector of length qpois(0., lambda), 
then there is a 99.99% chance that it is long enough.  Using 
lambda+4*sqrt(lambda) is almost as good.

Yet another approach is to take advantage of the memoryless property of the 
Poisson process: set tau to some reasonable length, then if it fill up, return 
and call the function again to handle the remainder of the duration.

-thomas

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


Re: [R] Finding an order for an hclust (dendrogram) object without intersections

2010-06-13 Thread Tal Galili
o.k,
I found an example where my algorithm can't fix the tree order.
But I don't know how to resolve it.

Here is the code to reproduce the problem:



# 

order.a.tree - function(tree)
{
num.of.leafs - length(tree$order)

for(i in 1:(num.of.leafs))
{
 tree$order -  order( cutree(tree, k = i))
}
 return(tree)
}

problematic.tree -
structure(list(merge = structure(c(-3, -24, 1, -25, 4, -27, 5,
 -22, 8, 3, 9, -5, 10, 11, 12, 6, 14, 7, 18, 19, 20, 21, 22, 23,
24, 25, -13, -23, -14, -21, -20, -26, -19, -1, 2, -15, -7, -4,
 -9, -18, -6, -17, -12, 17, -2, -8, -10, -16, 13, 15, 16, -11), .Dim =
c(26L,
2L)), height = c(0.0833, 0.0867, 0.117,
 0.136507936507937, 0.220634920634921, 0.622,
0.674603174603175,
0.823, 1.06349206349206, 1.27698412698413, 1.37,
 2.00952380952381, 2.2975, 2.39, 2.686667,
2.9, 3.14736842105263, 3.55634920634921, 3.7921768707483, 3.84183673469388,
 3.93817373103087, 4.54464285714286, 4.81438464274599, 5.10895156778615,
5.36142237562854, 6.19122779197967), order = c(1L, 2L, 3L, 4L,
 5L, 6L, 7L, 8L, 9L, 10L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 11L), labels = 1:27), .Names =
c(merge,
 height, order, labels), class = hclust)
plot(order.a.tree(problematic.tree ))

# 


Thanks,
Tal




Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Sun, Jun 13, 2010 at 7:39 PM, Tal Galili tal.gal...@gmail.com wrote:

 Thanks Charles.

 In the meantime, I found out the following code does the trick.
 But I am wondering if:
 1) I might have made a mistake in it somewhere
 2) If there are other (smarter) ways of going about this.

 Here is the solution I wrote:



 # -

 order.a.tree - function(tree)
 {
 num.of.leafs - length(tree$order)
 for(i in 2:(num.of.leafs-1))
  {
 tree$order -  order( cutree(tree, k = i))
  }
 return(tree)
 }


 #Example:
 a - list()  # initialize empty object
 # define merging pattern:
 #negative numbers are leaves,
 #positive are merged clusters (defined by row number in $merge)
 a$merge - matrix(c(-1, -2,
   -3, -4,
1,  2,
 -5,-6,
 3,4), nc=2, byrow=TRUE )
 a$height - c(1, 1.5, 3,4,4.5)# define merge heights
 a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
 hand-entered)
 a$labels - 1:6# LETTERS[1:4]# labels of leaves
 class(a) - hclust# make it an hclust object
 par(mfrow = c(1,2))
 plot(a) # look at the result
 plot(order.a.tree(a))

 # -



 Any comments, or other solutions will be very welcomed.

 Best,
 Tal




 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)

 --




 On Sun, Jun 13, 2010 at 7:08 PM, Charles C. Berry cbe...@tajo.ucsd.eduwrote:

 On Sun, 13 Jun 2010, Tal Galili wrote:

  Hello all,

 I manually created an hclust object.
 Now I am looking to reorder the leafs so they won't intersect with each
 other, and would be happy for advises on how to do that.


 Have a look at the code for hclust().


 If you can instead create an object like 'hcl', then pass the results to
 .Fortran(hcass2,...), you should be done.

 HTH,

 Chuck


 Here is an example code:


 #-
 a - list()  # initialize empty object
 # define merging pattern:
 #negative numbers are leaves,
 #positive are merged clusters (defined by row number in $merge)
 a$merge - matrix(c(-1, -2,
   -3, -4,
1,  2,
 -5,-6,
 3,4), nc=2, byrow=TRUE )
 a$height - c(1, 1.5, 3,4,4.5)# define merge heights
 a$order - c(1,4,2,3,6,5)  # order of leaves(trivial if
 hand-entered)
 a$labels - 1:6# LETTERS[1:4]# labels of leaves
 class(a) - hclust# make it an hclust object
 plot(a) # look at the result

 #-

 A working order solution in this example would be 1:6.
 The question is how can I find it.


 Thanks,
 Tal







 Contact
 Details:---
 Contact me: tal.gal...@gmail.com |  972-52-7275845
 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
 www.r-statistics.com (English)

 

[R] Pairwise cross correlation from data set

2010-06-13 Thread Claus O'Rourke
Dear list,

Following up on an earlier post, I would like to reorder a dataset and
compute pairwise correlations. But I'm having some real problems
getting this done.

My data looks something like:

Participant Stimulus Measurement
 p1 s`15
 p1 s`26.1
 p1 s`37
 p2 s`14.8
 p2 s`26
 p2 s`36.5
 p3 s`14
 p3 s`27
 p3 s`36

As a first step I would imagine that I have to rearrange my data into
a frame more like this

Stimulus  p1   p2  p3
   s1   5  4.8 4
   s2   6.1   67
   s3   7  6.5 6

And then do the pairwise correlations between {p1,p2},{p2,p3}.{p2,p3}

I can do all of this manually, i.e., using some messy case specific
code, but can anyone please point out the best way to do this in a
more generalizable way.

Thanks for any help you can give a novice!

Claus

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


Re: [R] add only selected labels using thigmophobe

2010-06-13 Thread David Winsemius


 
joerg wrote:
 
 I am trying to label data points within a scatter plot using thigmophobe. 
 While the data set consists of about 3000 points I only would like to
 label a subset of these points. 
 
 I read the x and y coordinates in from a txt file and define them as:
 
  MLPM1-log2(Ratio.M.L.G2.PM)
  HLG2-log2(Ratio.H.L..G2.PM)
 
 the names and a corresponding ID are read in from the same txt file as:
 
 GENE-(Gene.Names)
 ID-(id)
 
 plotting is:
 
 plot(x=MLPM1,y=HLG2,main='G2 vs PM',xlab='Fold change M/L PM',ylab='Fold
 change H/L G2)',xlim=c(-7,7),ylim=c(-7,7))
 
 labelling of the whole dataset I can do with:
 
 thigmophobe.labels(MLPM1,HLG2,labels=c(GENE),col=c(2:6,8:12),font=2) 
 
 but how can I label only a few points from the whole dataset with names or
 IDs ?? 
 
 

 require(plotrix)
#Loading required package: plotrix
 ?thigmophobe.labels
#starting httpd help server ... done
 dta - data.frame(a=rlnorm(20), b=rlnorm(20))
 with( dta, plot(a,b))
 with( dta[c(2,7,10), ], thigmophobe.labels(a, b, labels=c('A', 'B', 'C') )
)

-- 
David.

-- 
View this message in context: 
http://r.789695.n4.nabble.com/add-only-selected-labels-using-thigmophobe-tp2253497p2253549.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] Count of unique factors within another factor

2010-06-13 Thread Birdnerd

I have a data frame with two factors (sampling 'unit', 'species'). I want to
calculate the number of unique 'species' per 'unit.' I can calculate the
number of unique values for each variable separately, but can't get a count
for each ‘unit’.

 data=read.csv(C:/Desktop/sr_sort_practice.csv)
 attach(data)

 data[1:10,]
   unit species
1   123ACMA
2   123LIDE
3   123LIDE
4   123SESE
5   123SESE
6   123SESE
7   345HEAR
8   345LOHI
9   345QUAG
10  345TODI…..

 sr.unique- lapply (data, unique)
$unit
[1] 123 345 216
$species
 [1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE

 sapply (sr.unique,length)
unit species 
  3  10

Then, I get stuck here because this unique species count is not given for
each ‘unit’.
What I'd like to get is:

unit species
1233
3454
216--

Thanks--

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-unique-factors-within-another-factor-tp2253545p2253545.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] ERROR need finite 'ylim' values

2010-06-13 Thread David Winsemius


Giuseppe wrote:
 
 Hello:
 I use R with MAC
 I have a simple data table, numeric and text columns, named dt. The table
 is imported through read.csv from a csv file. Row numbers are
 automatically assigned, header is set to TRUE. there are 599 rows and
 several columns.
 
 I am trying to plot using the stripchart command: one numeric variable
 (say dt$fnatg) vs a text column (say dt$pat). dt$pat contains one of 3
 values: pos, neg, 
 
 So I issue the following command:
 
stripchart (dt$fnatg~dt$pat)
 
 and works well. it works well also with several options and nuances:
 
stripchart (dt$fnatg ~ dt$pat, method =jitter, jitter = 0.3, vertical
=TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)
 
 Now I want my graph to exclude values for which dt$pat == 
 
 I tried:
  
stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,
dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin
(ng/mL),xlab=Surgical Pathology)
 
 there is no effect: the plot contains the same values as before
 
 the I tried first subsetting the table:
 
patonly-(dt, dt$pat!=) which works well in creating a new table
excluding the unwanted rows. I have noticed that the new table keeps the
same row numbers assigned in the previous table. So row numbers now go 1 to
599 but with some intervals (for example there is no row 475 etc.).
 
 then I use:
 
stripchart (patonly$fnatg ~ patonly$pat, method =jitter, jitter = 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)
 
 and I get the following error:
 
 Error in plot.window(...) : need finite 'ylim' values
 In addition: Warning messages:
 1: In min(x) : no non-missing arguments to min; returning Inf
 2: In max(x) : no non-missing arguments to max; returning -Inf
 3: In min(x) : no non-missing arguments to min; returning Inf
 4: In max(x) : no non-missing arguments to max; returning -Inf
 
 I f I try the same command but I use another text variable (for example
 patonly$gr) in the same table to split the plot, it now works:
 
stripchart (patonly$fnatg ~ patonly$gr, method =jitter, jitter = 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)
 
 
 My question is two fold: 
 Why does not the subset command work within the stripchart command?
 
 Why the subsetted table cannot be used in the stripchart command, when the
 plotting variable is the same previously used in the subsetting process?
 
 

You appear to have adopted a strategy of using positional matching. Naming
your arguments will often result in more informative error messages. 
Looking at the help page for stripchart, it appears that there is no
subset parameter to set in any of its methods and only the formula method
has a data argument. It should work with:

stripchart(formula1 , data=subset(dta, subset=criteria),    rest of
arguments preferably named  )

Your other option might be to use the with() function:

with( subset(patonly, pat!=),  stripchart(fnatg ~ gr,  ... named
arguments) )


HTH. and if it doesn't, then submit a reproducible data example to work
with.

-- 
David.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ERROR-need-finite-ylim-values-tp2253388p2253560.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] Count of unique factors within another factor

2010-06-13 Thread Erik Iverson
I think ?tapply will help here.  But *please* read the posting guide and provide 
minimal, reproducible examples!


Birdnerd wrote:

I have a data frame with two factors (sampling 'unit', 'species'). I want to
calculate the number of unique 'species' per 'unit.' I can calculate the
number of unique values for each variable separately, but can't get a count
for each ‘unit’.


data=read.csv(C:/Desktop/sr_sort_practice.csv)
attach(data)



data[1:10,]

   unit species
1   123ACMA
2   123LIDE
3   123LIDE
4   123SESE
5   123SESE
6   123SESE
7   345HEAR
8   345LOHI
9   345QUAG
10  345TODI…..


sr.unique- lapply (data, unique)

$unit
[1] 123 345 216
$species
 [1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE


sapply (sr.unique,length)
unit species 
  3  10


Then, I get stuck here because this unique species count is not given for
each ‘unit’.
What I'd like to get is:

unit species
1233
3454
216--

Thanks--



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


Re: [R] Count of unique factors within another factor

2010-06-13 Thread Jorge Ivan Velez
Hi there,

Try

with(data, tapply(species, unit, function(x) length(unique(x

HTH,
Jorge


On Sun, Jun 13, 2010 at 12:07 PM, Birdnerd  wrote:


 I have a data frame with two factors (sampling 'unit', 'species'). I want
 to
 calculate the number of unique 'species' per 'unit.' I can calculate the
 number of unique values for each variable separately, but can't get a count
 for each ‘unit’.

  data=read.csv(C:/Desktop/sr_sort_practice.csv)
  attach(data)

  data[1:10,]
   unit species
 1   123ACMA
 2   123LIDE
 3   123LIDE
 4   123SESE
 5   123SESE
 6   123SESE
 7   345HEAR
 8   345LOHI
 9   345QUAG
 10  345TODI…..

  sr.unique- lapply (data, unique)
 $unit
 [1] 123 345 216
 $species
  [1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE

  sapply (sr.unique,length)
unit species
  3  10

 Then, I get stuck here because this unique species count is not given for
 each ‘unit’.
 What I'd like to get is:

 unit species
 1233
 3454
 216--

 Thanks--

 --
 View this message in context:
 http://r.789695.n4.nabble.com/Count-of-unique-factors-within-another-factor-tp2253545p2253545.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.


[R] Are any values in one list contained within a second list

2010-06-13 Thread GL

Silly question, but, can I test to see if any value of list a is contained in
list b without doing a loop? A loop is easy enough, but wanted to see if
there was a cleaner way. By way of example:

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, b

Return true, since both lists contain b

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, t

Return false, since the lists have no mutual values



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Are-any-values-in-one-list-contained-within-a-second-list-tp2253637p2253637.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] Mid-P value for a chi-squared test

2010-06-13 Thread Ted Harding
On 13-Jun-10 17:12:45, David Winsemius wrote:
 On Jun 1, 2010, at 4:17 AM, Wilson, Andrew wrote:
 
 Can anyone tell me how to calculate a mid-p value for a chi-squared  
 test in R?
 
 I cannot see that this has been answered. It has a date from 12 days  
 ago but I cannot see a reply in the archives.
 
 So, what is a mid-p value and which chi-square test are you asking 
 about? A simple data setup in R code with expected output  would speed 
 this discussion along.
 
 David Winsemius, MD

The mid-p value is a device for improving the accuracy of a continuous
approximation to a distribution which in reality is discrete.

Intuitively, the idea is to treat the discrete probabilities of the
discrete distribution as if they were proportions in a histogram.
Then imagine fitting a continuous curve (e.g. a chi-squared density)
to the histogram. The fit (agreement between the proportion in one
histogram bar, and the probability below that portion of the curve
which lies in the same range) will be better if the curve goes through
the midpoint of the top of the bar.

This leads to the formal definition:

  mid-P = Prob(X  Xobs) + 0.5*Prob(X = Xobs)

A number of R functions use this idea. Check out what you get by
going to http://finzi.psych.upenn.edu/nmz.html and entering mid-p
into the search box, and see whether any of them match (or come
close to) your particular case.

In the case of the chi-squared test, the idea is related to (but
not the same as) the Yates correction for continuity. chisq.test()
has an option correct=TRUE to force this, but only for 2x2 tables.

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 13-Jun-10   Time: 19:19:44
-- XFMail --

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


Re: [R] Pairwise cross correlation from data set

2010-06-13 Thread David Winsemius


On Jun 13, 2010, at 1:47 PM, Claus O'Rourke wrote:


Dear list,

Following up on an earlier post, I would like to reorder a dataset and
compute pairwise correlations. But I'm having some real problems
getting this done.

My data looks something like:

Participant Stimulus Measurement
p1 s`15
p1 s`26.1
p1 s`37
p2 s`14.8
p2 s`26
p2 s`36.5
p3 s`14
p3 s`27
p3 s`36

As a first step I would imagine that I have to rearrange my data into
a frame more like this


It is not particularly natural to do the re-ordering to my mind as  
long asyou preserve the ordering of the Stimulus variable. Personally,  
I would avoid using back-quotes in values as they may have special  
syntactic implications.


Stimulus  p1   p2  p3
  s1   5  4.8 4
  s2   6.1   67
  s3   7  6.5 6

And then do the pairwise correlations between {p1,p2},{p2,p3}.{p2,p3}

I can do all of this manually, i.e., using some messy case specific
code, but can anyone please point out the best way to do this in a
more generalizable way.


 rd.txt
function(txt, header=TRUE, ...) {
 rd - read.table(textConnection(txt), header=header, ...)
   closeAllConnections()
 rd }
 dtat - rd.txt(Participant Stimulus Measurement
+ p1 s`15
+ p1 s`26.1
+ p1 s`37
+ p2 s`14.8
+ p2 s`26
+ p2 s`36.5
+ p3 s`14
+ p3 s`27
+ p3 s`36, stringsAsFactors=F)


 str(dtat)
'data.frame':   9 obs. of  3 variables:
 $ Participant: chr  p1 p1 p1 p2 ...
 $ Stimulus   : chr  s`1 s`2 s`3 s`1 ...
 $ Measurement: num  5 6.1 7 4.8 6 6.5 4 7 6
 combn(unique(dtat$Participant), 2)
 [,1] [,2] [,3]
[1,] p1 p1 p2
[2,] p2 p3 p3

  apply( combn(unique(dtat$Participant), 2), 2,
# read combinations by columns
  function(x) {with(subset(dtat, Participant %in% x),
# used only the desired combo's
cor(Measurement, as.numeric(factor(Stimulus
# needed to turn Stimulus into factor to get an ordering
 } )

# [1] 0.9696635 0.7627701 0.7424791

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] Are any values in one list contained within a second list

2010-06-13 Thread David Winsemius


On Jun 13, 2010, at 2:17 PM, GL wrote:



Silly question, but, can I test to see if any value of list a is  
contained in
list b without doing a loop? A loop is easy enough, but wanted to  
see if

there was a cleaner way. By way of example:

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, b

Return true, since both lists contain b

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, t

Return false, since the lists have no mutual values


length(intersect(List_1, List_2))  0






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] Are any values in one list contained within a second list

2010-06-13 Thread Jorge Ivan Velez
Hi GL,

Tr this:

# example 1

list1 - list(letters[1:7])

list1

list2 - list(c('z','y','x','w','v','u','b'))

list2

mapply(function(x, y) any(x %in% y), list1, list2)



 # example 2

list2 - list(c('z','y','x','w','v','u','t'))

list2

mapply(function(x, y) any(x %in% y), list1, list2)

HTH,
Jorge


On Sun, Jun 13, 2010 at 2:17 PM, GL  wrote:


 Silly question, but, can I test to see if any value of list a is contained
 in
 list b without doing a loop? A loop is easy enough, but wanted to see if
 there was a cleaner way. By way of example:

 List 1: a, b, c, d, e, f, g

 List 2: z, y, x, w, v, u, b

 Return true, since both lists contain b

 List 1: a, b, c, d, e, f, g

 List 2: z, y, x, w, v, u, t

 Return false, since the lists have no mutual values



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Are-any-values-in-one-list-contained-within-a-second-list-tp2253637p2253637.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] Are any values in one list contained within a second list

2010-06-13 Thread William Dunlap
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of GL
 Sent: Sunday, June 13, 2010 11:18 AM
 To: r-help@r-project.org
 Subject: [R] Are any values in one list contained within a second list
 
 
 Silly question, but, can I test to see if any value of list a 
 is contained in
 list b without doing a loop?

It is almost the same as your English description of the problem:
  any(a %in% b)

 A loop is easy enough, but 
 wanted to see if
 there was a cleaner way. By way of example:
 
 List 1: a, b, c, d, e, f, g
 
 List 2: z, y, x, w, v, u, b

It would be nicer if you used R syntax to create the
datasets in your example.  E.g., I'm guessing you mean
 a1 - c(a,b,c,d,e,f,g)
but since you didn't quote the strings and you called it
a list you could mean
 a2 - as.list(expression(a, b, c, d, e, f, g))
or, equivalently,
 a3 - list(quote(a), quote(b), quote(c), quote(d), quote(e),
quote(f), quote(g))

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 
 Return true, since both lists contain b
 
 List 1: a, b, c, d, e, f, g
 
 List 2: z, y, x, w, v, u, t
 
 Return false, since the lists have no mutual values
 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Are-any-values-in-one-list-conta
ined-within-a-second-list-tp2253637p2253637.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


[R] losing line of mtext when saving to png format

2010-06-13 Thread John Kane

I have a simple graph (oode below) which looks fine on the screen but when
I save it in png format the title (actually the last mtext line) is cut off.

I am pretty sure that I am doing something very stupid but 
other than playing around with the png height and width commands which don't 
seem to help I have no idea of what to look for.

Any suggestions or cures would be appreciated.

Thanks
#===#

mydata  - data.frame(kel = c(13,253,263,273,283,292,303,313,323,333,573,853),
  cent=  c( -280, -40, -30, -20, -10, 1, 10, 20, 30, 40, 280, 560)) 
   
(intervals - diff(mydata[,1]))

opar - par(mar= (c(5, 4, 6, 2)))

# png(C:/Rjunk/brendengraph.png, width=600, height=500)

plot(1:12,mydata$kel, main= , xlab= ,
   ylab= ,type=l, col=red, xaxt=n, yaxt=n,cex=.75)
   
axis(1, at=1:12,labels=as.character(mydata$kel), cex.axis=.75)

axis(3, at=1:12, labels=as.character(mydata$cent), cex.axis=.75)

mtext(side = 1, line=2, text=Degrees Kelvin,cex=.75 )
mtext(side = 3, line=2, text=Degrees Centegrade,cex=.75 )
mtext(side=3, line=4, text=Room Temperature, font=2, cex=.85)
# dev.off()
par(opar)
#=

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


Re: [R] Are any values in one list contained within a second list

2010-06-13 Thread Phil Spector

I think the simplest way is to translate the English
directly :-)


list1 = c('a','b','c','d','e','f','g')
list2 = c('z','y','x','w','v','u','b')
any(list2 %in% list1)

[1] TRUE

list2 = c('z','y','x','w','v','u','t')
any(list2 %in% list1)

[1] FALSE

- Phil Spector
 Statistical Computing Facility
 Department of Statistics
 UC Berkeley
 spec...@stat.berkeley.edu


On Sun, 13 Jun 2010, GL wrote:



Silly question, but, can I test to see if any value of list a is contained in
list b without doing a loop? A loop is easy enough, but wanted to see if
there was a cleaner way. By way of example:

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, b

Return true, since both lists contain b

List 1: a, b, c, d, e, f, g

List 2: z, y, x, w, v, u, t

Return false, since the lists have no mutual values



--
View this message in context: 
http://r.789695.n4.nabble.com/Are-any-values-in-one-list-contained-within-a-second-list-tp2253637p2253637.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] HOW to install RSQLite database

2010-06-13 Thread John Kane
select a cran mirror   Packages  Select Cran Mirror

In R use  the following command
   install.packages(RSQLite)



--- On Sun, 6/13/10, vijaysheegi vijay.she...@gmail.com wrote:

 From: vijaysheegi vijay.she...@gmail.com
 Subject: Re: [R] HOW to install RSQLite database
 To: r-help@r-project.org
 Received: Sunday, June 13, 2010, 2:38 AM
 
 Yes i am asking how to install RSQLite packagein
 windows.Please help on this
 regards
 
 On 6/11/10, david.jessop [via R] 
 ml-node+2251498-1601505055-288...@n4.nabble.comml-node%2b2251498-1601505055-288...@n4.nabble.com
 wrote:
 
  Are you asking how to install the RSQLite package or
 how to create a
  SQLite database?  The two are somewhat distinct
 questions. RSQLite is
  just a package of functions for R to be able to access
 data in an SQLite
  database. There isn't a separate SQLite program - just
 a library that is
  compiled into RSQLite.
 
  Regards
 
  David
 
 
  -Original Message-
  From: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=2251498i=0[mailto:[hidden
  email] http://user/SendEmail.jtp?type=nodenode=2251498i=1]
  On Behalf Of vijaysheegi
  Sent: 10 June 2010 16:22
  To: [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=2
  Subject: [R] HOW to install RSQLite database
 
 
  Please let me know where i have to type below thing
 to  RSQLite database
  get installed.Please let me know the solution.Thanks
 in advance
 
 
 
 
 
  RSQLite -- Embedding the SQLite engine in R
 
  (The RSQLite package includes a recent copy of the
 SQLite distribution
  from http://www.sqlite.org http://www.sqlite.org/?by-user=t.)
 
  Installation
  
 
  There are 3 alternatives for installation:
 
  1. Simple installation:
 
        R CMD INSTALL
 RSQLite-.tar.gz
 
     the installation automatically detects
 whether SQLite is
     available in any of your system
 directories;  if it's not
     available, it installs the SQLite engine
 and the R-SQLite
     interface under the package directory
 $R_PACKAGE_DIR/sqlite.
 
  2. If you have SQLite installed in a non-system
 directory (e.g,
     in $HOME/sqlite),
 
     a) You can use
 
        export
 PKG_LIBS=-L$HOME/sqlite/lib -lsqlite
        export
 PKG_CPPFLAGS=-I$HOME/sqlite/include
 
        R CMD INSTALL
 RSQLite-.tar.gz
 
     b) or you can use the --with-sqlite-dir
 configuration argument
 
        R CMD INSTALL
 --configure-args=--with-sqlite-dir=$HOME/sqlite \
                
      RSQLite-.tar.gz
 
  3. If you don't have SQLite but you rather install the
 version we
  provide
     into a directory different than the
 RSQLite package, for instance,
     $HOME/app/sqlite, use
 
        R CMD INSTALL
 --configure-args=--enable-sqlite=$HOME/app/sqlite \
                
      RSQLite-.tar.gz
 
  Usage
  -
 
  Note that if you use an *existing* SQLite library that
 resides in a
  non-system directory (e.g., other than /lib, /usr/lib,
 /usr/local/lib)
  you may need to include it in our LD_LIBRARY_PATH,
 prior to invoking R.
 
  For instance
 
      export
 LD_LIBRARY_PATH=$HOME/sqlite/lib:$LD_LIBRARY_PATH
      R
       library(help=RSQLite)
       library(RSQLite)
 
  (if you use the --enable-sqlite=DIR configuration
 argument, the SQLite
  library is statically linked to the RSQLite R package,
 and you need not
  worry about setting LD_LIBRARY_PATH.)
 
 
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604phttp://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p?by-user=t
  2250604.html
  Sent from the R help mailing list archive at
 Nabble.com.
 
          [[alternative
 HTML version deleted]]
 
  __
  [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=3mailing
 list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
  Issued by UBS AG or affiliates to professional
 investors...{{dropped:30}}
 
  __
  [hidden email] http://user/SendEmail.jtp?type=nodenode=2251498i=4mailing
 list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained,
 reproducible code.
 
 
  --
  View message @
  http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p2251498.html
  To unsubscribe from HOW to install RSQLite database,
 click here (link removed) =.
 
 
 
 
 
 -- 
 vijayamahantesh
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/HOW-to-install-RSQLite-database-tp2250604p2253249.html
 Sent from the R help mailing list archive at Nabble.com.
 
     [[alternative HTML version deleted]]
 
 

Re: [R] losing line of mtext when saving to png format

2010-06-13 Thread Joshua Wiley
Hey John,

I believe this issue is that the png device is different from the
onscreen one.  You set the margins for the on screen with a call to
par() but not for the png().  The code below works for me.


mydata  - data.frame(kel=c(13,253,263,273,283,292,303,313,323,333,573,853),
cent=c( -280, -40, -30, -20, -10, 1, 10, 20, 30, 40, 280, 560))
png(C:/Rjunk/brendengraph.png, width=600, height=600)
par(mar=(c(5, 4, 6, 2))) #this goes after the call to png()
plot(1:12,mydata$kel, main= , xlab= , ylab= ,type=l,
col=red, xaxt=n, yaxt=n,cex=.75)
axis(1, at=1:12,labels=as.character(mydata$kel), cex.axis=.75)
axis(3, at=1:12, labels=as.character(mydata$cent), cex.axis=.75)
mtext(side = 1, line=2, text=Degrees Kelvin,cex=.75 )
mtext(side = 3, line=2, text=Degrees Centegrade,cex=.75 )
mtext(side = 3, line=4, text=Room Temperature, font=2, cex=.85)
dev.off()
#

HTH,

Josh

On Sun, Jun 13, 2010 at 12:09 PM, John Kane jrkrid...@yahoo.ca wrote:

 I have a simple graph (oode below) which looks fine on the screen but when
 I save it in png format the title (actually the last mtext line) is cut off.

 I am pretty sure that I am doing something very stupid but
 other than playing around with the png height and width commands which don't 
 seem to help I have no idea of what to look for.

 Any suggestions or cures would be appreciated.

 Thanks
 #===#

 mydata  - data.frame(kel = c(13,253,263,273,283,292,303,313,323,333,573,853),
              cent=  c( -280, -40, -30, -20, -10, 1, 10, 20, 30, 40, 280, 560))
 (intervals - diff(mydata[,1]))

 opar - par(mar= (c(5, 4, 6, 2)))

 # png(C:/Rjunk/brendengraph.png, width=600, height=500)

 plot(1:12,mydata$kel, main= , xlab= ,
       ylab= ,type=l, col=red, xaxt=n, yaxt=n,cex=.75)

 axis(1, at=1:12,labels=as.character(mydata$kel), cex.axis=.75)

 axis(3, at=1:12, labels=as.character(mydata$cent), cex.axis=.75)

 mtext(side = 1, line=2, text=Degrees Kelvin,cex=.75 )
 mtext(side = 3, line=2, text=Degrees Centegrade,cex=.75 )
 mtext(side=3, line=4, text=Room Temperature, font=2, cex=.85)
 # dev.off()
 par(opar)
 #=

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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
Senior in Psychology
University of California, Riverside
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] losing line of mtext when saving to png format

2010-06-13 Thread John Kane
Oh, how embarrassing!  I made the exact same mistake about 2-3 years ago.  

Thanks a lot. 

It was not even that important a graph but 
it was really bothering me.

--- On Sun, 6/13/10, Joshua Wiley jwiley.ps...@gmail.com wrote:

 From: Joshua Wiley jwiley.ps...@gmail.com
 Subject: Re: [R] losing line of mtext when saving to png format
 To: John Kane jrkrid...@yahoo.ca
 Cc: R R-help r-h...@stat.math.ethz.ch
 Received: Sunday, June 13, 2010, 3:32 PM
 Hey John,
 
 I believe this issue is that the png device is different
 from the
 onscreen one.  You set the margins for the on screen
 with a call to
 par() but not for the png().  The code below works for
 me.
 
 
 mydata  -
 data.frame(kel=c(13,253,263,273,283,292,303,313,323,333,573,853),
 cent=c( -280, -40, -30, -20, -10, 1, 10, 20, 30, 40, 280,
 560))
 png(C:/Rjunk/brendengraph.png, width=600, height=600)
 par(mar=(c(5, 4, 6, 2))) #this goes after the call to
 png()
 plot(1:12,mydata$kel, main= , xlab= , ylab=
 ,type=l,
 col=red, xaxt=n, yaxt=n,cex=.75)
 axis(1, at=1:12,labels=as.character(mydata$kel),
 cex.axis=.75)
 axis(3, at=1:12, labels=as.character(mydata$cent),
 cex.axis=.75)
 mtext(side = 1, line=2, text=Degrees Kelvin,cex=.75 )
 mtext(side = 3, line=2, text=Degrees Centegrade,cex=.75
 )
 mtext(side = 3, line=4, text=Room Temperature, font=2,
 cex=.85)
 dev.off()
 #
 
 HTH,
 
 Josh
 
 On Sun, Jun 13, 2010 at 12:09 PM, John Kane jrkrid...@yahoo.ca
 wrote:
 
  I have a simple graph (oode below) which looks fine on
 the screen but when
  I save it in png format the title (actually the last
 mtext line) is cut off.
 
  I am pretty sure that I am doing something very stupid
 but
  other than playing around with the png height and
 width commands which don't seem to help I have no idea of
 what to look for.
 
  Any suggestions or cures would be appreciated.
 
  Thanks
 
 #===#
 
  mydata  - data.frame(kel =
 c(13,253,263,273,283,292,303,313,323,333,573,853),
               cent=  c( -280, -40, -30, -20,
 -10, 1, 10, 20, 30, 40, 280, 560))
  (intervals - diff(mydata[,1]))
 
  opar - par(mar= (c(5, 4, 6, 2)))
 
  # png(C:/Rjunk/brendengraph.png, width=600,
 height=500)
 
  plot(1:12,mydata$kel, main= , xlab= ,
        ylab= ,type=l, col=red, xaxt=n,
 yaxt=n,cex=.75)
 
  axis(1, at=1:12,labels=as.character(mydata$kel),
 cex.axis=.75)
 
  axis(3, at=1:12, labels=as.character(mydata$cent),
 cex.axis=.75)
 
  mtext(side = 1, line=2, text=Degrees Kelvin,cex=.75
 )
  mtext(side = 3, line=2, text=Degrees
 Centegrade,cex=.75 )
  mtext(side=3, line=4, text=Room Temperature, font=2,
 cex=.85)
  # dev.off()
  par(opar)
 
 #=
 
  __
  R-help@r-project.org
 mailing list
  https://stat.ethz.ch/mailman/listinfo/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
 Senior in Psychology
 University of California, Riverside
 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] Get a list of installed commands

2010-06-13 Thread Henrique Dallazuanna
Try this:

sapply(installed.packages()[,1], function(x)try(ls(asNamespace(x

On Sun, Jun 13, 2010 at 9:30 AM, Data Monkey coco.datamon...@gmail.comwrote:

 Thanks Joris. Very helpful.

 I had thought of that, just curious to see if it was possible to get a
 fresh list in R.
 After reading your email I think perhaps my wording was a bit loose. I
 meant commands in the pre-installed packages.
 So basically, out of the box what commands will R recognize.

 I had found the full reference manual for R online and parsed the table of
 contents into a nice XML file I could use as a possible solution.
 However, your attached file looks a bit more complete (haven't really given
 much thought to the reason yet). Thanks again for sending it.

 I'm using Coda on OS X, which is really designed for Web dev, but I like it
 so much I've added support for Stata and now want R. It's got Terminal
 bult-in, so I can invoke R through there.
 Anyway, my ultimate goal is to not only get syntax highlighting, but also
 autocompletion. If possible in the prediction, also get the method (where
 applicable) signature. Coda allows all this.
 I use this a lot when coding in PHP in Coda and C# in Visual Studio - I
 think Microsoft call it Intellisense or something.

 Cheers for the help.

 On 13/06/2010, at 9:47 PM, Joris Meys wrote:

  Hi,
 
  Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
  with StatET,... They contain lists you can use. Also the listings
  package of LaTeX contains a wordlist for R.
 
  Getting all installed commands out of R is not doable with a single
  command as far as I know. R works completely different than Stata; R
  is a fullblown programming language, not a statistical program. Try to
  find a list of all installed Perl commands for example...
 
  Attached is the recognition file of Tinn-R. Reserved 1 are special
  keywords, Reserved 2 is a list of the most commonly used commands in
  the pre-installed packages, and Reserved 3 is a list of common
  parameters of those functions. It's submitted with Tinn-R under the
  GNU license, so keep that in mind when using it.
 
  But instead of re-inventing the wheel and constructing your own
  editor, you could take a look at one of those mentioned above. On
  Windows, I recommend Tinn-R for daily scripting, and Eclipse for
  developing packages and the likes. Both offer the advantage of direct
  communication with the R console.
 
  Cheers
  Joris
 
  On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey coco.datamon...@gmail.com
 wrote:
  I'm pretty new to R, but have experience with other languages, both OO
 and scripting.
 
  I'm trying to add support for R to my text editor of choice and to do
 this I need a list of installed commands I can markup with XML.
  I'd then simply feed in the marked up list into my text editor's library
 and I'm off.
 
  I've done this in Stata before using the following command:
  getcmds using ~/Desktop/StataCommands.txt
 
  Does anyone know of a way to do this in R?
 
  Any pointers much appreciated.
 
  Thanks!
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Joris Meys
  Statistical consultant
 
  Ghent University
  Faculty of Bioscience Engineering
  Department of Applied mathematics, biometrics and process control
 
  tel : +32 9 264 59 87
  joris.m...@ugent.be
  ---
  Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
  Tinn-R_recognized words.r

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] Mid-P value for a chi-squared test

2010-06-13 Thread David Winsemius


On Jun 13, 2010, at 2:19 PM, (Ted Harding) wrote:


On 13-Jun-10 17:12:45, David Winsemius wrote:

On Jun 1, 2010, at 4:17 AM, Wilson, Andrew wrote:


Can anyone tell me how to calculate a mid-p value for a chi-squared
test in R?


I cannot see that this has been answered. It has a date from 12 days
ago but I cannot see a reply in the archives.

So, what is a mid-p value and which chi-square test are you  
asking
about? A simple data setup in R code with expected output  would  
speed

this discussion along.

David Winsemius, MD


The mid-p value is a device for improving the accuracy of a  
continuous

approximation to a distribution which in reality is discrete.

Intuitively, the idea is to treat the discrete probabilities of the
discrete distribution as if they were proportions in a histogram.
Then imagine fitting a continuous curve (e.g. a chi-squared density)
to the histogram. The fit (agreement between the proportion in one
histogram bar, and the probability below that portion of the curve
which lies in the same range) will be better if the curve goes through
the midpoint of the top of the bar.

This leads to the formal definition:

 mid-P = Prob(X  Xobs) + 0.5*Prob(X = Xobs)


Looking at Agresti and Gottard's piece, cited by one of the R  
functions, midPci {PropCIs} from a match to your suggested search  
strategy below, they say the lower mid-p CI would be defined as  
solving equation:


Pr_0L (X  x) + 1/2 x Pr_0L (X = x) = a/2.

Is that mathematically equivalent ( perhaps the NP dual to a p-value  
version) to what you offered? And is the upper CI then defined as  
solution to :


Pr_0U (X  x) + 1/2 x Pr_0U (X = x) = 1-a/2,,, ?


A number of R functions use this idea. Check out what you get by
going to http://finzi.psych.upenn.edu/nmz.html and entering mid-p
into the search box, and see whether any of them match (or come
close to) your particular case.

In the case of the chi-squared test, the idea is related to (but
not the same as) the Yates correction for continuity. chisq.test()
has an option correct=TRUE to force this, but only for 2x2 tables.

Ted.



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] ERROR need finite 'ylim' values

2010-06-13 Thread Peter Ehlers

Giuseppe,

See comments below.

On 2010-06-13 10:24, David Winsemius wrote:



Giuseppe wrote:


Hello:
I use R with MAC
I have a simple data table, numeric and text columns, named dt. The table
is imported through read.csv from a csv file. Row numbers are
automatically assigned, header is set to TRUE. there are 599 rows and
several columns.

I am trying to plot using the stripchart command: one numeric variable
(say dt$fnatg) vs a text column (say dt$pat). dt$pat contains one of 3
values: pos, neg, 

So I issue the following command:


stripchart (dt$fnatg~dt$pat)


and works well. it works well also with several options and nuances:


stripchart (dt$fnatg ~ dt$pat, method =jitter, jitter = 0.3, vertical

=TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)


Now I want my graph to exclude values for which dt$pat == 

I tried:


stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,

dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin
(ng/mL),xlab=Surgical Pathology)


there is no effect: the plot contains the same values as before

the I tried first subsetting the table:


patonly-(dt, dt$pat!=) which works well in creating a new table

excluding the unwanted rows. I have noticed that the new table keeps the
same row numbers assigned in the previous table. So row numbers now go 1 to
599 but with some intervals (for example there is no row 475 etc.).


then I use:


stripchart (patonly$fnatg ~ patonly$pat, method =jitter, jitter = 0.3,

vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)


and I get the following error:

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

I f I try the same command but I use another text variable (for example
patonly$gr) in the same table to split the plot, it now works:


stripchart (patonly$fnatg ~ patonly$gr, method =jitter, jitter = 0.3,

vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)



My question is two fold:
Why does not the subset command work within the stripchart command?

Why the subsetted table cannot be used in the stripchart command, when the
plotting variable is the same previously used in the subsetting process?




You appear to have adopted a strategy of using positional matching. Naming
your arguments will often result in more informative error messages.
Looking at the help page for stripchart, it appears that there is no
subset parameter to set in any of its methods and only the formula method
has a data argument. It should work with:

stripchart(formula1 , data=subset(dta, subset=criteria),   rest of
arguments preferably named   )

Your other option might be to use the with() function:

with( subset(patonly, pat!=),  stripchart(fnatg ~ gr,  ...named
arguments) )


HTH. and if it doesn't, then submit a reproducible data example to work
with.


Actually, Giuseppe appears to have stumbled upon a bug in the
stripchart() function.

First, here's a fix:
After your command

  patonly-(dt, dt$pat!=)

which I assume is meant to be

  patonly - subset(dt, dt$pat!=)

and which can be written as

  patonly - subset(dt, pat!=)

you should issue this:

  patonly$pat - factor(patonly$pat)

which will remove the empty level; stripchart() should
work well after that (and do use the data= argument
rather than dt$...).

Alternatively, you could change your text variables
(which I assume are factors) to character values (or
re-import your data with stringsAsFactors = FALSE).


Now for the bug in stripchart():
If the *first* group of the grouping variable is
empty, then stripchart() has a problem determining
the range of data values (x-values for horizontal
charts, y-values otherwise). I can replicate your
problem withe OrchardSprays dataset:

# this works:
stripchart(decrease ~ treatment, data = OrchardSprays,
   subset = treatment != B)

# this doesn't
stripchart(decrease ~ treatment, data = OrchardSprays,
   subset = treatment != A)

I'll be submitting a bug report (and I think the fix
is easy).

  -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] Count of unique factors within another factor

2010-06-13 Thread jim holtman
You can also use the sqldf package:

 x
   unit species
1   123ACMA
2   123LIDE
3   123LIDE
4   123SESE
5   123SESE
6   123SESE
7   345HEAR
8   345LOHI
9   345QUAG
10  345TODI
 require(sqldf)
 sqldf('select unit, count(distinct species) as count from x group by unit')
  unit count
1  123 3
2  345 4



On Sun, Jun 13, 2010 at 12:07 PM, Birdnerd haaszool...@gmail.com wrote:

 I have a data frame with two factors (sampling 'unit', 'species'). I want to
 calculate the number of unique 'species' per 'unit.' I can calculate the
 number of unique values for each variable separately, but can't get a count
 for each ‘unit’.

 data=read.csv(C:/Desktop/sr_sort_practice.csv)
 attach(data)

 data[1:10,]
   unit species
 1   123    ACMA
 2   123    LIDE
 3   123    LIDE
 4   123    SESE
 5   123    SESE
 6   123    SESE
 7   345    HEAR
 8   345    LOHI
 9   345    QUAG
 10  345    TODI…..

 sr.unique- lapply (data, unique)
 $unit
 [1] 123 345 216
 $species
  [1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE

 sapply (sr.unique,length)
    unit species
      3      10

 Then, I get stuck here because this unique species count is not given for
 each ‘unit’.
 What I'd like to get is:

 unit species
 123    3
 345    4
 216    --

 Thanks--

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Count-of-unique-factors-within-another-factor-tp2253545p2253545.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem that you are trying to solve?

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


Re: [R] Get a list of installed commands

2010-06-13 Thread David Winsemius


On Jun 13, 2010, at 3:44 PM, Henrique Dallazuanna wrote:


Try this:

sapply(installed.packages()[,1], function(x)try(ls(asNamespace(x


You could clean that up a bit with:

funlist - sapply(installed.packages()[,1],  
function(x)try(ls(asNamespace(x


function.list - fun.list[lapply(fun.list, length) 1]  # removes all  
entries for the package with no namespace.


I was left wondering if the speed characteristics of an implementation  
that needed to search against 32K names might be a bit slow?


 length(function.list)
[1] 211  # number of installed packages on my machine with namespaces
 sum(unlist(lapply(function.list, length)))
[1] 31960   # number of function names


You might want to limit your search to base R packages minus  
datasets ( from R-FAQ listing):


http://cran.r-project.org/doc/FAQ/R-FAQ.html#Add_002don-packages-from-CRAN

 core.pkgs - c(base, grDevices, graphics, grid, methods,  
splines, stats, stats4, tcltk, tools, utils)

core.fun.list - sapply(core.pkgs, function(x) try(ls(asNamespace(x
sum(unlist(lapply(core.fun.list[lapply(core.fun.list, length) 1],  
length)))

[1] 4036

--
David.



On Sun, Jun 13, 2010 at 9:30 AM, Data Monkey coco.datamon...@gmail.com 
wrote:



Thanks Joris. Very helpful.

I had thought of that, just curious to see if it was possible to  
get a

fresh list in R.
After reading your email I think perhaps my wording was a bit  
loose. I

meant commands in the pre-installed packages.
So basically, out of the box what commands will R recognize.

I had found the full reference manual for R online and parsed the  
table of

contents into a nice XML file I could use as a possible solution.
However, your attached file looks a bit more complete (haven't  
really given

much thought to the reason yet). Thanks again for sending it.

I'm using Coda on OS X, which is really designed for Web dev, but I  
like it
so much I've added support for Stata and now want R. It's got  
Terminal

bult-in, so I can invoke R through there.
Anyway, my ultimate goal is to not only get syntax highlighting,  
but also
autocompletion. If possible in the prediction, also get the method  
(where

applicable) signature. Coda allows all this.
I use this a lot when coding in PHP in Coda and C# in Visual Studio  
- I

think Microsoft call it Intellisense or something.

Cheers for the help.

On 13/06/2010, at 9:47 PM, Joris Meys wrote:


Hi,

Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
with StatET,... They contain lists you can use. Also the listings
package of LaTeX contains a wordlist for R.

Getting all installed commands out of R is not doable with a single
command as far as I know. R works completely different than Stata; R
is a fullblown programming language, not a statistical program.  
Try to

find a list of all installed Perl commands for example...

Attached is the recognition file of Tinn-R. Reserved 1 are special
keywords, Reserved 2 is a list of the most commonly used commands in
the pre-installed packages, and Reserved 3 is a list of common
parameters of those functions. It's submitted with Tinn-R under the
GNU license, so keep that in mind when using it.

But instead of re-inventing the wheel and constructing your own
editor, you could take a look at one of those mentioned above. On
Windows, I recommend Tinn-R for daily scripting, and Eclipse for
developing packages and the likes. Both offer the advantage of  
direct

communication with the R console.

Cheers
Joris

On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey coco.datamon...@gmail.com 


wrote:
I'm pretty new to R, but have experience with other languages,  
both OO

and scripting.


I'm trying to add support for R to my text editor of choice and  
to do

this I need a list of installed commands I can markup with XML.
I'd then simply feed in the marked up list into my text editor's  
library

and I'm off.


I've done this in Stata before using the following command:
getcmds using ~/Desktop/StataCommands.txt

Does anyone know of a way to do this in R?

Any pointers much appreciated.

Thanks!

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

http://www.R-project.org/posting-guide.html

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





--
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
Tinn-R_recognized words.r


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





--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 

Re: [R] ERROR need finite 'ylim' values

2010-06-13 Thread David Winsemius


On Jun 13, 2010, at 3:49 PM, Peter Ehlers wrote:


Giuseppe,

See comments below.

On 2010-06-13 10:24, David Winsemius wrote:



Giuseppe wrote:


Hello:
I use R with MAC
I have a simple data table, numeric and text columns, named dt.  
The table

is imported through read.csv from a csv file. Row numbers are
automatically assigned, header is set to TRUE. there are 599 rows  
and

several columns.

I am trying to plot using the stripchart command: one numeric  
variable
(say dt$fnatg) vs a text column (say dt$pat). dt$pat contains one  
of 3

values: pos, neg, 

So I issue the following command:


stripchart (dt$fnatg~dt$pat)


and works well. it works well also with several options and nuances:

stripchart (dt$fnatg ~ dt$pat, method =jitter, jitter = 0.3,  
vertical

=TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
Pathology)


Now I want my graph to exclude values for which dt$pat == 

I tried:


stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,
dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1,  
ylab=Thyroglobulin

(ng/mL),xlab=Surgical Pathology)


there is no effect: the plot contains the same values as before

the I tried first subsetting the table:


patonly-(dt, dt$pat!=) which works well in creating a new table
excluding the unwanted rows. I have noticed that the new table  
keeps the
same row numbers assigned in the previous table. So row numbers now  
go 1 to

599 but with some intervals (for example there is no row 475 etc.).


then I use:

stripchart (patonly$fnatg ~ patonly$pat, method =jitter, jitter  
= 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/ 
mL),xlab=Surgical

Pathology)


and I get the following error:

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

I f I try the same command but I use another text variable (for  
example

patonly$gr) in the same table to split the plot, it now works:

stripchart (patonly$fnatg ~ patonly$gr, method =jitter, jitter  
= 0.3,
vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/ 
mL),xlab=Surgical

Pathology)



My question is two fold:
Why does not the subset command work within the stripchart command?

Why the subsetted table cannot be used in the stripchart command,  
when the
plotting variable is the same previously used in the subsetting  
process?





You appear to have adopted a strategy of using positional matching.  
Naming

your arguments will often result in more informative error messages.
Looking at the help page for stripchart, it appears that there is no
subset parameter to set in any of its methods and only the  
formula method

has a data argument. It should work with:

stripchart(formula1 , data=subset(dta,  
subset=criteria),   rest of

arguments preferably named   )

Your other option might be to use the with() function:

with( subset(patonly, pat!=),  stripchart(fnatg ~ gr,  ...named
arguments) )


HTH. and if it doesn't, then submit a reproducible data example to  
work

with.


Actually, Giuseppe appears to have stumbled upon a bug in the
stripchart() function.


I thought when Guisseppe wrote:



I tried:


stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,
dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1,  
ylab=Thyroglobulin

(ng/mL),xlab=Surgical Pathology)

... that the expression: subset(dt, dt$pat!=) ,  would get  
erroneously matched to dlab, the third parameter in the formula  
method arg list, but maybe it would get matched to the data, the  
second parameter. I would also worry that specifying a data object,  
but then in a sense contravening that specification by reference to  
the full name in the formula specification (dt$fnatg) might cause  
problems.





First, here's a fix:
After your command

 patonly-(dt, dt$pat!=)

which I assume is meant to be

 patonly - subset(dt, dt$pat!=)

and which can be written as

 patonly - subset(dt, pat!=)

you should issue this:

 patonly$pat - factor(patonly$pat)

which will remove the empty level; stripchart() should
work well after that (and do use the data= argument
rather than dt$...).

Alternatively, you could change your text variables
(which I assume are factors) to character values (or
re-import your data with stringsAsFactors = FALSE).


Now for the bug in stripchart():
If the *first* group of the grouping variable is
empty, then stripchart() has a problem determining
the range of data values (x-values for horizontal
charts, y-values otherwise). I can replicate your
problem withe OrchardSprays dataset:

# this works:
stripchart(decrease ~ treatment, data = OrchardSprays,
  subset = treatment != B)

# this doesn't
stripchart(decrease ~ treatment, data = OrchardSprays,
  subset = treatment != A)

I'll be submitting a 

Re: [R] Count of unique factors within another factor

2010-06-13 Thread Charles C. Berry

On Sun, 13 Jun 2010, Birdnerd wrote:



I have a data frame with two factors (sampling 'unit', 'species'). I want to
calculate the number of unique 'species' per 'unit.' I can calculate the
number of unique values for each variable separately, but can't get a count
for each ‘unit’.



If I understand you

colSums( xtabs( ~ specie + unit , data ) !=0 )

HTH,

Chuck


data=read.csv(C:/Desktop/sr_sort_practice.csv)
attach(data)



data[1:10,]

  unit species
1   123ACMA
2   123LIDE
3   123LIDE
4   123SESE
5   123SESE
6   123SESE
7   345HEAR
8   345LOHI
9   345QUAG
10  345TODI…..


sr.unique- lapply (data, unique)

$unit
[1] 123 345 216
$species
[1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE


sapply (sr.unique,length)

   unit species
 3  10

Then, I get stuck here because this unique species count is not given for
each ‘unit’.
What I'd like to get is:

unit species
1233
3454
216--

Thanks--

--
View this message in context: 
http://r.789695.n4.nabble.com/Count-of-unique-factors-within-another-factor-tp2253545p2253545.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.



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

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


Re: [R] ERROR need finite 'ylim' values

2010-06-13 Thread Giuseppe


Peter Ehlers wrote:
 
 Giuseppe,
 
 See comments below.
 
 On 2010-06-13 10:24, David Winsemius wrote:


 Giuseppe wrote:

 Hello:
 I use R with MAC
 I have a simple data table, numeric and text columns, named dt. The
 table
 is imported through read.csv from a csv file. Row numbers are
 automatically assigned, header is set to TRUE. there are 599 rows and
 several columns.

 I am trying to plot using the stripchart command: one numeric variable
 (say dt$fnatg) vs a text column (say dt$pat). dt$pat contains one of 3
 values: pos, neg, 

 So I issue the following command:

 stripchart (dt$fnatg~dt$pat)

 and works well. it works well also with several options and nuances:

 stripchart (dt$fnatg ~ dt$pat, method =jitter, jitter = 0.3, vertical
 =TRUE,log=y, pch=1, ylab=Thyroglobulin (ng/mL),xlab=Surgical
 Pathology)

 Now I want my graph to exclude values for which dt$pat == 

 I tried:

 stripchart (dt$fnatg ~ dt$pat, method =jitter, subset (dt,
 dt$pat!=),jitter = 0.3, vertical =TRUE,log=y, pch=1,
 ylab=Thyroglobulin
 (ng/mL),xlab=Surgical Pathology)

 there is no effect: the plot contains the same values as before

 the I tried first subsetting the table:

 patonly-(dt, dt$pat!=) which works well in creating a new table
 excluding the unwanted rows. I have noticed that the new table keeps the
 same row numbers assigned in the previous table. So row numbers now go 1
 to
 599 but with some intervals (for example there is no row 475 etc.).

 then I use:

 stripchart (patonly$fnatg ~ patonly$pat, method =jitter, jitter =
 0.3,
 vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin
 (ng/mL),xlab=Surgical
 Pathology)

 and I get the following error:

 Error in plot.window(...) : need finite 'ylim' values
 In addition: Warning messages:
 1: In min(x) : no non-missing arguments to min; returning Inf
 2: In max(x) : no non-missing arguments to max; returning -Inf
 3: In min(x) : no non-missing arguments to min; returning Inf
 4: In max(x) : no non-missing arguments to max; returning -Inf

 I f I try the same command but I use another text variable (for example
 patonly$gr) in the same table to split the plot, it now works:

 stripchart (patonly$fnatg ~ patonly$gr, method =jitter, jitter = 0.3,
 vertical =TRUE,log=y, pch=1, ylab=Thyroglobulin
 (ng/mL),xlab=Surgical
 Pathology)


 My question is two fold:
 Why does not the subset command work within the stripchart command?

 Why the subsetted table cannot be used in the stripchart command, when
 the
 plotting variable is the same previously used in the subsetting process?



 You appear to have adopted a strategy of using positional matching.
 Naming
 your arguments will often result in more informative error messages.
 Looking at the help page for stripchart, it appears that there is no
 subset parameter to set in any of its methods and only the formula
 method
 has a data argument. It should work with:

 stripchart(formula1 , data=subset(dta, subset=criteria),   rest of
 arguments preferably named   )

 Your other option might be to use the with() function:

 with( subset(patonly, pat!=),  stripchart(fnatg ~ gr,  ...named
 arguments) )


 HTH. and if it doesn't, then submit a reproducible data example to work
 with.
 
 Actually, Giuseppe appears to have stumbled upon a bug in the
 stripchart() function.
 
 First, here's a fix:
 After your command
 
patonly-(dt, dt$pat!=)
 
 which I assume is meant to be
 
patonly - subset(dt, dt$pat!=)
 
 and which can be written as
 
patonly - subset(dt, pat!=)
 
 you should issue this:
 
patonly$pat - factor(patonly$pat)
 
 which will remove the empty level; stripchart() should
 work well after that (and do use the data= argument
 rather than dt$...).
 
 Alternatively, you could change your text variables
 (which I assume are factors) to character values (or
 re-import your data with stringsAsFactors = FALSE).
 
 
 Now for the bug in stripchart():
 If the *first* group of the grouping variable is
 empty, then stripchart() has a problem determining
 the range of data values (x-values for horizontal
 charts, y-values otherwise). I can replicate your
 problem withe OrchardSprays dataset:
 
 # this works:
 stripchart(decrease ~ treatment, data = OrchardSprays,
 subset = treatment != B)
 
 # this doesn't
 stripchart(decrease ~ treatment, data = OrchardSprays,
 subset = treatment != A)
 
 I'll be submitting a bug report (and I think the fix
 is easy).
 
-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.
 
 
Thank you Peter, both your solutions worked for me. Why do you insist for
using data = argument?
Giuseppe
Giuseppe
-- 
View this message in context: 
http://r.789695.n4.nabble.com/ERROR-need-finite-ylim-values-tp2253388p2253767.html
Sent from the R 

[R] Standard error of regression coefficient

2010-06-13 Thread Josh B
Hi all,

This should be a very simple question for you, whereas it is proving devilish 
for me.

How do I output the STANDARD ERROR of the regression coefficient (i.e., the 
standard error of b) from a simple linear regression?

Consider this data, taken directly from ?lm:

ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)

The problem is that neither of these lines of code seem to show me what I'm 
looking for:
 lm(weight ~ group)

Call:
lm(formula = weight ~ group)

Coefficients:
(Intercept) groupTrt  
  5.032   -0.371

 anova(lm.D9 - lm(weight ~ group))
Analysis of Variance Table

Response: weight
  Df Sum Sq Mean Sq F value Pr(F)
group  1 0.6882  0.6882  1.4191  0.249
Residuals 18 8.7292  0.4850

So what's the secret, then?

Thanks very much R users!
Josh



  
[[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] Standard error of regression coefficient

2010-06-13 Thread Erik Iverson

Josh B wrote:

Hi all,

This should be a very simple question for you, whereas it is proving devilish 
for me.

How do I output the STANDARD ERROR of the regression coefficient (i.e., the 
standard error of b) from a simple linear regression?



The first 'See Also' in ?lm is for ?summary.lm, which will give you what you 
want.  So simply pass your lm object to summary.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Best way to remove double precision round off chaff

2010-06-13 Thread Jason Rupert
I would like to get rid of the double precision round off chaff, so is the 
following the best way to handle it? 

 0.625-0.8+0.45-0.275
[1] -5.551115e-17
 round(0.625-0.8+0.45-0.275, digits=4)
[1] 0

Motivation for removing the chaff is for no other reason than to titty up the 
digits for display purposes and to help quicken the analysis of values that 
most definitely should be zero. 

Thanks for any insights and feedback.

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


Re: [R] Best way to remove double precision round off chaff

2010-06-13 Thread Bert Gunter
Jason:

Many print methods have specific options to control this: ?print.default

See also the digits and scipen settings in ?options for global control
(these can be put in your startup file, for example).

See also ?format and e.g. ?sprintf for more precise control of print format.

All of this has to do with what is displayed and does not change the
underlying values, of course, which round() and friends do.

Cheers,

Bert Gunter
Genentech Nonclinical Statistics

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Jason Rupert
Sent: Sunday, June 13, 2010 4:24 PM
To: R Project Help
Subject: [R] Best way to remove double precision round off chaff

I would like to get rid of the double precision round off chaff, so is the
following the best way to handle it? 

 0.625-0.8+0.45-0.275
[1] -5.551115e-17
 round(0.625-0.8+0.45-0.275, digits=4)
[1] 0

Motivation for removing the chaff is for no other reason than to titty up
the digits for display purposes and to help quicken the analysis of values
that most definitely should be zero. 

Thanks for any insights and feedback.

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

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


[R] Registration deadline, useR! 2010

2010-06-13 Thread Katharine Mullen
The final registration deadline for the R User Conference is June 20,
2010, one week away.  Later registration will not be possible on site!

Conference webpage:  http://www.R-project.org/useR-2010
Conference program: http://www.R-project.org/useR-2010/program.html

Registration:
  http://www.R-project.org/useR-2010/registration/registration.html

The conference is scheduled for July 21-23, 2010, and will take place at
the campus of the National Institute of Standards and Technology (NIST) in
Gaithersburg, Maryland, USA.

Following the successful useR! 2004, useR! 2006, useR! 2007, useR! 2008,
and useR! 2009, conferences, the conference is focused on:

   1. R as the `lingua franca' of data analysis and statistical computing,
   2. providing a platform for R users to discuss and exchange ideas on
  how R can be used to do statistical computations, data analysis,
  visualization and exciting applications in various fields,
   3. giving an overview of the new features of the rapidly evolving R
  project.

As for the predecessor conferences, the program will consist of two parts:
invited lectures and user-contributed sessions.  Prior to the conference,
there will be tutorials on R, descriptions of which are available at
   http://www.R-project.org/useR-2010/tutorials

INVITED LECTURES

Invited speakers will include

Mark Handcock, Frank Harrell Jr, Friedrich Leisch, Michael Meyer,
Richard Stallman, Luke Tierney, Diethelm Wuertz.

USER-CONTRIBUTED SESSIONS

The sessions will be a platform to bring together R users, contributors,
package maintainers and developers in the S spirit that `users are
developers'. People from different fields will show us how they solve
problems with R in fascinating applications.  The sessions are organized
by members of the program committee, including

 Dirk Eddelbuettel, John Fox, Virgilio Gomez-Rubio,
 Richard Heiberger, Torsten Hothorn, Aaron King, Jan de Leeuw,
 Nicholas Lewin-Koh, Andy Liaw, Uwe Ligges, Martin Maechler,
 Katharine Mullen, Heather Turner, Ravi Varadhan, H. D. Vinod,
 John Verzani, Alan Zaslavsky, Achim Zeileis.

The program will cover topics such as

 * Applied Statistics  Biostatistics
 * Bayesian Statistics
 * Bioinformatics
 * Chemometrics and Computational Physics
 * Data Mining
 * Econometrics  Finance
 * Environmetrics  Ecological Modeling
 * High Performance Computing
 * Machine Learning
 * Marketing  Business Analytics
 * Psychometrics
 * Robust Statistics
 * Social network analysis
 * Spatial Statistics
 * Statistics in the Social and Political Sciences
 * Teaching
 * Visualization  Graphics
 * and many more.

IMPORTANT DATES

*
**   2010-06-20 registration deadline
**(later registration NOT possible on site)
*
   2010-07-20   tutorials
   2010-07-21   conference start
   2010-07-23   conference end

We hope to meet you in Gaithersburg!

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


Re: [R] Get a list of installed commands

2010-06-13 Thread Data Monkey
Enrique,

That's fantastic. Thanks for that1
I got a couple of warnings but for the most part it looks like it gives what I 
want.

Cheers.
On 14/06/2010, at 5:44 AM, Henrique Dallazuanna wrote:

 Try this:
 
 sapply(installed.packages()[,1], function(x)try(ls(asNamespace(x
 
 On Sun, Jun 13, 2010 at 9:30 AM, Data Monkey coco.datamon...@gmail.com 
 wrote:
 Thanks Joris. Very helpful.
 
 I had thought of that, just curious to see if it was possible to get a fresh 
 list in R.
 After reading your email I think perhaps my wording was a bit loose. I meant 
 commands in the pre-installed packages.
 So basically, out of the box what commands will R recognize.
 
 I had found the full reference manual for R online and parsed the table of 
 contents into a nice XML file I could use as a possible solution.
 However, your attached file looks a bit more complete (haven't really given 
 much thought to the reason yet). Thanks again for sending it.
 
 I'm using Coda on OS X, which is really designed for Web dev, but I like it 
 so much I've added support for Stata and now want R. It's got Terminal 
 bult-in, so I can invoke R through there.
 Anyway, my ultimate goal is to not only get syntax highlighting, but also 
 autocompletion. If possible in the prediction, also get the method (where 
 applicable) signature. Coda allows all this.
 I use this a lot when coding in PHP in Coda and C# in Visual Studio - I think 
 Microsoft call it Intellisense or something.
 
 Cheers for the help.
 
 On 13/06/2010, at 9:47 PM, Joris Meys wrote:
 
  Hi,
 
  Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
  with StatET,... They contain lists you can use. Also the listings
  package of LaTeX contains a wordlist for R.
 
  Getting all installed commands out of R is not doable with a single
  command as far as I know. R works completely different than Stata; R
  is a fullblown programming language, not a statistical program. Try to
  find a list of all installed Perl commands for example...
 
  Attached is the recognition file of Tinn-R. Reserved 1 are special
  keywords, Reserved 2 is a list of the most commonly used commands in
  the pre-installed packages, and Reserved 3 is a list of common
  parameters of those functions. It's submitted with Tinn-R under the
  GNU license, so keep that in mind when using it.
 
  But instead of re-inventing the wheel and constructing your own
  editor, you could take a look at one of those mentioned above. On
  Windows, I recommend Tinn-R for daily scripting, and Eclipse for
  developing packages and the likes. Both offer the advantage of direct
  communication with the R console.
 
  Cheers
  Joris
 
  On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey coco.datamon...@gmail.com 
  wrote:
  I'm pretty new to R, but have experience with other languages, both OO and 
  scripting.
 
  I'm trying to add support for R to my text editor of choice and to do this 
  I need a list of installed commands I can markup with XML.
  I'd then simply feed in the marked up list into my text editor's library 
  and I'm off.
 
  I've done this in Stata before using the following command:
  getcmds using ~/Desktop/StataCommands.txt
 
  Does anyone know of a way to do this in R?
 
  Any pointers much appreciated.
 
  Thanks!
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide 
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Joris Meys
  Statistical consultant
 
  Ghent University
  Faculty of Bioscience Engineering
  Department of Applied mathematics, biometrics and process control
 
  tel : +32 9 264 59 87
  joris.m...@ugent.be
  ---
  Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
  Tinn-R_recognized words.r
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 -- 
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O


[[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] Count of unique factors within another factor

2010-06-13 Thread Dennis Murphy
Hi:

Another possibility:

as.data.frame(with(data[!duplicated(data), ], table(unit))
  unit Freq
1  1233
2  3454

HTH,
Dennis

On Sun, Jun 13, 2010 at 9:07 AM, Birdnerd haaszool...@gmail.com wrote:


 I have a data frame with two factors (sampling 'unit', 'species'). I want
 to
 calculate the number of unique 'species' per 'unit.' I can calculate the
 number of unique values for each variable separately, but can't get a count
 for each ‘unit’.

  data=read.csv(C:/Desktop/sr_sort_practice.csv)
  attach(data)

  data[1:10,]
   unit species
 1   123ACMA
 2   123LIDE
 3   123LIDE
 4   123SESE
 5   123SESE
 6   123SESE
 7   345HEAR
 8   345LOHI
 9   345QUAG
 10  345TODI…..

  sr.unique- lapply (data, unique)
 $unit
 [1] 123 345 216
 $species
  [1] ACMA  LIDE  SESE  HEAR  LOHI  QUAG  TODI  UMCA  ARSP  LIDE

  sapply (sr.unique,length)
unit species
  3  10

 Then, I get stuck here because this unique species count is not given for
 each ‘unit’.
 What I'd like to get is:

 unit species
 1233
 3454
 216--

 Thanks--

 --
 View this message in context:
 http://r.789695.n4.nabble.com/Count-of-unique-factors-within-another-factor-tp2253545p2253545.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.


[R] Multiple regressions

2010-06-13 Thread Amy Hessen

 
Hi,
Could you please tell me whether SVM can do multiple regression or not?
Cheers,
Amy   
_
Browse profiles for FREE! Meet local singles online.

[[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] logistic regression with 50 varaibales

2010-06-13 Thread array chip
Hi, this is not R technical question per se. I know there are many excellent 
statisticians in this list, so here my questions: I have dataset with ~1800 
observations and 50 independent variables, so there are about 35 samples per 
variable. Is it wise to build a stable multiple logistic model with 50 
independent variables? Any problem with this approach? Thanks

John

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


Re: [R] Multiple regressions

2010-06-13 Thread Steve Lianoglou
Hi,

On Sun, Jun 13, 2010 at 8:30 PM, Amy Hessen amy_4_5...@hotmail.com wrote:

 Hi,
 Could you please tell me whether SVM can do multiple regression or not?

Yes, an SVM can.

-steve

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

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


[R] font path problem in Ubuntu

2010-06-13 Thread Tae-Hoon Chung
I am not exactly sure whether this is the right place to ask this but I hope
this might be relevant to some other users of ubuntu linux as well.
I've installed R-2.11.1 in my ubuntu 10.04 LTS.
When I tried to generate a simple plot, however, it crashed:

 plot(rnorm(100))
Error in axis(side = side, at = at, labels = labels, ...) :
could not find any X11 fonts
Check that the Font Path is correct.
In addition: Warning messages:
1: In function (display = , width, height, pointsize, gamma, bg, :
locale not supported by Xlib: some X ops will operate in C locale
2: In function (display = , width, height, pointsize, gamma, bg, :
X cannot set locale modifiers
 sessionInfo()
R version 2.11.1 (2010-05-31)
i686-pc-linux-gnu

locale:
[1] LC_CTYPE=en_SG.utf8 LC_NUMERIC=C
[3] LC_TIME=en_SG.utf8 LC_COLLATE=en_SG.utf8
[5] LC_MONETARY=C LC_MESSAGES=en_SG.utf8
[7] LC_PAPER=en_SG.utf8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_SG.utf8 LC_IDENTIFICATION=C

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

It seems like this is due to genuine font path problem in Ubuntu (and so has
nothing to do with R itself) but I'm just asking if anyone was able to solve
this problem.
When I googled the font path in ubuntu, it produced some suggestions
regarding xorg.conf but following them didn't solve the problem for me.
Any ideas?dlgmlwj

Thanks in advance,
TH

-- 
Tae-Hoon Chung, PhD

[[alternative HTML version deleted]]

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


Re: [R] using latticeExtra plotting confidence intervals

2010-06-13 Thread Deepayan Sarkar
On Sun, Jun 13, 2010 at 10:10 AM, Joe P King j...@joepking.com wrote:
 I am wanting to plot a 95% confidence band using segplot, yet I am wanting
 to have groups. For example if I have males and females, and then I have
 them in different races, I want the racial groups in different panels. I
 have this minor code, completely made up but gets at what I am wanting, 4
 random samples and 4 samples of confidence, I know how to get A  B into one
 panel and CD in to another but how do I get the x axis to label them
 properly and have it categorized as two. I am not sure what to have to the
 left side of the formula. This is the example code:

(1) Your code results in

 length(categories)
[1] 2
 length(mu)
[1] 4

which makes the formula mu~ci.upper+ci.lower|categories meaningless.

(2) You are effectively plotting xyplot(mu ~ mu | categories), with
additional confidence intervals in one direction. I'm sure that's not
what you want, but it's not clear what it is that you do actually
want.

-Deepayan






 library(lattice)

 library(latticeExtra)



 sample1-rnorm(100,10,2)

 sample2-rnorm(100,50,3)

 sample3-rnorm(100,20,2)

 sample4-rnorm(100,40,1)

 mu1-mean(sample1)

 ci.upper1-mu1+2*2

 ci.lower1-mu1-2*2

 mu2-mean(sample2)

 ci.upper2-mu2+2*3

 ci.lower2-mu2-2*3

 mu3-mean(sample3)

 ci.upper3-mu3+2*2

 ci.lower3-mu3-2*2

 mu4-mean(sample4)

 ci.upper4-mu4+2*1

 ci.lower4-mu4-2*1

 categories-c(A,B)



 mu-cbind(mu1,mu2,mu3,mu4)

 ci.upper-cbind(ci.upper1,ci.upper2,ci.upper3,ci.upper4)

 ci.lower-cbind(ci.lower1,ci.lower2,ci.lower3,ci.lower4)

 segplot(mu~ci.upper+ci.lower|categories, centers = mu, horizontal=FALSE)



 I also tried this



 seq1-seq(1,4,1)

 segplot(seq1~ci.upper+ci.lower|categories, centers = mu,horizontal=FALSE)



 but it also gives poor x axis, I know this is probably an elementary problem
 but any help would be greatly appreciated.



 Heres my data structure, sorry for bombarding with all the code.



 structure(c(9.85647167881417, 50.1856561919426, 19.8477661576365,

 39.8575819498655, 13.8564716788142, 56.1856561919426, 23.8477661576365,

 41.8575819498655, 5.85647167881417, 44.1856561919426, 15.8477661576365,

 37.8575819498655), .Dim = c(1L, 12L), .Dimnames = list(NULL,

    c(mu1, mu2, mu3, mu4, ci.upper1, ci.upper2, ci.upper3,

    ci.upper4, ci.lower1, ci.lower2, ci.lower3, ci.lower4

    )))

 ---

 Joe King, M.A.

 Ph.D. Student

 University of Washington - Seattle

 Office: 404A

 Miller Hall

 206-913-2912

  mailto:j...@joepking.com j...@joepking.com

 ---

 Never throughout history has a man who lived a life of ease left a name
 worth remembering. --Theodore Roosevelt




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