[R] Installation problems: Linux Java and R not working together

2013-11-19 Thread Uwe Bohne

   Dear community,

   I almost tried for 3 days now to install rJava and package FSelector on my
   Linux machine but couldn't do so.
   I  searched all the forums and tried some tricks ... but unfortunately
   couldn't find any solution.
   First of all I did try to install rJava in my rkward without any changes ,
   that gave me the following error :

   configure: error: One or more JNI types differ from the corresponding native
   type.  You  may need to use non-standard compiler flags or a different
   compiler in order to fix this.

   ERROR: configuration failed for package ‘rJava’

   * removing ‘/home/uwe/.rkward/library/rJava’

   Warnmeldung:

   In install.packages(pkgs = c(rJava), lib = /home/uwe/.rkward/library, :

   Installation des Pakets ‘rJava’ hatte Exit-Status ungleich 0


   So then I started searching and found a tip. I did run the following;



   uwe@linux-k2a8:~ sudo R CMD javareconf
   Java interpreter : /usr/bin/java
   Java version : 1.7.0_45
   Java home path   : /usr/lib/jdk1.7.0_45/jre
   Java compiler: /usr/bin/javac
   Java headers gen.: /usr/bin/javah
   Java archive tool: /usr/bin/jar
   NOTE: Your JVM has a bogus java.library.path system property!
 Trying a heuristic via sun.boot.library.path to find jvm library...
   Java library path: $(JAVA_HOME)/lib/i386/client
   JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm
   JNI cpp flags: -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
   Updating Java configuration in /usr/lib/R
   Done.



   And also did check 


   uwe@linux-k2a8:~ java -version
   java version 1.7.0_45
   Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
   Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
   uwe@linux-k2a8:~ sudo /usr/sbin/update-alternatives --config java
   There are 4 choices for the alternative java (providing /usr/bin/java).
 SelectionPath Priority   Status
   
 0/usr/lib/jvm/jre-1.7.0-openjdk/bin/java   17147 auto mode
 1/usr/java/latest/bin/java 1 manual
   mode
   * 2/usr/lib/jdk_Oracle/bin/java  3 manual
   mode
 3/usr/lib/jvm/jre-1.5.0-gcj/bin/java   1500  manual
   mode
 4/usr/lib/jvm/jre-1.7.0-openjdk/bin/java   17147 manual
   mode
   Press enter to keep the current choice[*], or type selection number:



   I absolutely don't know what is wrong with that setup since my Java seems to
   have JDK and all the other things needed for R.

   For your Information here my system:
   uwe@linux-k2a8:~ uname -rm
   3.4.63-2.44-desktop i686

   uwe@linux-k2a8:~ cat /proc/version
   Linux version 3.4.63-2.44-desktop (geeko@buildhost) (gcc version 4.7.1
   20120723 [gcc-4_7-branch revision 189773] (S Linux) ) #1 SMP PREEMPT Wed Oct
   2 11:18:32 UTC 2013 (d91a619)



   I would be really thankful for any advise to get rJava (and FSelector)
   running soon.

   Best wishes

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


Re: [R] Reading in csv data with ff package

2013-11-19 Thread Jan van der Laan

The following seems to work:

data = read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows = 500,
  next.rows = 1005,sep=,,colClasses = c(integer,factor,logical))


'character' doesn't work because ff does not support character  
vectors. Character vector need to be stored as factors. The  
disadvantage of that is that the levels are stored in memory, so if  
the number of levels is very large (e.g. with unique strings) you  
might still run into memory problems.


'integer' doesn't work because read.csv.ffdf passes the colClasses on  
to read.table, which then tries to converts your second column to  
integer which it can't.


Jan



Nick McClure nfmccl...@gmail.com schreef:


I've spent some time trying to wrap my head around reading in large csv
files with the ff-package.  I think I know how to do it, but am bumping
into some problems.  I've tried to recreate the issues as best as I can
with a smaller example and maybe someone can help explain the problems.

The following code just creates a csv file with an integer column,
character column and logical column.
-
library(ff)
#Create data
size = 2000
fake.data =
data.frame(Integer=round(10*runif(size)),Character=sample(LETTERS,size,replace=T),Logical=sample(c(T,F),size,replace=T))

#Write to csv
write.csv(fake.data,data.csv,row.names=F)
-

Now to read it in as a 'ffdf' class, I can do the following:

-
data = read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows = 500,
next.rows = 1005,sep=,)
-

That works.  But with my current large data set, read.csv.ffdf is debating
with me about the classes it's importing. I was also messing around with
the first.rows/next.rows, but that's a question for another time. So I'll
try to load the data in, specifying the column types (same exact command,
except with specifying colClasses):

-

data = read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows =  
500, next.rows = 1005,sep=,,colClasses =  
c(integer,integer,logical))Error in scan(file, what, nmax,  
sep, dec, quote, skip, nlines, na.strings,  :

  scan() expected 'an integer', got 'J' data =
read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows = 500,
next.rows = 1005,sep=,,colClasses =
c(integer,character,logical))Error in ff(initdata = initdata,
length = length, levels = levels, ordered = ordered,  :
  vmode 'character' not implemented data =
read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows = 500,
next.rows = 1005,sep=,,colClasses = rep(character,3))Error in
ff(initdata = initdata, length = length, levels = levels, ordered =
ordered,  :
  vmode 'character' not implemented data =
read.csv.ffdf(x=NULL,file=data.csv,nrows=1001,first.rows = 500,
next.rows = 1005,sep=,,colClasses = rep(raw,3))Error in scan(file,
what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  scan() expected 'a raw', got '8601'

-
I just can't find a combination of classes that will result in this reading
in.  I really don't understand why the classes 'character' won't work for
all of them.  Any thoughts as to why?  I appreciate the help and time.

[[alternative HTML version deleted]]

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


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


Re: [R] Installation problems: Linux Java and R not working together

2013-11-19 Thread Prof Brian Ripley
First, read the posting guide.  This is a question about compiled code 
and belongs on R-devel.


Second, the answer will be in the config.log file for rJava which you 
have not shown us.  You need to download and unpack it, then run


R CMD INSTALL rJava

and look at rJava/config.log

If that is not sufficient clue, do follow up on R-devel.

On 19/11/2013 09:11, Uwe Bohne wrote:


Dear community,

I almost tried for 3 days now to install rJava and package FSelector on my
Linux machine but couldn't do so.
I  searched all the forums and tried some tricks ... but unfortunately
couldn't find any solution.
First of all I did try to install rJava in my rkward without any changes ,
that gave me the following error :

configure: error: One or more JNI types differ from the corresponding native
type.  You  may need to use non-standard compiler flags or a different
compiler in order to fix this.

ERROR: configuration failed for package ‘rJava’

* removing ‘/home/uwe/.rkward/library/rJava’

Warnmeldung:

In install.packages(pkgs = c(rJava), lib = /home/uwe/.rkward/library, :

Installation des Pakets ‘rJava’ hatte Exit-Status ungleich 0


So then I started searching and found a tip. I did run the following;



uwe@linux-k2a8:~ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.7.0_45
Java home path   : /usr/lib/jdk1.7.0_45/jre
Java compiler: /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
NOTE: Your JVM has a bogus java.library.path system property!
  Trying a heuristic via sun.boot.library.path to find jvm library...
Java library path: $(JAVA_HOME)/lib/i386/client
JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm
JNI cpp flags: -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
Updating Java configuration in /usr/lib/R
Done.



And also did check


uwe@linux-k2a8:~ java -version
java version 1.7.0_45
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
uwe@linux-k2a8:~ sudo /usr/sbin/update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).
  SelectionPath Priority   Status

  0/usr/lib/jvm/jre-1.7.0-openjdk/bin/java   17147 auto mode
  1/usr/java/latest/bin/java 1 manual
mode
* 2/usr/lib/jdk_Oracle/bin/java  3 manual
mode
  3/usr/lib/jvm/jre-1.5.0-gcj/bin/java   1500  manual
mode
  4/usr/lib/jvm/jre-1.7.0-openjdk/bin/java   17147 manual
mode
Press enter to keep the current choice[*], or type selection number:



I absolutely don't know what is wrong with that setup since my Java seems to
have JDK and all the other things needed for R.

For your Information here my system:
uwe@linux-k2a8:~ uname -rm
3.4.63-2.44-desktop i686

uwe@linux-k2a8:~ cat /proc/version
Linux version 3.4.63-2.44-desktop (geeko@buildhost) (gcc version 4.7.1
20120723 [gcc-4_7-branch revision 189773] (S Linux) ) #1 SMP PREEMPT Wed Oct
2 11:18:32 UTC 2013 (d91a619)



I would be really thankful for any advise to get rJava (and FSelector)
running soon.

Best wishes

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




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

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


[R] metafor escalc(measure=SMCC)

2013-11-19 Thread petretta

Dear all,

I use R 3.0 for Windows.

I ask how escalc(measure=SMCC) [metafor package] mathematically  
calculate yi and vi when only change score and SD change score are  
provided.


I used the example (repoted below) posted by Qiang Yue at:

http://r.789695.n4.nabble.com/using-metafor-for-meta-analysis-of-before-after-studies-escalc-SMCC-td4667233.html

but it is unclear for me the formula used to derive y1 and v1. I read  
the documentation of metafor package and it is all very well  
described, but I ask if possible for the formula used by  
escalc(measure=SMCC) to mathematically calculate yi and vi.  
Unfortunatel, I have no free access to the paper quoted in metafor  
package.


Beginning example:

fMRS
author year n mean_r sd_r mean_s sd_s r
1 Tom  2006 9  0   0 0.12 0.030   0
2 Jack 2012 6  0   0 0.23 0.050   0
3 Zhu  2013 8  0   0 0.18 0.050   0


dat_SMCC=escalc(measure=SMCC,data=fMRS,ni=n,m1i=mean_s,m2i=mean_r,sd1i=sd_s,sd2i=sd_r,ri=r

,append=TRUE)

dat_SMCC

author year n mean_r sd_r mean_s sd_s r  yi  vi
1 Tom 2006  9  0 00.12  0.03  0 3.6108 0.8354
2 Jack 2012 6  0 00.23  0.05  0 3.8674 1.4131
3 Zhu 2013  8  0 00.18  0.05  0 3.1975 0.7640



Sincerely

--
Mario Petretta
Department of Translational Medical Sciences
Naples University Federico II
Italy

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

2013-11-19 Thread Johannes Radinger
Hi,

I'd like to plot a boxplot and use a scatter.smooth line plot as an overlay
for this plot.
This works except for the problem that the x-axis ticks for both plots are
differently spaced:
The boxplot ticks are closer and the space between the outer most boxplots
and the plot region (box) is larger for boxplots than for the
scatter.smooth plot. Is there any plot-option that can be changed to
produce the desired plot.

Here an example to illustrate what problem I am facing:

x - c(rep(1,100),rep(2,100),rep(3,100))
y - c(rnorm(100,1),rnorm(100,2),rnorm(100,3))

boxplot(y~x)
par(new=TRUE)
scatter.smooth(x, y, xaxt=n, yaxt=n, ann=FALSE)

Moreover, I'd like to plot just the smoothed line only and not the
datapoints.
Any suggestions?

best regards,

J.

[[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] metafor escalc(measure=SMCC)

2013-11-19 Thread Viechtbauer Wolfgang (STAT)
Dear Mario,

You can always just inspect the code:

escalc.default

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of petre...@unina.it
 Sent: Tuesday, November 19, 2013 11:29
 To: r-help@r-project.org
 Subject: [R] metafor escalc(measure=SMCC)
 
 Dear all,
 
 I use R 3.0 for Windows.
 
 I ask how escalc(measure=SMCC) [metafor package] mathematically
 calculate yi and vi when only change score and SD change score are
 provided.
 
 I used the example (repoted below) posted by Qiang Yue at:
 
 http://r.789695.n4.nabble.com/using-metafor-for-meta-analysis-of-before-
 after-studies-escalc-SMCC-td4667233.html
 
 but it is unclear for me the formula used to derive y1 and v1. I read
 the documentation of metafor package and it is all very well
 described, but I ask if possible for the formula used by
 escalc(measure=SMCC) to mathematically calculate yi and vi.
 Unfortunatel, I have no free access to the paper quoted in metafor
 package.
 
 Beginning example:
 
 fMRS
 author year n mean_r sd_r mean_s sd_s r
 1 Tom  2006 9  0   0 0.12 0.030   0
 2 Jack 2012 6  0   0 0.23 0.050   0
 3 Zhu  2013 8  0   0 0.18 0.050   0
 
 
 dat_SMCC=escalc(measure=SMCC,data=fMRS,ni=n,m1i=mean_s,m2i=mean_r,sd1i=s
 d_s,sd2i=sd_r,ri=r
 ,append=TRUE)
  dat_SMCC
 author year n mean_r sd_r mean_s sd_s r  yi  vi
 1 Tom 2006  9  0 00.12  0.03  0 3.6108 0.8354
 2 Jack 2012 6  0 00.23  0.05  0 3.8674 1.4131
 3 Zhu 2013  8  0 00.18  0.05  0 3.1975 0.7640
 
 
 
 Sincerely
 
 --
 Mario Petretta
 Department of Translational Medical Sciences
 Naples University Federico II
 Italy
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] image plot with color scale

2013-11-19 Thread Witold E Wolski
I am plotting an image of correlations but need to add a color scale...

dat-matrix(rnorm(1000),ncol=5)
labels=c(a,b,c,d,e)
cortmp - cor(dat)

image(cortmp , axes = F )
axis( 1, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = 45,las=2,cex=1)
axis( 2, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = -45,las=1,cex=1)


 tried image.plot from package fields but :

image.plot(cortmp , axes = F )
axis( 1, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = 45,las=2,cex=1)
axis( 2, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = -45,las=1,cex=1)


but adding the axis fails... (the axis appears but the labls are not shown.

Can anyone can suggest an easy to use image function in R?

best
Witold

-- 
Witold Eryk Wolski

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


Re: [R] image plot with color scale

2013-11-19 Thread Jim Lemon

On 11/19/2013 10:07 PM, Witold E Wolski wrote:

I am plotting an image of correlations but need to add a color scale...

dat-matrix(rnorm(1000),ncol=5)
labels=c(a,b,c,d,e)
cortmp- cor(dat)

image(cortmp , axes = F )
axis( 1, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = 45,las=2,cex=1)
axis( 2, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = -45,las=1,cex=1)



tried image.plot from package fields but :


image.plot(cortmp , axes = F )
axis( 1, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = 45,las=2,cex=1)
axis( 2, at=seq(0,1,length=length(labels)) , labels=labels ,
cex.axis=0.8 ,srt = -45,las=1,cex=1)


but adding the axis fails... (the axis appears but the labls are not shown.

Can anyone can suggest an easy to use image function in R?


Hi Witold,
You may find that color2D.matplot (plotrix) will do what you want.

Jim

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


Re: [R] How to convert a 3 dimensional List to make a table with tables tabular()?

2013-11-19 Thread Duncan Murdoch

On 13-11-18 3:46 PM, Beckstrand, Janis, NCOD wrote:

I have information in a 3 dimensional list that I want to use to create
a table for a written report.



The 3d list was created by applying the epiR function  epitest  to a
list of 8 2x2 tables using  lapply.

The resulting list gives the 12 statistics with CIs,  that  generated by
epitest, for each of the 8 matrices (i9, i10, etc).



The list has the following form:



Statslow$i9

$aprev

 est lowerupper

1 0.2263884 0.2244714 0.228314



$tprev

est lower upper

1 0.204388 0.2025413 0.2062442



Statslow$i10

$aprev

 est lowerupper

1 0.227004 0.22545  0.228314



$tprev

est lower upper

1 0.204388 0.2025413 0.2062442





I want to create a report that has a table in the following format:

I9
i10

  Est   lower upper   Est  lower
upper



aprev   0.23 0.22 0.23   etc

tprev0.2   0.20 0.21

etc



I have read and tried the tables package pdf and also the information at

http://www.r-statistics.com/tag/data-frame/ about cast() and
tabular.cast_df.r(),

and also all the information I can find on nested tables, but have not
be successful.

I have tried to use melt() on the 3D list (to create a dataframe
statslow.d)  but get what seems more like S3 output :



   variable value   L2L1

1  est   0.2263884aprev   i9

2lower0.2244714aprev  i9

3upper   0.2283140aprev   i9

4  est   0.2043880 tprev  i9

5lower0.2025413tprev   i9

6upper   0.2062442tprev   i9



When I try to use it with tables() I get errors

and I can't see how to use the tables function on it to get what I want.

Here is the tables() code that I have tried:



class(statslow.d)

[1] data.frame


head(statslow.d)


   variable valueL2  L1

1  est 0.2263884 aprev  i9

2lower 0.2244714 aprev i9

3upper 0.2283140 aprev i9

4  est 0.2043880 tprev i9

5lower 0.2025413 tprev i9

6upper 0.2062442 tprev i9


tabular(statslow.d,L2~L1*variable)


Error in tabular.formula(as.formula(table, env = parent.frame()), ...) :


   data must be a dataframe, list or environment


statslow.d-as.data.frame(statslow.d)



tabular(statslow.d,L2~L1*variable)


Error in tabular.formula(as.formula(table, env = parent.frame()), ...) :


   data must be a dataframe, list or environment



I would appreciate any help or hints anyone can give.





The arguments to tabular are in the wrong order.  You need to give the 
formula first or name it as table.  So


tabular(L2 ~ L1*variable, data=statslow.d)

would not give an error, but it probably doesn't do what you want, 
because you don't specify a statistic, so it will default to a count. 
You could use the mean function, e.g.


tabular(L2 ~ L1*variable*Heading()*mean, data=statslow.d)

(The Heading() will suppress the column label mean.)  There are 
examples in the vignette that do fancy formatting of multiple columns, 
so it would be possible to write the interval as [.224, .228] for instance.


Duncan Murdoch

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


Re: [R] equal horizontal and vertical proportions in graphics

2013-11-19 Thread Jim Lemon

On 11/19/2013 01:03 PM, Mercutio Florid wrote:

I use several different versions of R, including RGui on Windows and rstudio on 
Linux.  In all cases, I use graphical commands, such as image().

image() displays rectangles, but I want to be able to guarantee that the 
heights of those rectangles will always equal the widths.  Typically, the 
rectangles come out with notable asymmetries.

Thus, if I need to draw a perfect circle with square pixels, I usually get a 
squashed ellipse with oblong pixels.

I have experimented with other commands, and I don't need to continue to use 
image() if some other command would be more suitable.


Hi Mercutio,
If you have matrices with equal numbers of rows and columns, try:

par(pty=s)

to get a square plot. If the number of rows and columns differ you will 
have to adjust the width and height of the graphic device and the 
margins to get squares. For getting circles regardless of plot 
dimensions, try draw.circle in the plotrix package.


Jim

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


Re: [R] equal horizontal and vertical proportions in graphics

2013-11-19 Thread Carl Witthoft

 see ?par .  Use the argument  asp=TRUE.


Mercutio Florid wrote
 I use several different versions of R, including RGui on Windows and
 rstudio on Linux.  In all cases, I use graphical commands, such as
 image().  
 
 image() displays rectangles, but I want to be able to guarantee that the
 heights of those rectangles will always equal the widths.  Typically, the
 rectangles come out with notable asymmetries.
 
 Thus, if I need to draw a perfect circle with square pixels, I usually get
 a squashed ellipse with oblong pixels.
 
 I have experimented with other commands, and I don't need to continue to
 use image() if some other command would be more suitable.
 
 Thanks.
 
   [[alternative HTML version deleted]]
 
 
 __

 R-help@

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





--
View this message in context: 
http://r.789695.n4.nabble.com/equal-horizontal-and-vertical-proportions-in-graphics-tp4680716p4680727.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] What is the difference between Mean Decrease Accuracy produced by importance(foo) vs foo$importance in a Random Forest Model?

2013-11-19 Thread Liaw, Andy
The difference is importance(..., scale=TRUE).  See the help page for detail.  
If you extract the $importance component from a randomForest object, you do not 
get the scaling.

Best,
Andy

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Lopez, Dan
Sent: Wednesday, November 13, 2013 12:16 PM
To: R help (r-help@r-project.org)
Subject: [R] What is the difference between Mean Decrease Accuracy produced by 
importance(foo) vs foo$importance in a Random Forest Model?

Hi R Expert Community,

My question: What is the difference between Mean Decrease Accuracy produced by 
importance(foo) vs foo$importance in a Random Forest Model?

I ran a Random Forest classification model where the classifier is binary. I 
stored the model in object FOREST_model. I than ran importance(FOREST_model) 
and FOREST_model$importance. I usually use the prior but decided to learn more 
about what is in summary(randomForest ) so I ran the latter. I expected both to 
produce identical output. Mean Decrease Gini is the only thing that is 
identical in both.

I looked at ? Random Forest and Package 'randomForest' documentation and didn't 
find any info explaining this difference.

I am not including a reproducible example because this is most likely 
something, perhaps simple, such as one  is divided by something (if so, what?), 
that I am just not aware of.


importance(FOREST_model)

 HC  TER MeanDecreaseAccuracy MeanDecreaseGini
APPT_TYP_CD_LL0.16025157 -0.521041660   0.1567029712.793624
ORG_NAM_LL0.20886631 -0.952057325   0.20208393   107.137049
NEW_DISCIPLINE0.20685079 -0.960719435   0.2007676286.495063


FOREST_model$importance


  HC   TER MeanDecreaseAccuracy MeanDecreaseGini

APPT_TYP_CD_LL0.0049473962 -3.727629e-03 0.0045949805
12.793624

ORG_NAM_LL0.0090715845 -2.401016e-02 0.0077298067   
107.137049

NEW_DISCIPLINE0.0130672572 -2.656671e-02 0.0114583178
86.495063

Dan Lopez
LLNL, HRIM, Workforce Analytics  Metrics


[[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.
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


Re: [R] Computational differences in R vs Excel

2013-11-19 Thread Carl Witthoft
There are several problems here.   The first is that it's rather unlikely you
really need 10-place accuracy to fit your data.  This suggests you may be
doing something inappropriate such as fitting the wrong function or trying
to extrapolate.   Since you haven't explained what process you have that
isn't converging, since clearly the fitting algorithms themselves have
converged.

Next,  you need to understand that both Excel and R have default convergence
tolerances which may not be identical (as well as default iteration limits).

And finally, of course, there's the question of machine precision limits,
although that is less likely to be a culprit in this instance.  


Soham wrote
 Hello,
  I am working on fitting a non-linear time series. The results which I
 found using R and Excel are not quite same up to 10-12 places after
 decimal (i require high precision because otherwise the process might not
 converge)
  For example, i am performing this simple arithmetic:
 23-(1.346493052*16)+(.663965156*11)+(.008569426*5)-15.23480728
 
 R gives the result -- -6.432232271 
 Excel gives the result --- -6.432232266
 
 The difference is negligible for all practical purposes but it leads to
 entirely different outcomes for me. I read some of the materials available
 online but none were of any help. What is the difference which prompts
 such different results? Is there anything that can be used to solve this
 problem ?
 
 Please give suggestion if you can. Thanks





--
View this message in context: 
http://r.789695.n4.nabble.com/Computational-differences-in-R-vs-Excel-tp4680726p4680730.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] can par()$pin be used to guarantee equal horizontal and vertical image lengths?

2013-11-19 Thread Mercutio Florid
  
Today at 10:03 AM  
I use several different versions of R, including RGui on Windows and 
rstudio on Linux.  In all cases, I use graphical commands, such as 
image().  

image() displays rectangles, but I want to be able to 
guarantee that the heights of those rectangles will always equal the 
widths.  Typically, the rectangles come out with notable asymmetries.

Thus, if I need to draw a perfect circle with square pixels, I usually get a 
squashed ellipse with oblong pixels.

I had hoped that par()$pin would be the answer, but I can't seem to set it 
properly.  For example:
 par()$pin
[1] 4.416111 1.685556
 source('~/.active-rstudio-document')
 par()$pin-c(4,4)
Error in par()$pin - c(4, 4) : invalid (NULL) left side of assignment
 str(par()$pin)
 num [1:2] 4.46 2.82
 par()$pin[2]-par()$pin[1]
Error in par()$pin[2] - par()$pin[1] : 
  invalid (NULL) left side of assignment

I
 have experimented with other commands, and I don't need to continue to 
use image() if some other command would be more suitable.

Thanks.
[[alternative HTML version deleted]]

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


[R] Repeated measures with categorical data

2013-11-19 Thread sualme
Hello,
I am working in a longitudinal study, with a categorical variable as a
dependent variable (alcohol consumption: no use, use, abuse and dependence)
with repeated measures (baseline, 1 year, 2 years). Besides I have another
variable with two groups: control and experimental. 

I would like to analyze the evolution in each group, I have though in lme,
but I am not sure if I can do an lme with a categorical vble as dependent
vble, or it must be continuous. If so, which model could I do? I have read
something about lmer, but doesn`t give p-values..


Thanks in advance!



--
View this message in context: 
http://r.789695.n4.nabble.com/Repeated-measures-with-categorical-data-tp4680733.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] Providing a Title for a Write.Table - Thinking of Titles in SPSS CTABLES

2013-11-19 Thread Adams, Jean
One way to do it, is just to insert another write.table() command giving
the text you want to write.  Here's a simple example:

myfile - c:/temp/junk.csv
for(i in 1:5) {
df - data.frame(x=rnorm(3), y=rnorm(3))
write.table(paste0(Run #, i), myfile, sep=\t, append=(i!=1),
col.names=FALSE, row.names=FALSE)
 write.table(df, myfile, sep=\t, append=TRUE, col.names=FALSE)
}

Jean


On Mon, Nov 18, 2013 at 8:42 AM, Zach Feinstein zfeinst...@isgmn.comwrote:

 I understand how I may use message() to provide some output on which run I
 will be looking at. However, I wish to automate it, and have it written out
 to a tab-delimited file. Below is the command to output my coefficients:

 write.table(zbetas, file = z_coeffs.csv, sep=\t, append = TRUE)

 I do this run multiple times. It appends the latter results to the end of
 my .csv file.

 Is there a way to say just before the write.table something to the effect
 of:

 title(First Run, append = TRUE)?

 Or perhaps there is a sub-command in the write.table to accomplish this.

 So when I interactively run my code it could be something like:

 First run
 Coeff1 0.34
 Coeff2 0.96

 Second run
 Coeff1 0.47
 Coeff2 0.95

 Thank you very much in advance.

 Zach Feinstein
 zfeinst...@isgmn.commailto:zfeinst...@isgmn.com
 (952) 277-0162
 (612) 590-4813 (mobile)


 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread Adams, Jean
Use lines() with loess.smooth() instead of scatter.smooth() to add to the
already existing boxplot.  For example,

boxplot(y~x)
lines(loess.smooth(x, y))

Jean


On Tue, Nov 19, 2013 at 4:43 AM, Johannes Radinger 
johannesradin...@gmail.com wrote:

 Hi,

 I'd like to plot a boxplot and use a scatter.smooth line plot as an overlay
 for this plot.
 This works except for the problem that the x-axis ticks for both plots are
 differently spaced:
 The boxplot ticks are closer and the space between the outer most boxplots
 and the plot region (box) is larger for boxplots than for the
 scatter.smooth plot. Is there any plot-option that can be changed to
 produce the desired plot.

 Here an example to illustrate what problem I am facing:

 x - c(rep(1,100),rep(2,100),rep(3,100))
 y - c(rnorm(100,1),rnorm(100,2),rnorm(100,3))

 boxplot(y~x)
 par(new=TRUE)
 scatter.smooth(x, y, xaxt=n, yaxt=n, ann=FALSE)

 Moreover, I'd like to plot just the smoothed line only and not the
 datapoints.
 Any suggestions?

 best regards,

 J.

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Repeated measures with categorical data

2013-11-19 Thread Ben Bolker
sualme susana.alberichmesa at osakidetza.net writes:

 
 Hello,
 I am working in a longitudinal study, with a categorical variable as a
 dependent variable (alcohol consumption: no use, use, abuse and dependence)
 with repeated measures (baseline, 1 year, 2 years). Besides I have another
 variable with two groups: control and experimental. 
 
 I would like to analyze the evolution in each group, I have though in lme,
 but I am not sure if I can do an lme with a categorical vble as dependent
 vble, or it must be continuous. If so, which model could I do? I have read
 something about lmer, but doesn`t give p-values..
 
 Thanks in advance!

  I'd take a look at the clmm function in the 'ordinal' package,
or possibly the MCMCglmm package, and consider posting future questions 
to r-sig-mixed-mod...@r-project.org .  (Your response variable is
probably considered 'ordinal', i.e. ordered categorical, which may
be helpful terminology in searching for solutions.)

  Ben Bolker

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


Re: [R] Computational differences in R vs Excel

2013-11-19 Thread S Ellison
   For example, i am performing this simple arithmetic:
  23-(1.346493052*16)+(.663965156*11)+(.008569426*5)-15.23480728
 
  R gives the result -- -6.432232271


My machine (win32, R 3.0.1) gives -6.432232266

Something about your machine, or typing, is different.

It shouldn't be R, as the help system implies it uses the same precision and 
IEEE floating point rules for all platforms


S Ellison



***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] Warning message during starts up

2013-11-19 Thread S Ellison
 During startup R gives a Warning message: Setting LC_CTYPE=en_US
 gnumeric  failed What is the error and how can I fix it?
Googling the error message provides a number of answers from various sites; 
perhaps you could try that? It seems silly to retype them here

Incidentally, the answers I saw seem to imply that it's a mac error, but you 
didn't mention your OS.

S Ellison


***
This email and any attachments are confidential. Any use...{{dropped:8}}

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


Re: [R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread Johannes Radinger
Thanks...that works great!

/J


On Tue, Nov 19, 2013 at 2:39 PM, Adams, Jean jvad...@usgs.gov wrote:

 Use lines() with loess.smooth() instead of scatter.smooth() to add to the
 already existing boxplot.  For example,

 boxplot(y~x)
 lines(loess.smooth(x, y))

 Jean


 On Tue, Nov 19, 2013 at 4:43 AM, Johannes Radinger 
 johannesradin...@gmail.com wrote:

 Hi,

 I'd like to plot a boxplot and use a scatter.smooth line plot as an
 overlay
 for this plot.
 This works except for the problem that the x-axis ticks for both plots are
 differently spaced:
 The boxplot ticks are closer and the space between the outer most boxplots
 and the plot region (box) is larger for boxplots than for the
 scatter.smooth plot. Is there any plot-option that can be changed to
 produce the desired plot.

 Here an example to illustrate what problem I am facing:

 x - c(rep(1,100),rep(2,100),rep(3,100))
 y - c(rnorm(100,1),rnorm(100,2),rnorm(100,3))

 boxplot(y~x)
 par(new=TRUE)
 scatter.smooth(x, y, xaxt=n, yaxt=n, ann=FALSE)

 Moreover, I'd like to plot just the smoothed line only and not the
 datapoints.
 Any suggestions?

 best regards,

 J.

 [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] How to extract sets of rows (not sorted) from text file in R, do some methods on these rows, save the result in another text file, then pick others set of rows and do the same

2013-11-19 Thread arun


Hi,
You may need ?split(), or ?aggregate() or ?ddply() from library(plyr)

dat1 - read.table(tex=1 2 4 7 8 9
1 4 5 8 9
1 4 5 6 9
2 3 4 8
3 6 7 8
1 5 6 9
2 5 7 9,header=FALSE,sep=,fill=TRUE) 
##

 res1 - do.call(rbind,lapply(split(dat1,dat1[,1]),function(x) 
c(V1=x[1,1],colSums(x[,-1],na.rm=TRUE
 write.table(res1,file=new.txt,row.names=FALSE,quote=FALSE)

#or
res2 - with(dat1,aggregate(cbind(V2,V3,V4,V5,V6),list(V1=V1),sum,na.rm=TRUE))


#or
library(plyr)
res3 - ddply(dat1,.(V1),colwise(sum,na.rm=TRUE))

A.K.


Hi, 
in a text file like 
1 2 4 7 8 9 
1 4 5 8 9 
1 4 5 6 9 
2 3 4 8 
3 6 7 8 
1 5 6 9 
2 5 7 9 
And so on 

where the first column represents group's number 

data - read.table(in.txt) 

## first: 
       - select rows that strat with one (check first column), apply
methods only on thes rows (expect for the first column in each line); 

       - save the result in another text file namely new.txt 

## second: 
       - do the same for these rows start with with two 

       - save the result in new.txt after the prevous result 
And so on 


I have 9000 lines and around 100 groups (first column). 



for (i in 1:9000 ) { 

newdata - data[ , which(data$V1 =='1')] 

- apply methods 
- save the result 
} 


Thanks for any help

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

2013-11-19 Thread Barry King
When using XLConnect's readWorksheet, instead of it correctly reading
string and numeric columns, I receive NA's with the following message:

 Error when trying to evaluate cell A2 - not implemented yet

I do not know what this means.  Can anyone please assist?

-- 
__
*Barry E. King, Ph.D.*
Chief Modeler
Qualex Consulting Services, Inc.
barry.k...@qlx.com
O: (317)940-5464
M: (317)507-0661
__

[[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] XLConnect error - not implemented yet

2013-11-19 Thread Rui Barradas

Hello,

I believe this is the sort of error message you should ask the 
maintainer about.


maintainer('XLConnect')
[1] Martin Studer martin.stu...@mirai-solutions.com

Hope this helps,

Rui Barradas

Em 19-11-2013 15:49, Barry King escreveu:

When using XLConnect's readWorksheet, instead of it correctly reading
string and numeric columns, I receive NA's with the following message:

 Error when trying to evaluate cell A2 - not implemented yet

I do not know what this means.  Can anyone please assist?



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


Re: [R] 3D Plot of Convex hull

2013-11-19 Thread David Winsemius

On Nov 18, 2013, at 8:01 PM, wwreith wrote:

 I have a data set in which I am trying to plot a convex hull in 3 dim. Below
 is a subset of the points I would use. Columns 2,3,4 are my x,y,z
 coordinates. I found some ways to plot 2D convext hulls or find a convex
 hull for higher dimensions, but not how to plot the data. 

Doing a simple search with: 3d convex hull r-project  I find the geometry 
package supports construction of multidimensional convex hulls and construction 
of tessalations. That package also suggsets the rgl package, which makes me 
think that 3d tessellations may be suitable for input to the rgl::surface3d 
function.

-- 
David.
 
 I have have attached an example of what I am shooting for in my plot. 
 
 Thanks for the help!
 
 6466574 37 225 27  53.69230 5
 6466575 38 225 27  47.54898 5
 6466576 39 225 27  58.71439 5
 6466577 40 225 27  67.40830 5
 6466578 41 225 27  64.40646 5
 6466579 42 225 27  71.59792 5
 6466580 43 225 27  66.10197 5
 6466581 44 225 27  61.53381 5
 6466582 45 225 27  69.49900 5
 6466583 46 225 27  93.91280 5
 6466800 31 226 27 102.78361 5
 6466801 32 226 27  69.58787 5
 6466802 33 226 27  67.53348 5
 6466803 34 226 27  66.83624 5
 6466804 35 226 27  52.74981 5
 6466805 36 226 27  58.10865 5
 6466806 37 226 27  64.29259 5
 6466807 38 226 27  55.37983 5
 6466808 39 226 27  58.48212 5
 6466809 40 226 27  66.21062 5
 6466810 41 226 27  58.39149 5
 6466811 42 226 27  60.40741 5
 6466812 43 226 27  60.95507 5
 6466813 44 226 27  64.16653 5
 6466814 45 226 27  62.48255 5
 6466815 46 226 27  74.37065 5
 6466816 47 226 27 100.51262 5 
 
 http://r.789695.n4.nabble.com/file/n4680712/turbo_ch3d_lung3.jpg 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/3D-Plot-of-Convex-hull-tp4680712.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Rotation of parallel lines

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 5:53 AM, Tonio wrote:

 Thank you for your post. I believe that it is possible to make a function to 
 rotate a graphical component that might be based on the rotation matrix.
 
 
 I'll take a look to the packages anyway...


It's certainly possible to rotate  abstract segment endpoints using a 
rotation matrix. What is not possible is to claenly erase the original image 
and replace it with the new image. You could also repeatedly draw new plots 
with a segment being rotated (around what center you do not say) in angular 
increments and then assemble a sequence of plots with the animation package. (A 
rotation matrix would transform segment end-points around the origin.)  As 
always, a complete description of the desired result is needed and I do not 
believe you have yet provided such.

-- 
David.
 
 Den 15:38 mandag den 18. november 2013 skrev David Winsemius 
 dwinsem...@comcast.net:
 
 
 On Nov 18, 2013, at 7:27 AM, Tonio wrote:
 
 
 
 Dear list,
 
 Consider these two parallel segments in a plot.
 
 plot(c(1, 6), c(2, 2), type=n, xlim=c(0, 7), ylim=c(-2, 6))
 segments(1, 1, 6, 1)
 segments(1, 3, 6, 3)
 
 
 
 How can I rotate the two lines together by a defined angle?
 
 Base graphics do not support object operations. You need to do the  
 calculation and redraw the plot.
 
 Either lattice or ggplot2 which depend upon the grid system would  
 have the possibility to rotate a component.
 
 -- 
 
 David Winsemius, MD
 Alameda, CA, USA

David Winsemius
Alameda, CA, USA

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


Re: [R] Computational differences in R vs Excel

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 6:02 AM, S Ellison wrote:

 For example, i am performing this simple arithmetic:
23-(1.346493052*16)+(.663965156*11)+(.008569426*5)-15.23480728
 
 R gives the result -- -6.432232271
 
 
 My machine (win32, R 3.0.1) gives -6.432232266
 
 Something about your machine, or typing, is different.

I get the same, at least when printing to the same degree of accuracy:

 x - 23-(1.346493052*16)+(.663965156*11)+(.008569426*5)-15.23480728 
 print(x, digits=10)
[1] -6.432232266


Mac OSX 10.7.5, R 3.0.2

 It shouldn't be R, as the help system implies it uses the same precision and 
 IEEE floating point rules for all platforms
 
 
 S Ellison


-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] Overlay boxplot and scatter.smooth line

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 2:43 AM, Johannes Radinger wrote:

 Hi,
 
 I'd like to plot a boxplot and use a scatter.smooth line plot as an overlay
 for this plot.
 This works except for the problem that the x-axis ticks for both plots are
 differently spaced:
 The boxplot ticks are closer and the space between the outer most boxplots
 and the plot region (box) is larger for boxplots than for the
 scatter.smooth plot. Is there any plot-option that can be changed to
 produce the desired plot.
 
 Here an example to illustrate what problem I am facing:
 
 x - c(rep(1,100),rep(2,100),rep(3,100))
 y - c(rnorm(100,1),rnorm(100,2),rnorm(100,3))
 
 boxplot(y~x)
 par(new=TRUE)
 scatter.smooth(x, y, xaxt=n, yaxt=n, ann=FALSE)
 
 Moreover, I'd like to plot just the smoothed line only and not the
 datapoints.

?boxplot  #  sends you to ?boxplot.stats which should be used to  determine 
what user coordinates are being used when plotting the boxplot.

xlim  would be suitable for getting both plots on hte same x-scale.
 

-- 

David Winsemius
Alameda, CA, USA

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


[R] Inverse of Probit

2013-11-19 Thread Calum
Hi there,
I hope someone can help me.

I have a dataset of Concentration against Mortality, and I am trying to
compare the use of Logit and Probit models using this data.

The issue I am having is trying to back transform the data from the probit
model, to plot it in normal space instead of log space.
I know this can be done with a logit model using the code below, where
ilogit is a function for the inverse logit:

NEWCONC - seq(0,0.6, length=25)
NEWMORT - predict(LOGIT, Conc=NEWCONC, se=TRUE)

plot(data=DATA, Prop~Conc)
lines(NEWCONC, ilogit(NEWMORT$fit))

However, I can't seem to find a function equivalent to ilogit for a probit
model, that I could use in this code:

NEWCONC - seq(0,0.6, length=25)
NEWMORT - predict(PROBIT, Conc=NEWCONC, se=TRUE)

plot(data=DATA, Prop~Conc)
lines(NEWCONC,###INVERSE PROBIT### (NEWMORT$fit))


Any advice on this issue would be appreciated,
Thanks,
Calum



--
View this message in context: 
http://r.789695.n4.nabble.com/Inverse-of-Probit-tp4680752.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] Inverse of Probit

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 10:59 AM, Calum wrote:

 Hi there,
 I hope someone can help me.
 
 I have a dataset of Concentration against Mortality, and I am trying to
 compare the use of Logit and Probit models using this data.
 
 The issue I am having is trying to back transform the data from the probit
 model, to plot it in normal space instead of log space.
 I know this can be done with a logit model using the code below, where
 ilogit is a function for the inverse logit:
 
 NEWCONC - seq(0,0.6, length=25)
 NEWMORT - predict(LOGIT, Conc=NEWCONC, se=TRUE)
 
 plot(data=DATA, Prop~Conc)
 lines(NEWCONC, ilogit(NEWMORT$fit))
 
 However, I can't seem to find a function equivalent to ilogit for a probit
 model, that I could use in this code:
 
 NEWCONC - seq(0,0.6, length=25)
 NEWMORT - predict(PROBIT, Conc=NEWCONC, se=TRUE)

You should be looking at ?predict and paying particular attention to the 'type' 
argument. I think you want: type='response'


 
 plot(data=DATA, Prop~Conc)
 lines(NEWCONC,###INVERSE PROBIT### (NEWMORT$fit))
 
 
 Any advice on this issue would be appreciated,
 Thanks,
 Calum
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Inverse-of-Probit-tp4680752.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Optim function Hessian matrix

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 12:09 PM, sofeira taajobian wrote:

 Dear  R Users
 Hi,
 
 
 I have very emergency problems in my programming about  finding  MLE
 with optim command. I reproduced it  with real data. I guess that my
 function object in optim is very sensitive because it has power
 function .
 Then optim give me lower or initial values for estimates with these
 warnings for Hessian matrix computation:
 1: In log(B2 * (C2^(y + v))) : NaNs produced
 2: In log(B3 * C3^(x + u1)) : NaNs produced
 3: In log(B4 * C4^(y + u2)) : NaNs produced
 4: In log(B1 * (C1^(x + v))) : NaNs produced
 But I have  in result a hessian matrix with only first (2*2) block and
 other values are zero.
 It would not be the problem of code lead to this.  plz check the code
 and data, I attach them with this email. hope it can reduce some
 workload as copying and pasting.
 
 
 what may lead to this and any possible way to solve it? any suggestion
 are  appreciated. Plz help me as soon as possible because I don’t have
 enough time.
 data4.txt

Only the txt file made it throuhg. If you attached a .R file it would have been 
scrubbed. You need to rename it something.txt so you mailer sends it as 
MIME-text rather than unknown-type.


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

David Winsemius
Alameda, CA, USA

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


Re: [R] Hide return values

2013-11-19 Thread Brian Diggs

On 11/17/2013 5:28 AM, David Winsemius wrote:


On Nov 17, 2013, at 3:21 AM, Chris89 wrote:


Hi everyone!

I am in the process of writing an R-package and while writing a summary
function, I have come across a problem. I am able to print a summary
table
(as in a standard glm() summary) by using *cat()* but the values I
return is
also printet.
How am I able to remove the return values from being printet, but still
being able to grab using e.g. summary$coeff??


?invisible


But don't. See R FAQ 8.1 for a better approach.

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

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


[R] Does function read.sas7bdat() have some memory limitations?

2013-11-19 Thread Li, Xiaochun
Dear R-ers,

I was trying to read in a large sas7bdat file (size 148094976 bytes) using 
'read.sas7bdat()', but it did not read in the data correctly.  E.g., the first 
5 rows will come out like this (I'm omitting other columns to keep it readable):

   PERSON_ID   age
1  5.399114e-315 5.329436e-315
2  5.399114e-315 5.328302e-315
3  5.399114e-315 5.332026e-315
4  5.399114e-315 5.329112e-315
5  5.399114e-315 5.331055e-315

If I reduced the original sas dataset to the first 5 rows, 'read.sas7bdat' read 
them in correctly:

  PERSON_ID age
1612569  55
2612571  48
3612580  78
4612606  53
5612617  66

So for now I first saved the sas dataset as .csv, then read using 'read.csv', 
everything is fine.  

Any suggestion why 'read.sas7bdat' didn't work, and if some fix in its code can 
make it work?

Thank  you.
_ 
Xiaochun Li, Ph.D. 
Department of Biostatistics 
Indiana University 
School of Medicine and
Richard M. Fairbanks School of Public Health

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


[R] Help with removing extra legend elements in ggplot

2013-11-19 Thread Matthew Van Scoyoc
I can't get the fine tuning right with my legend. I get an extra legend
element 10 which is the point size in my plot. Can someone help me get rid
of this extra element? Additionally I would also like to reduce the size of
the legend.

If you want to reproduce my figure you can  download my data in csv format
here
https://github.com/scoyoc/EcoSiteDelineation/blob/master/VegNMDS_scores.csv

.

Here is my code...

veg.nmds.sc = read.csv(VegNMDS_scores.csv, header = T)

nmds.fig = ggplot(data = veg.nmds.sc, aes(x = NMDS1, y = NMDS2))
nmds.fig + geom_point(aes(color = VegType, shape = VegType, size = 10)) +
  scale_colour_manual(name = Vegetation Type,
  values = c(blue, magenta, gray50, red,
 cyan3,
 green4, gold)) +
  scale_shape_manual(name = Vegetation Type, values = c(15, 16, 17, 18,
 15, 16, 17)) +
  theme_bw() +
  theme(panel.background = element_blank(), panel.grid.major =
 element_blank(),
panel.grid.minor = element_blank(),
legend.key = element_rect(color = white)
)

I have been messing around with
  theme(..., legend.key.size = unit(1, cm))
but I keep getting the error could not find function unit. I'm not sure
why, isn't unit supposed to be part of the legend.key argument?

... and the resulting figure...
http://r.789695.n4.nabble.com/file/n4680764/VegNMDS.jpeg


Thanks for the help.
MVS
=
Matthew Van Scoyoc
Graduate Research Assistant, Ecology
Wildland Resources Department http://www.cnr.usu.edu/wild/  Ecology
Center http://www.usu.edu/ecology/
Quinney College of Natural Resources http://cnr.usu.edu/
Utah State University
Logan, UT
=
Think SNOW!

[[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] Help with removing extra legend elements in ggplot

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 3:44 PM, Matthew Van Scoyoc wrote:

 I can't get the fine tuning right with my legend. I get an extra legend
 element 10 which is the point size in my plot. Can someone help me get rid
 of this extra element? Additionally I would also like to reduce the size of
 the legend.
 
 If you want to reproduce my figure you can  download my data in csv format
 here
 https://github.com/scoyoc/EcoSiteDelineation/blob/master/VegNMDS_scores.csv
 
 .
 
 Here is my code...
 
 veg.nmds.sc = read.csv(VegNMDS_scores.csv, header = T)
 
 nmds.fig = ggplot(data = veg.nmds.sc, aes(x = NMDS1, y = NMDS2))
 nmds.fig + geom_point(aes(color = VegType, shape = VegType, size = 10)) +
 scale_colour_manual(name = Vegetation Type,
 values = c(blue, magenta, gray50, red,
 cyan3,
green4, gold)) +
 scale_shape_manual(name = Vegetation Type, values = c(15, 16, 17, 18,
 15, 16, 17)) +
 theme_bw() +
 theme(panel.background = element_blank(), panel.grid.major =
 element_blank(),
   panel.grid.minor = element_blank(),
   legend.key = element_rect(color = white)
   )
 
 I have been messing around with
 theme(..., legend.key.size = unit(1, cm))
 but I keep getting the error could not find function unit. I'm not sure
 why, isn't unit supposed to be part of the legend.key argument?

Try this workaround to what sounds like a bug:

library(grid)

# then repeat the call.

-- 

David Winsemius
Alameda, CA, USA

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


[R] (no subject)

2013-11-19 Thread Jim Silverton
I generated some random data using R and then trying to see if it came from
the same distribution but the erros keep piling.  Can anyone help?



y=rchisq(10,1)
mean(y)
var(y)
library(MASS)
fitdistr(y, chi-squared, start = list(4), method = Brent, lower=0.9,
upper=3)


-- 
Thanks,
Jim.

[[alternative HTML version deleted]]

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


Re: [R] Help with removing extra legend elements in ggplot

2013-11-19 Thread Matthew Van Scoyoc
No dice. I still get the 10 legend element.
Thanks for the quick reply.
Cheers,

MVS
=
Matthew Van Scoyoc
Graduate Research Assistant, Ecology
Wildland Resources Department http://www.cnr.usu.edu/wild/  Ecology
Center http://www.usu.edu/ecology/
Quinney College of Natural Resources http://cnr.usu.edu/
Utah State University
Logan, UT

mvansco...@aggiemail.usu.eduhttps://sites.google.com/site/scoyoc/
=
Think SNOW!


On Tue, Nov 19, 2013 at 5:12 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Nov 19, 2013, at 3:44 PM, Matthew Van Scoyoc wrote:

  I can't get the fine tuning right with my legend. I get an extra legend
  element 10 which is the point size in my plot. Can someone help me get
 rid
  of this extra element? Additionally I would also like to reduce the size
 of
  the legend.
 
  If you want to reproduce my figure you can  download my data in csv
 format
  here
  
 https://github.com/scoyoc/EcoSiteDelineation/blob/master/VegNMDS_scores.csv
 
  .
 
  Here is my code...
 
  veg.nmds.sc = read.csv(VegNMDS_scores.csv, header = T)
 
  nmds.fig = ggplot(data = veg.nmds.sc, aes(x = NMDS1, y = NMDS2))
  nmds.fig + geom_point(aes(color = VegType, shape = VegType, size = 10))
 +
  scale_colour_manual(name = Vegetation Type,
  values = c(blue, magenta, gray50, red,
  cyan3,
 green4, gold)) +
  scale_shape_manual(name = Vegetation Type, values = c(15, 16, 17, 18,
  15, 16, 17)) +
  theme_bw() +
  theme(panel.background = element_blank(), panel.grid.major =
  element_blank(),
panel.grid.minor = element_blank(),
legend.key = element_rect(color = white)
)
 
  I have been messing around with
  theme(..., legend.key.size = unit(1, cm))
  but I keep getting the error could not find function unit. I'm not sure
  why, isn't unit supposed to be part of the legend.key argument?

 Try this workaround to what sounds like a bug:

 library(grid)

 # then repeat the call.

 --

 David Winsemius
 Alameda, CA, USA



[[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] Help with removing extra legend elements in ggplot

2013-11-19 Thread Dennis Murphy
The additional element comes from this code:

geom_point(aes(color = VegType, shape = VegType, size = 10))

Take the size argument outside the aes() statement and the legend will
disappear:

geom_point(aes(color = VegType, shape = VegType), size = 10)

The aes() statement maps a variable to a plot aesthetic. In this case
you're mapping VegType to color and shape. You want to *set* the size
aesthetic to a constant value, and that is done by assigning the value
10 to the size aesthetic outside of aes().

Dennis

On Tue, Nov 19, 2013 at 4:35 PM, Matthew Van Scoyoc sco...@gmail.com wrote:
 No dice. I still get the 10 legend element.
 Thanks for the quick reply.
 Cheers,

 MVS
 =
 Matthew Van Scoyoc
 Graduate Research Assistant, Ecology
 Wildland Resources Department http://www.cnr.usu.edu/wild/  Ecology
 Center http://www.usu.edu/ecology/
 Quinney College of Natural Resources http://cnr.usu.edu/
 Utah State University
 Logan, UT

 mvansco...@aggiemail.usu.eduhttps://sites.google.com/site/scoyoc/
 =
 Think SNOW!


 On Tue, Nov 19, 2013 at 5:12 PM, David Winsemius 
 dwinsem...@comcast.netwrote:


 On Nov 19, 2013, at 3:44 PM, Matthew Van Scoyoc wrote:

  I can't get the fine tuning right with my legend. I get an extra legend
  element 10 which is the point size in my plot. Can someone help me get
 rid
  of this extra element? Additionally I would also like to reduce the size
 of
  the legend.
 
  If you want to reproduce my figure you can  download my data in csv
 format
  here
  
 https://github.com/scoyoc/EcoSiteDelineation/blob/master/VegNMDS_scores.csv
 
  .
 
  Here is my code...
 
  veg.nmds.sc = read.csv(VegNMDS_scores.csv, header = T)
 
  nmds.fig = ggplot(data = veg.nmds.sc, aes(x = NMDS1, y = NMDS2))
  nmds.fig + geom_point(aes(color = VegType, shape = VegType, size = 10))
 +
  scale_colour_manual(name = Vegetation Type,
  values = c(blue, magenta, gray50, red,
  cyan3,
 green4, gold)) +
  scale_shape_manual(name = Vegetation Type, values = c(15, 16, 17, 18,
  15, 16, 17)) +
  theme_bw() +
  theme(panel.background = element_blank(), panel.grid.major =
  element_blank(),
panel.grid.minor = element_blank(),
legend.key = element_rect(color = white)
)
 
  I have been messing around with
  theme(..., legend.key.size = unit(1, cm))
  but I keep getting the error could not find function unit. I'm not sure
  why, isn't unit supposed to be part of the legend.key argument?

 Try this workaround to what sounds like a bug:

 library(grid)

 # then repeat the call.

 --

 David Winsemius
 Alameda, CA, USA



 [[alternative HTML version deleted]]

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

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


Re: [R] Help with removing extra legend elements in ggplot

2013-11-19 Thread Matthew Van Scoyoc
Awesome! Thanks for the fix Dennis, and thanks for clearing up aes() too.
It makes sense now.
Cheers,

MVS
=
Matthew Van Scoyoc
Graduate Research Assistant, Ecology
Wildland Resources Department http://www.cnr.usu.edu/wild/  Ecology
Center http://www.usu.edu/ecology/
Quinney College of Natural Resources http://cnr.usu.edu/
Utah State University
Logan, UT

mvansco...@aggiemail.usu.eduhttps://sites.google.com/site/scoyoc/
=
Think SNOW!


On Tue, Nov 19, 2013 at 5:52 PM, Dennis Murphy djmu...@gmail.com wrote:

 The additional element comes from this code:

 geom_point(aes(color = VegType, shape = VegType, size = 10))

 Take the size argument outside the aes() statement and the legend will
 disappear:

 geom_point(aes(color = VegType, shape = VegType), size = 10)

 The aes() statement maps a variable to a plot aesthetic. In this case
 you're mapping VegType to color and shape. You want to *set* the size
 aesthetic to a constant value, and that is done by assigning the value
 10 to the size aesthetic outside of aes().

 Dennis

 On Tue, Nov 19, 2013 at 4:35 PM, Matthew Van Scoyoc sco...@gmail.com
 wrote:
  No dice. I still get the 10 legend element.
  Thanks for the quick reply.
  Cheers,
 
  MVS
  =
  Matthew Van Scoyoc
  Graduate Research Assistant, Ecology
  Wildland Resources Department http://www.cnr.usu.edu/wild/  Ecology
  Center http://www.usu.edu/ecology/
  Quinney College of Natural Resources http://cnr.usu.edu/
  Utah State University
  Logan, UT
 
  mvansco...@aggiemail.usu.eduhttps://sites.google.com/site/scoyoc/
  =
  Think SNOW!
 
 
  On Tue, Nov 19, 2013 at 5:12 PM, David Winsemius dwinsem...@comcast.net
 wrote:
 
 
  On Nov 19, 2013, at 3:44 PM, Matthew Van Scoyoc wrote:
 
   I can't get the fine tuning right with my legend. I get an extra
 legend
   element 10 which is the point size in my plot. Can someone help me
 get
  rid
   of this extra element? Additionally I would also like to reduce the
 size
  of
   the legend.
  
   If you want to reproduce my figure you can  download my data in csv
  format
   here
   
 
 https://github.com/scoyoc/EcoSiteDelineation/blob/master/VegNMDS_scores.csv
  
   .
  
   Here is my code...
  
   veg.nmds.sc = read.csv(VegNMDS_scores.csv, header = T)
  
   nmds.fig = ggplot(data = veg.nmds.sc, aes(x = NMDS1, y = NMDS2))
   nmds.fig + geom_point(aes(color = VegType, shape = VegType, size =
 10))
  +
   scale_colour_manual(name = Vegetation Type,
   values = c(blue, magenta, gray50, red,
   cyan3,
  green4, gold)) +
   scale_shape_manual(name = Vegetation Type, values = c(15, 16, 17,
 18,
   15, 16, 17)) +
   theme_bw() +
   theme(panel.background = element_blank(), panel.grid.major =
   element_blank(),
 panel.grid.minor = element_blank(),
 legend.key = element_rect(color = white)
 )
  
   I have been messing around with
   theme(..., legend.key.size = unit(1, cm))
   but I keep getting the error could not find function unit. I'm not
 sure
   why, isn't unit supposed to be part of the legend.key argument?
 
  Try this workaround to what sounds like a bug:
 
  library(grid)
 
  # then repeat the call.
 
  --
 
  David Winsemius
  Alameda, CA, USA
 
 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

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


Re: [R] (no subject)

2013-11-19 Thread Pascal Oettli
Hello,

The value for 'start' is not correct. According to the help for
fitdistr, 'start' should contain the paramaters used by the random
function (?rchisq)

Hope this helps,
Pascal

On 20 November 2013 09:29, Jim Silverton jim.silver...@gmail.com wrote:
 I generated some random data using R and then trying to see if it came from
 the same distribution but the erros keep piling.  Can anyone help?



 y=rchisq(10,1)
 mean(y)
 var(y)
 library(MASS)
 fitdistr(y, chi-squared, start = list(4), method = Brent, lower=0.9,
 upper=3)


 --
 Thanks,
 Jim.

 [[alternative HTML version deleted]]

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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

2013-11-19 Thread Gary Dong
Dear R users,

I am a R beginner and I am having trouble in using If Else in R. Here is
an example:

## create a data frame

a-c(1,2,3,4)
b-c(2,0,5,0)
ab-data.frame(cbind(a,b))

##calculate c, which is the ratio between a and b

if(ab$b0) {
 ab$c-ab$a/ab$b
} else {
 ab$c-0
 }

here is the error I got:

Warning message:
In if (ab$b  0) { :
  the condition has length  1 and only the first element will be used.

Any help is appreciated!

Gary

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

2013-11-19 Thread Nick Matzke
Hi,

This would be an issue with if() as well as if/else.  ab$b has 4
numbers in it, so ab$b  0 evaluates to TRUE TRUE FALSE TRUE or
whatever. if() can only take a single true or false. Cheers! Nick

On Tue, Nov 19, 2013 at 8:30 PM, Gary Dong pdxgary...@gmail.com wrote:
 Dear R users,

 I am a R beginner and I am having trouble in using If Else in R. Here is
 an example:

 ## create a data frame

 a-c(1,2,3,4)
 b-c(2,0,5,0)
 ab-data.frame(cbind(a,b))

 ##calculate c, which is the ratio between a and b

 if(ab$b0) {
  ab$c-ab$a/ab$b
 } else {
  ab$c-0
  }

 here is the error I got:

 Warning message:
 In if (ab$b  0) { :
   the condition has length  1 and only the first element will be used.

 Any help is appreciated!

 Gary

 [[alternative HTML version deleted]]

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

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


Re: [R] if else in R

2013-11-19 Thread Ben Tupper
Hi,

On Nov 19, 2013, at 9:41 PM, Nick Matzke mat...@berkeley.edu wrote:

 Hi,
 
 This would be an issue with if() as well as if/else.  ab$b has 4
 numbers in it, so ab$b  0 evaluates to TRUE TRUE FALSE TRUE or
 whatever. if() can only take a single true or false. Cheers! Nick
 

As a follow up, you could make a logical index for the condition as Nick 
suggests.

a-c(1,2,3,4)
b-c(2,0,5,0)
ab-data.frame(a,b)
ix - ab[,'b']  0
ix
# [1]  TRUE FALSE  TRUE FALSE

ab[ix,'c'] - ab[ix,'a']/ab[ix,'b']
ab[!ix,'c'] - 0
ab
#  a b   c
# 1 1 2 0.5
# 2 2 0 0.0
# 3 3 5 0.6
# 4 4 0 0.0

I'm not a big fan of the ab$b form of subsetting, I find ab[,'b'] more readable 
for my fading eyesight.  But you could do it your way, too.

ab$c[ix] - ab$a[ix]/ab$b[ix]

Cheers,
Ben


 On Tue, Nov 19, 2013 at 8:30 PM, Gary Dong pdxgary...@gmail.com wrote:
 Dear R users,
 
 I am a R beginner and I am having trouble in using If Else in R. Here is
 an example:
 
 ## create a data frame
 
 a-c(1,2,3,4)
 b-c(2,0,5,0)
 ab-data.frame(cbind(a,b))
 
 ##calculate c, which is the ratio between a and b
 
 if(ab$b0) {
 ab$c-ab$a/ab$b
 } else {
 ab$c-0
 }
 
 here is the error I got:
 
 Warning message:
 In if (ab$b  0) { :
  the condition has length  1 and only the first element will be used.
 
 Any help is appreciated!
 
 Gary
 
[[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.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

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


Re: [R] if else in R

2013-11-19 Thread arun
Hi,
Try:
within(ab, {c - ifelse(b0, a/b,0)})
A.K.




On Tuesday, November 19, 2013 8:51 PM, Gary Dong pdxgary...@gmail.com wrote:
Dear R users,

I am a R beginner and I am having trouble in using If Else in R. Here is
an example:

## create a data frame

a-c(1,2,3,4)
b-c(2,0,5,0)
ab-data.frame(cbind(a,b))

##calculate c, which is the ratio between a and b

if(ab$b0) {
ab$c-ab$a/ab$b
} else {
ab$c-0
}

here is the error I got:

Warning message:
In if (ab$b  0) { :
  the condition has length  1 and only the first element will be used.

Any help is appreciated!

Gary

    [[alternative HTML version deleted]]

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


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


Re: [R] if else in R

2013-11-19 Thread Jeff Newmiller
Which means you should use the ifelse function...

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

Nick Matzke mat...@berkeley.edu wrote:
Hi,

This would be an issue with if() as well as if/else.  ab$b has 4
numbers in it, so ab$b  0 evaluates to TRUE TRUE FALSE TRUE or
whatever. if() can only take a single true or false. Cheers! Nick

On Tue, Nov 19, 2013 at 8:30 PM, Gary Dong pdxgary...@gmail.com
wrote:
 Dear R users,

 I am a R beginner and I am having trouble in using If Else in R.
Here is
 an example:

 ## create a data frame

 a-c(1,2,3,4)
 b-c(2,0,5,0)
 ab-data.frame(cbind(a,b))

 ##calculate c, which is the ratio between a and b

 if(ab$b0) {
  ab$c-ab$a/ab$b
 } else {
  ab$c-0
  }

 here is the error I got:

 Warning message:
 In if (ab$b  0) { :
   the condition has length  1 and only the first element will be
used.

 Any help is appreciated!

 Gary

 [[alternative HTML version deleted]]

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

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

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


[R] If commands in a while loop

2013-11-19 Thread Hlebtomane
Unfortunately, the while loop in the following code doesn't seem to work. It
would be very nice
if someone might help me, thanks in advance:

 z = 0*c(1:1000)

  while (sum(z)  751){
  for(mu in (900:1100)/1){
  for(i in(1:1000)) {
z[i] - V5[i]*exp(5*mu)

if (z[i] = 1276281) {z[i] - 1}
else{z[i] - 0} 
}
}
   }




--
View this message in context: 
http://r.789695.n4.nabble.com/If-commands-in-a-while-loop-tp4680775.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R- package for Parametric Survival Analysis with Left-censored data

2013-11-19 Thread Vinod Mishra
Dear All,

I am new to R. Can someone please direct me to an R package using which I can 
estimate a Parametric Survival Analysis model with Left-censored (delayed 
entry) data in it. 

I recently received reviewers comment on my submitted article, where the 
reviewer suggested that only R has capabilities of estimating above mentioned 
survival model. However, I am not able to figure which specific package in R, 
the reviewer was referring to. 

Any pointer would be greatly appreciated !!

cheers,

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


Re: [R] if else in R

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 5:30 PM, Gary Dong wrote:

 Dear R users,
 
 I am a R beginner and I am having trouble in using If Else in R. Here is
 an example:
 
 ## create a data frame
 
 a-c(1,2,3,4)
 b-c(2,0,5,0)
 ab-data.frame(cbind(a,b))
 
 ##calculate c, which is the ratio between a and b
 
 if(ab$b0) {
 ab$c-ab$a/ab$b
 } else {
 ab$c-0
 }
 
 here is the error I got:

Consider this alternative:

 ab$c - (ab  0 ) * ab$a/ab$b

Although in general, you will probably use `ifelse`.

?ifelse   # different than ?if

-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] If commands in a while loop

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 5:22 PM, Hlebtomane wrote:

 Unfortunately, the while loop in the following code doesn't seem to work. It
 would be very nice
 if someone might help me, thanks in advance:
 
 z = 0*c(1:1000)

I think it is more likely that you don't know what z looks like. Try `head(z)`


 
  while (sum(z)  751){
  for(mu in (900:1100)/1){
  for(i in(1:1000)) {
   z[i] - V5[i]*exp(5*mu)
   
   if (z[i] = 1276281) {z[i] - 1}
   else{z[i] - 0} 
   }
   }
  }
-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] R- package for Parametric Survival Analysis with Left-censored data

2013-11-19 Thread David Winsemius

On Nov 19, 2013, at 5:30 PM, Vinod Mishra wrote:

 Dear All,
 
 I am new to R. Can someone please direct me to an R package using which I can 
 estimate a Parametric Survival Analysis model with Left-censored (delayed 
 entry) data in it. 
 
 I recently received reviewers comment on my submitted article, where the 
 reviewer suggested that only R has capabilities of estimating above mentioned 
 survival model. However, I am not able to figure which specific package in R, 
 the reviewer was referring to. 

Look at:

?Surv 

... after loading the survival package. (I do think you would be advised to 
seek statistical consultation.)

-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] Datatable manipulation

2013-11-19 Thread arun
Hi,
Try:
dat1 - read.table(text=a b c
x 1 4 7
y 2 5 8
z 3 6 9,header=TRUE)
dat2 - dat1
#either
library(reshape2)
res1 - 
within(melt(dat1,id.var=ID),cell-as.character(interaction(variable,ID,sep=_)))[,c(4,3)]

#or
indx - which(dat20,arr.ind=TRUE) 
res2 - 
data.frame(cell=paste(colnames(dat2)[indx[,2]],rownames(dat2)[indx[,1]],sep=_),value=dat2[indx],stringsAsFactors=FALSE)
 identical(res1,res2)
#[1] TRUE

A.K.



On Tuesday, November 19, 2013 11:07 PM, Nitisha jha nitisha...@gmail.com 
wrote:

Hi
could you please let me know the solution?
Thanks




On Wed, Nov 20, 2013 at 4:13 AM, smartpink...@yahoo.com wrote:

Hi,
If this is a data.frame(), then I have some solution for this problem.  Also, 
you need to post it in R-help if that is the case.
Thanks.
A.K.
quote author='nuts'
Sample input dataset where a,b,c are col names. x y z are row names.
        a       b       c
x       1       4       7
y       2       5       8
z       3       6       9

I want output to be like this after manipulating the dataset.
cell    value
a_x     1
a_y     2
a_z     3
b_x     4
b_y     5
b_z     6
c_x     7
c_y     8
c_z     9
where cell and value are the colnames.
How do I achieve this? I am at a loss here.


/quote
Quoted from:
http://r.789695.n4.nabble.com/Datatable-manipulation-tp4680747.html


_
Sent from http://r.789695.n4.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] Optim function Hessian matrix

2013-11-19 Thread David Winsemius
This is the code that was attached. I arrived in the copy sent to my email 
address:

#--

L1=function(X){
B1=X[1]
C1=X[2]
B2=X[3]
C2=X[4]
mu=X[5]

S=-(B1*(C1^x)*((C1^v)-1)/log(C1))
  +(d2*log(B1*(C1^(x+v
  -(B2*(C2^y)*((C2^v)-1)/log(C2))
  +(d1*log(B2*(C2^(y+v
  -(v*mu)
  +(d3*log(mu))

return(sum(S))
}

L2=function(X){
B3=X[1]
C3=X[2]
sum(-(B3*(C3^(x+u1)-C3^(x))) + h1*log(B3*C3^(x+u1)))
}

L3=function(X){
B4=X[1]
C4=X[2]
sum(-(B4*(C4^(y+u2)-C4^(y))) + h2*log(B4*C4^(y+u2)))
}


L=function(X){
B1=X[1]
C1=X[2]
B2=X[3]
C2=X[4]
mu=X[5]
B3=X[6]
C3=X[7]
B4=X[8]
C4=X[9]


L=L1(c(B1,C1,B2,C2,mu))
 +L2(c(B3,C3))
 +L3(c(B4,C4))
-L
}


Sol=nlminb(c(7.741*10^(-7),1.155,2.422*10^(-5),1.0889,.001307,2.51*10^(-5),1.0712,3.7654*10^(-4),1.0561),L,
lower=c(7.000*10^(-7),1.055,2.122*10^(-5),1.0689,.001107,2.13*10^(-5),1.0088,3.5437*10^(-4),1.0612),
upper=c(1.0299*10^(-6),1.214,2.822*10^(-5),1.0989,.015407,2.77*10^(-5),1.1888,3.8737*10^(-4),1.0812),control=list(iter.max=1500))

par=Sol$par

optim(par,L,method=L-BFGS-B,
lower=c(7.000*10^(-7),1.055,2.122*10^(-5),1.0689,.001107,2.13*10^(-5),1.0088,3.5437*10^(-4),1.0612),
upper=c(1.0299*10^(-6),1.214,2.822*10^(-5),1.0989,.015407,2.77*10^(-5),1.0888,3.8737*10^(-4),1.0712),control=list(maxit=1500,pgtol=10^(-7)),hessian=TRUE)


-- 
David.


On Nov 19, 2013, at 12:09 PM, sofeira taajobian wrote:

 Dear  R Users
 Hi,
 
 
 I have very emergency problems in my programming about  finding  MLE
 with optim command. I reproduced it  with real data. I guess that my
 function object in optim is very sensitive because it has power
 function .
 Then optim give me lower or initial values for estimates with these
 warnings for Hessian matrix computation:
 1: In log(B2 * (C2^(y + v))) : NaNs produced
 2: In log(B3 * C3^(x + u1)) : NaNs produced
 3: In log(B4 * C4^(y + u2)) : NaNs produced
 4: In log(B1 * (C1^(x + v))) : NaNs produced
 But I have  in result a hessian matrix with only first (2*2) block and
 other values are zero.
 It would not be the problem of code lead to this.  plz check the code
 and data, I attach them with this email. hope it can reduce some
 workload as copying and pasting.
 
 
 what may lead to this and any possible way to solve it? any suggestion
 are  appreciated. Plz help me as soon as possible because I don’t have
 enough time.
 data4.txt__
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] R- package for Parametric Survival Analysis with Left-censored data

2013-11-19 Thread peter dalgaard

On 20 Nov 2013, at 04:15 , David Winsemius dwinsem...@comcast.net wrote:

 
 On Nov 19, 2013, at 5:30 PM, Vinod Mishra wrote:
 
 Dear All,
 
 I am new to R. Can someone please direct me to an R package using which I 
 can estimate a Parametric Survival Analysis model with Left-censored 
 (delayed entry) data in it. 
 
 I recently received reviewers comment on my submitted article, where the 
 reviewer suggested that only R has capabilities of estimating above 
 mentioned survival model. However, I am not able to figure which specific 
 package in R, the reviewer was referring to. 
 
 Look at:
 
 ?Surv 
 
 ... after loading the survival package. (I do think you would be advised to 
 seek statistical consultation.)
 

In particular, notice the difference between left censoring (some patients are 
known to have died at an unknown time before t0) and left truncation (we only 
know survival times for patients alive at t0). Delayed entry is the latter.

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

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


[R] save table to txt file in a printable form

2013-11-19 Thread Alaios
Hi there,
I would like to save tabular (in R just matrices) in a txt file but in a way 
that they would be somehow readable.
That means keeping columns aligned and rows so one can read easily for example 
the 2,3 element.

IS there a way to do that in R?
capture.output for example does not produce tables in the way I want to have 
those.

Regards
Alex
[[alternative HTML version deleted]]

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


Re: [R] save table to txt file in a printable form

2013-11-19 Thread Enrico Schumann
On Wed, 20 Nov 2013, Alaios ala...@yahoo.com writes:

 Hi there,
 I would like to save tabular (in R just matrices) in a txt file but in a way 
 that they would be somehow readable.
 That means keeping columns aligned and rows so one can read easily for 
 example the 2,3 element.

 IS there a way to do that in R?
 capture.output for example does not produce tables in the way I want to have 
 those.

Please provide an example that shows what you want to achieve, and why
capture.output does not work.

  A - rnorm(12)
  dim(A) - c(4,3)
  colnames(A) - LETTERS[1:3]
  A

  #  A  B  C
  # [1,] 1.3883785  1.7264519 -0.1340838
  # [2,] 1.0601385 -0.2378076  0.2078081
  # [3,] 0.7278065 -0.1279776 -1.1674676
  # [4,] 1.3321629 -1.4082142  0.9145042

  capture.output(A)
  # [1]  A  B  C
  # [2] [1,] 1.3883785  1.7264519 -0.1340838
  # [3] [2,] 1.0601385 -0.2378076  0.2078081
  # [4] [3,] 0.7278065 -0.1279776 -1.1674676
  # [5] [4,] 1.3321629 -1.4082142  0.9145042

  # writeLines(capture.output(A), matrix.txt) ## or similar



 Regards
 Alex
   [[alternative HTML version deleted]]

Please send plain-text emails.


-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

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