Re: [R] ROCR package not installing

2012-11-22 Thread Mohammed Ouassou
try:
   install.packages(ROCR,dep=T)

M.O

On to., 2012-11-22 at 16:02 +1000, Philip Robinson wrote:
 I have tried installing the package (ROCR) with this command:
 
  
 
 Install.packages(ROCR)
 
  
 
 And with this command on the command line
 
  
 
 R CMD INSTALL ROCR_1.0-4.tar.gz
 
  
 
 But both times I get exactly the same error shown below, I don't understand
 what is wrong, is this an error in the package code?
 
  
 
 Thank you
 
 Philip
 
  
 
 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$ R CMD INSTALL
 ROCR_1.0-4.tar.gz
 
 * installing to library
 
 '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10'
 
 * installing *source* package 'ROCR' ...
 
 ** R
 
 ** data
 
 ** demo
 
 ** preparing package for lazy loading
 
 Loading required package: gtools
 
 Loading required package: gdata
 
 gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
 
  
 
 gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
 
  
 
 Attaching package: 'gdata'
 
  
 
 
 
   The following object(s) are masked from package:utils :
 
  
 
   object.size 
 
  
 
 Loading required package: caTools
 
 Loading required package: bitops
 
 Loading required package: grid
 
 Loading required package: KernSmooth
 
 KernSmooth 2.23 loaded
 
 Copyright M. P. Wand 1997-2009
 
  
 
 Attaching package: 'gplots'
 
  
 
 
 
   The following object(s) are masked from package:stats :
 
  
 
   lowess 
 
  
 
 Error in setMethod(plot, signature(x = performance, y = missing),  : 
 
   no existing definition for function plot
 
 Error : unable to load R code in package 'ROCR'
 
 ERROR: lazy loading failed for package 'ROCR'
 
 * removing '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10/ROCR'
 
 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$ 
 
  
 
 
 
 
 
 
 
 
   [[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] cluster analysis in R

2012-11-22 Thread Ingmar Visser
It's hard to answer these questions without knowing what the errors are and
how they can be reproduced.
Best, Ingmar

On Thu, Nov 22, 2012 at 1:03 AM, KitKat katherinewri...@trentu.ca wrote:

 Thanks, I have been trying that site and another one
 (http://www.statmethods.net/advstats/cluster.html)

 I don't know if I should be doing mclust or mcclust, but either way, the
 codes are not working. I am following the guidelines online at:
 mcclust - http://cran.r-project.org/web/packages/mcclust/mcclust.pdf
 mclust - http://cran.r-project.org/

 I am relatively new to R, but so far I have been able to figure out dfa,
 manova, pca... I cannot get these codes to work, I keep getting various
 errors. Are there other resources that have details about what codes to use
 or what to do when errors result? I have not found anything else helpful

 Thank you



 --
 View this message in context:
 http://r.789695.n4.nabble.com/cluster-analysis-in-R-tp4649635p4650397.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] ROCR package not installing

2012-11-22 Thread Philip Robinson
My version is:

Linux bioinform08 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC
2011 x86_64 GNU/Linux
Ubuntu 10.04.3 LTS

R version 2.10.1 (2009-12-14)

Philip

-Original Message-
From: Pascal Oettli [mailto:kri...@ymail.com] 
Sent: Thursday, 22 November 2012 4:20 PM
To: Philip Robinson
Cc: r-help@r-project.org
Subject: Re: [R] ROCR package not installing

Hello,

What is the version of R you use ?

Regards,
Pascal


Le 22/11/2012 15:02, Philip Robinson a écrit :
 I have tried installing the package (ROCR) with this command:



 Install.packages(ROCR)



 And with this command on the command line



 R CMD INSTALL ROCR_1.0-4.tar.gz



 But both times I get exactly the same error shown below, I don't 
 understand what is wrong, is this an error in the package code?



 Thank you

 Philip



 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$ R CMD 
 INSTALL ROCR_1.0-4.tar.gz

 * installing to library

 '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10'

 * installing *source* package 'ROCR' ...

 ** R

 ** data

 ** demo

 ** preparing package for lazy loading

 Loading required package: gtools

 Loading required package: gdata

 gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.



 gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.



 Attaching package: 'gdata'





The following object(s) are masked from package:utils :



object.size



 Loading required package: caTools

 Loading required package: bitops

 Loading required package: grid

 Loading required package: KernSmooth

 KernSmooth 2.23 loaded

 Copyright M. P. Wand 1997-2009



 Attaching package: 'gplots'





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



lowess



 Error in setMethod(plot, signature(x = performance, y = missing),  :

no existing definition for function plot

 Error : unable to load R code in package 'ROCR'

 ERROR: lazy loading failed for package 'ROCR'

 * removing '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10/ROCR'

 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$










   [[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] ROCR package not installing

2012-11-22 Thread Philip Robinson
Hi Mohammed,

This didn't work either:

Error in setMethod(plot, signature(x = performance, y = missing),  :
  no existing definition for function plot
Error : unable to load R code in package 'ROCR'
ERROR: lazy loading failed for package ‘ROCR’
* removing ‘/home/probinson/R/x86_64-pc-linux-gnu-library/2.10/ROCR’

The downloaded packages are in
‘/tmp/Rtmpn1DjHt/downloaded_packages’
Warning message:
In install.packages(ROCR, dep = T) :
  installation of package 'ROCR' had non-zero exit status

thanks
Philip

-Original Message-
From: Mohammed Ouassou [mailto:mohammed.ouas...@statkart.no] 
Sent: Thursday, 22 November 2012 6:02 PM
To: Philip Robinson
Cc: r-help@r-project.org
Subject: Re: [R] ROCR package not installing

try:
   install.packages(ROCR,dep=T)

M.O

On to., 2012-11-22 at 16:02 +1000, Philip Robinson wrote:
 I have tried installing the package (ROCR) with this command:
 
  
 
 Install.packages(ROCR)
 
  
 
 And with this command on the command line
 
  
 
 R CMD INSTALL ROCR_1.0-4.tar.gz
 
  
 
 But both times I get exactly the same error shown below, I don't 
 understand what is wrong, is this an error in the package code?
 
  
 
 Thank you
 
 Philip
 
  
 
 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$ R CMD 
 INSTALL ROCR_1.0-4.tar.gz
 
 * installing to library
 
 '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10'
 
 * installing *source* package 'ROCR' ...
 
 ** R
 
 ** data
 
 ** demo
 
 ** preparing package for lazy loading
 
 Loading required package: gtools
 
 Loading required package: gdata
 
 gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
 
  
 
 gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
 
  
 
 Attaching package: 'gdata'
 
  
 
 
 
   The following object(s) are masked from package:utils :
 
  
 
   object.size
 
  
 
 Loading required package: caTools
 
 Loading required package: bitops
 
 Loading required package: grid
 
 Loading required package: KernSmooth
 
 KernSmooth 2.23 loaded
 
 Copyright M. P. Wand 1997-2009
 
  
 
 Attaching package: 'gplots'
 
  
 
 
 
   The following object(s) are masked from package:stats :
 
  
 
   lowess
 
  
 
 Error in setMethod(plot, signature(x = performance, y = missing),  : 
 
   no existing definition for function plot
 
 Error : unable to load R code in package 'ROCR'
 
 ERROR: lazy loading failed for package 'ROCR'
 
 * removing '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10/ROCR'
 
 probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$
 
  
 
 
 
 
 
 
 
 
   [[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] ROCR package not installing

2012-11-22 Thread Pascal Oettli
Very old version. Maybe you should try again after upgrading your 
version of R (current is 2.15.2).


Pascal


Le 22/11/2012 18:11, Philip Robinson a écrit :

My version is:

Linux bioinform08 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC
2011 x86_64 GNU/Linux
Ubuntu 10.04.3 LTS

R version 2.10.1 (2009-12-14)

Philip

-Original Message-
From: Pascal Oettli [mailto:kri...@ymail.com]
Sent: Thursday, 22 November 2012 4:20 PM
To: Philip Robinson
Cc: r-help@r-project.org
Subject: Re: [R] ROCR package not installing

Hello,

What is the version of R you use ?

Regards,
Pascal


Le 22/11/2012 15:02, Philip Robinson a écrit :

I have tried installing the package (ROCR) with this command:



Install.packages(ROCR)



And with this command on the command line



R CMD INSTALL ROCR_1.0-4.tar.gz



But both times I get exactly the same error shown below, I don't
understand what is wrong, is this an error in the package code?



Thank you

Philip



probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$ R CMD
INSTALL ROCR_1.0-4.tar.gz

* installing to library

'/home/probinson/R/x86_64-pc-linux-gnu-library/2.10'

* installing *source* package 'ROCR' ...

** R

** data

** demo

** preparing package for lazy loading

Loading required package: gtools

Loading required package: gdata

gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.



gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.



Attaching package: 'gdata'





The following object(s) are masked from package:utils :



object.size



Loading required package: caTools

Loading required package: bitops

Loading required package: grid

Loading required package: KernSmooth

KernSmooth 2.23 loaded

Copyright M. P. Wand 1997-2009



Attaching package: 'gplots'





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



lowess



Error in setMethod(plot, signature(x = performance, y = missing),  :

no existing definition for function plot

Error : unable to load R code in package 'ROCR'

ERROR: lazy loading failed for package 'ROCR'

* removing '/home/probinson/R/x86_64-pc-linux-gnu-library/2.10/ROCR'

probinson@bioinform08:/tmp/RtmpO0rFbx/downloaded_packages$










[[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] error message in Linkcomm package

2012-11-22 Thread Nick Duncan
Dear All,

Some of the functions in Linkcomm return an error:
unused argument(s) (v = V(x$igraph))

Although I follow the guidance in the manual a number of the functions
return this error. The igraph vector is an edgelist.

Many thanks for any guidance.
Best,
Nick

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

2012-11-22 Thread Catarina Maia
Hello,



I am using the mda package and in particular the fda routine to
classify/predict in terms of color to a set of 20 samples for which i don´t
know the color.

I preformed a flexible discriminant analysis (FDA) using a set of 147
samples for which i know all the information.



My script and data follow in attachment.



 A total of 23 predictors were considered. 20 of the predictors are
numeric and 3 are discrete/categorical.



The resulting FDA rule was applied to the matrix and for the same
predictors in order to predict the color. However a consistent error is
occuring:



Error in mindist[l] - ndist[l] :

**NAs are not allowed in subscripted assignments



It is possible the problem being related with the 2 predictors that are
discrete/categorical variables?



There is already available some rotine to perform a discriminant analysis
considering continuous and discrete/categorical variables?



If someone can help, would be very grateful.



cheers,



Catarina
n   Codecolor   GROUP_N Licenca_N   type1_W type2_W type3_W type4_W 
type5_W type6_W type7_W type8_W type9_W type1_V type2_V type3_V type4_V type5_V 
type7_V type8_V type9_V type10_Vtype11_Vtotal
1   PRT0026940473   verde   A8  B7  0,558416119 0   
0   0   0,152231706 0,243598713 0   0   0,005176997 
0,483991231 0   0   0   0,375554726 0,092127884 0   
0   0   0,011391047 714,7
2   PRT0026940480   verde   A8  B7  0,431011386 0   
0   0   0,090087073 0,389819156 0   0   0   
0,27662459  0   0   0   0,329209955 0,254047865 0   
0   0   0   597,2
3   PRT0026940500   verde   A8  B7  0,349034749 0   
0,013127413 0   0,362162162 0,197297297 0   0   0   
0,166132511 0   0,005179074 0   0,647152728 0,095422917 
0   0   0   0   259
4   PRT0026940507   verde   A8  B7  0,38562904  0   
0   0   0,235952263 0,245400298 0   0   0   
0,195929366 0   0   0   0,561989935 0,149391253 0   
0   0   0   402,2
6   PRT0042540249   verde   A9  B7  0,160142349 0   
0   0,0113879   0   0,098932384 0   0   0   
0,071878686 0   0   0,017455771 0   0,127177759 0   
0   0   0   140,5
7   PRT0042540358   verde   A9  B7  0,258287293 0   
0   0   0,04558011  0,165745856 0   0   0   
0,308268994 0   0   0   0,147252993 0,073850285 0   
0   0   0   72,4
9   PRT0042540498   verde   A9  B7  0,535232384 0   
0   0   0,230384808 0,143428286 0   0   0   
0,220279346 0   0   0   0,50482587  0,113254862 
0,089373366 0   0   0   200,1
10  PRT0042540507   verde   A9  B7  0,631288766 0   
0   0,029634735 0,188146106 0   0   0   0   
0,187408732 0   0   0,033825063 0,637267173 0   0   
0   0   0   145,1
11  PRT0042540527   verde   A9  B7  0,775214835 0   
0   0,014925373 0,03256445  0,054726368 0   0   0   
0,610476668 0   0   0,031623122 0,225502758 0,110096002 
0   0   0   0   221,1
12  PRT0112140260   amarelo A7  B5  0   0   
0,009701493 0,664925373 0   0,017164179 0,042537313 
0,023880597 0   0   0   0,011007463 0,617276119 0   
0,004626866 0   0,120279851 0,012649254 0   134
13  PRT0112140305   azulA7  B5  0   0   0   
0   0   0   0,095049505 0   0   0   0   0   
0   0   0   0,080972426 0,567469139 0   0   101
14  PRT0112140366   azulA7  B5  0   0   
0,014857143 0,102857143 0,040,014857143 0,011428571 
0,217142857 0   0   0   0,005893035 0,125398294 
0,16692363  0,013019495 0   0,024394422 0,152328091 0   
87,5
15  PRT0112140373   azulA7  B5  0   0   
0,019488429 0,052375152 0   0,017052375 0,052375152 0   
0   0   0   0,020974032 0,041306002 0   0,007062684 
0   0,2152573   0   0   82,1
16  PRT0112140382   azulA7  B5  0   0,016591252 
0,009049774 0   0   0   0   0   0   0   
0,047221686 0,009984565 0   0   0   0   0   

Re: [R] Stepwise analysis with fixed variables

2012-11-22 Thread Einat
Thanks. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Stepwise-analysis-with-fixed-variables-tp4650015p4650419.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] problems with RPostgreSQL compilation

2012-11-22 Thread lanczos
Hello,

I am trying to install RPostgreSQL, but without success at the moment, getting 
an errormessage - see below. 
My OS is Fedora 17, R version 2.15.2, PostgreSQL 9.2.1 with Postgis 2.0.1 
spatial extension. 

Thank You for any help, advice or hint in advance.

Regards

Tomas


 install.packages(RPostgreSQL, dependencies=TRUE)
trying URL 'http://cran.fyxm.net/src/contrib/RPostgreSQL_0.3-3.tar.gz'
Content type 'application/x-gzip' length 474570 bytes (463 Kb)
opened URL
==
downloaded 463 Kb

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for pg_config... /usr/bin/pg_config
checking for /usr/include/libpq-fe.h... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-DBI.c -o RS-DBI.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-PQescape.c -o RS-PQescape.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-PostgreSQL.c -o RS-PostgreSQL.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-copy.c -o RS-pgsql-copy.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-getResult.c -o 
RS-pgsql-getResult.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-pqexec.c -o RS-pgsql-pqexec.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o RPostgreSQL.so RS-DBI.o 
RS-PQescape.o RS-PostgreSQL.o RS-pgsql-copy.o RS-pgsql-getResult.o 
RS-pgsql-pqexec.o -L/usr/lib -lpq
/usr/bin/ld: cannot find -lpq
collect2: error: ld returned 1 exit status
make: *** [RPostgreSQL.so] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/usr/local/lib64/R/library/RPostgreSQL’

The downloaded source packages are in
‘/tmp/Rtmpv5LkJj/downloaded_packages’
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages(RPostgreSQL, dependencies = TRUE) :
  installation of package ‘RPostgreSQL’ had non-zero exit status

--
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [lattice] Increase distance between tick labels and ticks in wireframe plot (pad)

2012-11-22 Thread Felix Schönbrodt
Hello,

I try to increase the distance between tick labels and ticks in a lattice 
wireframe plot. Here's a minimal example:

## Minimal example
x - y - z - c(1,2,3)
df - data.frame(x, y, z)
wireframe(z ~ x*y, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6))


I tried the axis.components option 
(http://r.789695.n4.nabble.com/Lattice-distance-of-tick-labels-from-axis-line-tp3693014p3693014.html).
 This works for xyplot, but *not* for wireframe:

xyplot(z ~ x, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6), par.settings=list(axis.components=list(left=list(pad1=2

wireframe(z ~ x*y, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6), par.settings=list(axis.components=list(left=list(pad1=2

Any ideas on how to pad the axis labels in wireframe plots?

Thanks,
Felix
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 read jpeg image with russian font in R?

2012-11-22 Thread Manish Gupta
Hi,

I m working on R and read one image with russian font using readjpeg()
function and write it on pdf (using grid). But russian text is not visible
on pdf. How can i fix my pblm?

Regards http://r.789695.n4.nabble.com/file/n4650417/pointer.jpg 
library(JPEG)
library(grid)
pdf(out.pdf , width = 6.6 ,height = 4.2,family= URWHelvetica, 
encoding=KOI8-R)
a-readJPEG(ArrowImage)# name of arrow 
grid.newpage()
pushViewport(viewport(width=0.9, height=0.9))
pushViewport(viewport(yscale=c(0,0), xscale=c(0,1), x=0, y=0, width=0.15,
height=1.0, just=c(left, bottom)))
grid.raster(a, y=unit(ypos.img, native))
popViewport()
popViewport()
dev.off()

Regards



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-read-jpeg-image-with-russian-font-in-R-tp4650417.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] Extracting random rows from a dataset

2012-11-22 Thread Madhu Ganganapalli
I found this code through internet and I have a one doubt about this example, 
which is
Here you take a 70% random sample considering all the values but what I want is 
if the selected sample contains p1,p2 then I want all records of p1,p2 and also 
remaining data in some other data frame...like following output

D1

V1  v2
P1  10
P1  3
P1  4
P1  2
P2  30
P2  40

D2

V1  v2
P3  4
P3  1

I hope you understood my doubt.please help me

Thanks,
Madhu.





 read.table(textConnection(gsub(\\(|\\), , var) ))  #from prior
posting
   V1 V2
1 p1 10
2 p1  3
3 p1  4
4 p2 20
5 p2 30
6 p2 40
7 p3  4
8 p3  1
9 p1  2

 ridxs - sample(1:nrow(df),floor(0.7*nrow(df)) )  # the 70% sample
row IDs

 df[ridxs,]
   V1 V2
5 p2 30
6 p2 40
2 p1  3
7 p3  4
4 p2 20
8 p3  1


 df[-ridxs,]
  V1 V2
1 p1 10
3 p1  4
9 p1  2


[[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] problems with RPostgreSQL compilation

2012-11-22 Thread Pascal Oettli

Hello,

Do you have the shared libraries required by PostgreSQL installed on 
your machine (libpq)?


Regards,
Pascal

Le 22/11/2012 18:45, lanc...@t-zones.sk a écrit :

Hello,

I am trying to install RPostgreSQL, but without success at the moment, getting 
an errormessage - see below.
My OS is Fedora 17, R version 2.15.2, PostgreSQL 9.2.1 with Postgis 2.0.1 
spatial extension.

Thank You for any help, advice or hint in advance.

Regards

Tomas



install.packages(RPostgreSQL, dependencies=TRUE)

trying URL 'http://cran.fyxm.net/src/contrib/RPostgreSQL_0.3-3.tar.gz'
Content type 'application/x-gzip' length 474570 bytes (463 Kb)
opened URL
==
downloaded 463 Kb

* installing *source* package ‘RPostgreSQL’ ...
** package ‘RPostgreSQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for pg_config... /usr/bin/pg_config
checking for /usr/include/libpq-fe.h... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-DBI.c -o RS-DBI.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-PQescape.c -o RS-PQescape.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-PostgreSQL.c -o RS-PostgreSQL.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-copy.c -o RS-pgsql-copy.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-getResult.c -o 
RS-pgsql-getResult.o
gcc -std=gnu99 -I/usr/local/lib64/R/include -DNDEBUG -I/usr/include 
-I/usr/local/include-fpic  -g -O2  -c RS-pgsql-pqexec.c -o RS-pgsql-pqexec.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o RPostgreSQL.so RS-DBI.o 
RS-PQescape.o RS-PostgreSQL.o RS-pgsql-copy.o RS-pgsql-getResult.o 
RS-pgsql-pqexec.o -L/usr/lib -lpq
/usr/bin/ld: cannot find -lpq
collect2: error: ld returned 1 exit status
make: *** [RPostgreSQL.so] Error 1
ERROR: compilation failed for package ‘RPostgreSQL’
* removing ‘/usr/local/lib64/R/library/RPostgreSQL’

The downloaded source packages are in
‘/tmp/Rtmpv5LkJj/downloaded_packages’
Updating HTML index of packages in '.Library'
Making packages.html  ... done
Warning message:
In install.packages(RPostgreSQL, dependencies = TRUE) :
   installation of package ‘RPostgreSQL’ had non-zero exit status

--



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

2012-11-22 Thread Jim Lemon

On 11/22/2012 05:15 AM, Rosario Scandurra wrote:

Hi,

I want to generate an histogram and plot on the y axis the percentage of a
categorical variable and on the x axis a nominal variable. I want to move
the origin to have 2 categories below 0. Hope somebody could help me.
Thanks.


Hi Rosario,
If you already have your percentages, the barplot function will display 
them like most people expect an histogram to look by setting space=0. 
See the names.arg argument to have the names of your nominal variables 
on the x axis. I'm not sure exactly what you mean by wanting 2 
categories below 0. If these are negative percentages, the barplot 
function will automatically handle them.


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] Help with loop

2012-11-22 Thread Rui Barradas

Hello,

I'm glad it helped.
You should have kept this in the list, the odds of getting more answers 
are bigger.


As for your problem with NAs, what do you want to do with them? Should 
they count as within range?


Rui Barradas
Em 22-11-2012 10:18, Helene Frigstad escreveu:

Hi,
yes, that is a very elegant solution. Thank you very much!
Do you have any suggestions on how to deal with NA in such a situation? For 
example, if I have one missing value in the dataset, then the function will 
only work until it reaches the NA, and then the rest will be NA as well.

head (D, 11)Salt   time310 35.63511 2004-07-17311 35.62334 
2004-07-18312 35.63498 2004-07-19313 35.64032 2004-07-20314   NA 
2004-07-21315 35.66930 2004-07-22316 35.65394 2004-07-23317 35.64702 
2004-07-24318 35.63810 2004-07-25319 35.63190 2004-07-26320 35.66033 2004-07-27
(change - cumsum(c(FALSE, abs(diff(D$Salt))  0.05))) [1]  0  0  0  0 NA NA NA 
NA NA NA NA
(split(D, change))$`0`Salt   time310 35.63511 2004-07-17311 
35.62334 2004-07-18312 35.63498 2004-07-19313 35.64032 2004-07-20

Many thanks, Helene



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


Re: [R] printing difftime summary

2012-11-22 Thread R. Michael Weylandt
On Thu, Nov 22, 2012 at 4:01 AM, Sam Steingold s...@gnu.org wrote:
 Hi,

 * arun fznegcvax...@lnubb.pbz [2012-11-21 14:04:36 -0800]:

 Are you looking for some other function (difftime2string)
 ot just remove the quotes from the printed output?

 I am wondering what others do when they want to see a summary of difftime.

 If it is the latter, then this should do it.
 res-do.call(data.frame,lapply(s,difftime2string))
  names(res)-names(s)
  res
 #   Min.   1st Qu.Median Mean  3rd Qu.  Max.
 #1 500.00 ms 17.12 min 99.48 min 8.30 hrs 8.05 hrs 6.98 days

 cool, thanks.
 I now think that what I want is
 --8---cut here---start-8---
 difftime.summary - function (v) {
   s - summary(as.numeric(v))
   r - as.data.frame(sapply(s,difftime2string),stringsAsFactors=FALSE)
   names(r) - c(string)
   r[[units(v)]] - s
   r
 }

Any reason not summary.difftime to get S3 dispatch?

MW

 difftime.summary(infl$delay)
string secs
 Min.500.00 ms  0.5
 1st Qu. 17.12 min   1027.0
 Median  99.48 min   5969.0
 Mean 8.30 hrs  29870.0
 3rd Qu.  8.05 hrs  28970.0
 Max.6.98 days 603100.0
 --8---cut here---end---8---


 --
 Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 
 11.0.11103000
 http://www.childpsy.net/ http://ffii.org http://jihadwatch.org 
 http://memri.org
 http://www.memritv.org http://camera.org http://mideasttruth.com
 A computer scientist is someone who fixes things that aren't broken.

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

2012-11-22 Thread Marc Girondot

Dear members,

I have a series of values in a vector and some value are missing and 
replaced with NA.

For example:
a - c(27, 25, NA, NA, 24, 26, 27, NA, 26)
I would like to replace the NAs with the value taken from the previous 
value that is non-NA. The output would be in this case:


27 25 25 25 24 26 27 27 26

Now I do that with a for loop, but I try to eliminate all the loops to 
gain in performance


I try this and it works but again I have a while and then I do not 
eliminate completely loop:


l - length(a)
while(any(is.na(a))) {a[2:l] - ifelse(is.na(a[2:l]), a[1:(l-1)], a[2:l])}

If someone have another solution, I will be most happy !

Sincerely

Marc Girondot

--
__
Marc Girondot, Pr

Laboratoire Ecologie, Systématique et Evolution
Equipe de Conservation des Populations et des Communautés
CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
Bâtiment 362
91405 Orsay Cedex, France

Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
e-mail: marc.giron...@u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot

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


Re: [R] Trick to replace NA

2012-11-22 Thread R. Michael Weylandt
Take a look at

na.locf()

in the zoo package. (LOCF = last observation carried forward)

RMW

On Thu, Nov 22, 2012 at 12:56 PM, Marc Girondot marc_...@yahoo.fr wrote:
 Dear members,

 I have a series of values in a vector and some value are missing and
 replaced with NA.
 For example:
 a - c(27, 25, NA, NA, 24, 26, 27, NA, 26)
 I would like to replace the NAs with the value taken from the previous value
 that is non-NA. The output would be in this case:

 27 25 25 25 24 26 27 27 26

 Now I do that with a for loop, but I try to eliminate all the loops to gain
 in performance

 I try this and it works but again I have a while and then I do not eliminate
 completely loop:

 l - length(a)
 while(any(is.na(a))) {a[2:l] - ifelse(is.na(a[2:l]), a[1:(l-1)], a[2:l])}

 If someone have another solution, I will be most happy !

 Sincerely

 Marc Girondot

 --
 __
 Marc Girondot, Pr

 Laboratoire Ecologie, Systématique et Evolution
 Equipe de Conservation des Populations et des Communautés
 CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
 Bâtiment 362
 91405 Orsay Cedex, France

 Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
 e-mail: marc.giron...@u-psud.fr
 Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
 Skype: girondot

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

2012-11-22 Thread Jorge I Velez
Dear Marc,

Try

require(zoo)
na.locf(a)

HTH,
Jorge.-


On Thu, Nov 22, 2012 at 11:56 PM, Marc Girondot  wrote:

 Dear members,

 I have a series of values in a vector and some value are missing and
 replaced with NA.
 For example:
 a - c(27, 25, NA, NA, 24, 26, 27, NA, 26)
 I would like to replace the NAs with the value taken from the previous
 value that is non-NA. The output would be in this case:

 27 25 25 25 24 26 27 27 26

 Now I do that with a for loop, but I try to eliminate all the loops to
 gain in performance

 I try this and it works but again I have a while and then I do not
 eliminate completely loop:

 l - length(a)
 while(any(is.na(a))) {a[2:l] - ifelse(is.na(a[2:l]), a[1:(l-1)], a[2:l])}

 If someone have another solution, I will be most happy !

 Sincerely

 Marc Girondot

 --
 __**
 Marc Girondot, Pr

 Laboratoire Ecologie, Systématique et Evolution
 Equipe de Conservation des Populations et des Communautés
 CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079
 Bâtiment 362
 91405 Orsay Cedex, France

 Tel:  33 1 (0)1.69.15.72.30   Fax: 33 1 (0)1.69.15.73.53
 e-mail: marc.giron...@u-psud.fr
 Web: 
 http://www.ese.u-psud.fr/epc/**conservation/Marc.htmlhttp://www.ese.u-psud.fr/epc/conservation/Marc.html
 Skype: girondot

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


[[alternative HTML version deleted]]

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


Re: [R] Help with loop

2012-11-22 Thread Hefri
Hi again,

I was thinking that the interval would stop when there was a NA, ignore
subsequent NAs and only start a new interval when there was a new value. So
in the example below, the interval would stop at row 320, and a new interval
started at row 334.

 head (D, 20)
Salt   time
319 35.63190 2004-07-26
320 35.66033 2004-07-27
321   NA 2004-07-28
322   NA 2004-07-29
323   NA 2004-07-30
324   NA 2004-07-31
325   NA 2004-08-01
326   NA 2004-08-02
327   NA 2004-08-03
328   NA 2004-08-04
329   NA 2004-08-05
330   NA 2004-08-06
331   NA 2004-08-07
332   NA 2004-08-08
333   NA 2004-08-09
334 35.57781 2004-08-10
335 35.59829 2004-08-11

Many thanks, Helene



--
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-loop-tp4650313p4650432.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] lapack routines cannot be loaded [Help request]

2012-11-22 Thread Manca Marco (PATH)

Dear BioConductor and R fellow users

I apologize in advance for double posting, but I am not sure which list would 
actually be best fit for this message.


I am experiencing a weird error with my R installation on Ubuntu 10.04.4 (LTS) 
64bit: 

When I run R on the terminal everything goes smoothly:

$R
R version 2.15.2 (2012-10-26) -- Trick or Treat
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


However, as soon as I try to use limma (or WGCNA... I haven't tried other 
packages yet) the following mistake pops up ( lapack routines cannot be loaded )

library(limma)

 fit - lmFit(Data.rma, design)
Error in chol2inv(fit$qr$qr, size = fit$qr$rank) : 
  lapack routines cannot be loaded
In addition: Warning message:
In chol2inv(fit$qr$qr, size = fit$qr$rank) :
  unable to load shared object '/usr/lib64/R/modules//lapack.so':
  /usr/lib64/R/modules//lapack.so: undefined symbol: dpstrf_
 

It is independent of the dataset I am using.

I have already tried to recompile the whole BioConductor set of packages, and 
updated the general packages via CRAN, but nothing changed.

Following I am attaching my sessionInfo(), and you will find enclosed to this 
email the (incriminated) lapack.so file, should you be willing/able to take a 
look at it.

Any insights into what could be going on, and how to address the issue?

 sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C 
 [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
 [5] LC_MONETARY=en_US.utf8LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=CLC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C   
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C  

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

other attached packages:
[1] limma_3.12.3  hgu133plus2cdf_2.10.0 AnnotationDbi_1.18.4 
[4] affy_1.34.0   Biobase_2.16.0BiocGenerics_0.2.0   

loaded via a namespace (and not attached):
[1] affyio_1.24.0 BiocInstaller_1.4.9   DBI_0.2-5
[4] IRanges_1.14.4preprocessCore_1.18.0 RSQLite_0.11.2   
[7] stats4_2.15.2 tools_2.15.2  zlibbioc_1.2.0  



Thank you in advance,
Marco


--
Dr Marco Manca
University of Maastricht
Faculty of Health, Medicine and Life Sciences (FHML)
Cardiovascular Research Institute (CARIM)

Mailing address: PO Box 616, 6200 MD Maastricht (The Netherlands)
Visiting address: UNS40 West building - 5th floor Room5.544, Universiteit 
Singel 40, 6229  HX Maastricht

E-mail: m.ma...@maastrichtuniversity.nl
Office telephone: +31(0)433884289
Personal mobile: +31(0)626441205
Twitter: @markomanka


*

This email and any files transmitted with it are confidential and solely for 
the use of the intended recipient.

It may contain material protected by privacy or 
doctor-patient/consultant-client privilege. If you are not the intended 
recipient or the person responsible for

delivering to the intended recipient, be advised that you have received this 
email in error and that any use is STRICTLY PROHIBITED.

If you have received this email in error please notify us by telephone on 
+31626441205 Dr Marco MANCA

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

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hello,

I would appreciate if someone could help me resolve the following:

1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

2. Is these message harmful?  The following object(s) are masked from 'df1 
(position 3)':
X1, X2, X3, X4, X5

Thanks,

Pradip Muhuri


#Reproducible Example
set.seed(5)
df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
attach (df1)
#delete rows if any of them NA for X1
df1[!is.na( X1),][,1:5] # This works

#delete rows if any of them NA for X1, X2, X3, X4 or X5
df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

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


Re: [R] rapache memory problem

2012-11-22 Thread Gergely Daróczi
Hello mrzung,

it depends on several factors.

First of all: do your clients use RApache for computations in separate
sessions (possible which computations does not build on the previous ones)
or do they need a stateful application?

The first would be pretty easy to resolve, just clean the R environment at
the end your R scripts (which is a must in long running R sessions anyway).
If the users have direct access to R console (or some similar dynamic
solution and the app needs previous environments despite the fact that
Apache works with children), then e.g. clean the session when they log out.

I think opencpu http://opencpu.org/ would handle all this, and with
Apparmor (or with another great tool of Jeroen to set the limits
dynamically from R: RAppArmor https://github.com/jeroenooms/RAppArmor)
you can force (R)Apache not take more then given amount of RAM, and kill
the process. Well, not always when the users would want that :)

Best,
Gergely


On Thu, Nov 22, 2012 at 5:56 AM, mrzung mrzun...@gmail.com wrote:

 Hi all;
 Now I'm developing web application by using rapache in ubuntu.
 My problem is that as users execute the application, the server PC
 cumulates
 memory.
 After users close or refresh the application page, the server PC memory is
 still cumulated.
 Now I'm renewing apache machine by manually in terminal.

 Is there any way to kill memory when users refresh or close the application
 page?

 Thanks,




 --
 View this message in context:
 http://r.789695.n4.nabble.com/rapache-memory-problem-tp4650412.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] Data Extraction

2012-11-22 Thread Sarah Goslee
Hi,

is.na( X1 | X2 | X3 | X4 | X5)
isn't a valid construct.

You'd need
!(is.na(X1) | is.na(X2) etc )

Or more elegantly
df1[apply(df1, 1, function(x)all(!is.na(x))), ]

Sarah

On Thursday, November 22, 2012, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hello,

 I would appreciate if someone could help me resolve the following:

 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

 2. Is these message harmful?  The following object(s) are masked from 'df1
 (position 3)':
 X1, X2, X3, X4, X5

 Thanks,

 Pradip Muhuri


 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.na( X1),][,1:5] # This works

 #delete rows if any of them NA for X1, X2, X3, X4 or X5
 df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

 __
 R-help@r-project.org javascript:; mailing list
 https://stat.ethz.ch/mailman/listinfo/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.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] Data Extraction

2012-11-22 Thread PIKAL Petr
Hi

do you want this?

 df1[complete.cases(df1),]
   X1 X2 X3 X4 X5
2   8  8  3  2 10
6   8  6  7 10  1
11  4  5  5 10  8
12  6  1  7  8  4
17  5  7  3  1  3
18 10  7  3  8  7
19  7  5  3  5  6
20 10  5  2  4  6

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Muhuri, Pradip (SAMHSA/CBHSQ)
 Sent: Thursday, November 22, 2012 3:11 PM
 To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org
 Subject: [R] Data Extraction
 
 Hello,
 
 I would appreciate if someone could help me resolve the following:
 
 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work
 
 2. Is these message harmful?  The following object(s) are masked from
 'df1 (position 3)':
 X1, X2, X3, X4, X5
 
 Thanks,
 
 Pradip Muhuri
 
 
 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.na( X1),][,1:5] # This works
 
 #delete rows if any of them NA for X1, X2, X3, X4 or X5 df1[!is.na( X1
 | X2 | X3 | X4 | X5),][,1:5] # This does not work
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] ggplot2 and the legend

2012-11-22 Thread Peter Kupfer
Dear all,
i try to plot with ggplot2. Therefor I have an matrix with 3 colums. With cbind 
I add an additional column called col. I need this column col because in a 
later step and want to specify here some plot details which I will get from 
another analysis
If I want to plot with this code, I have the problem that the legend is wrong. 
Blue changed to green and green to blue. Furthermore the colors in the plot 
seem a little bit strange. Can anybody help me out?
All the best and thanks
Peter



#THE CODE


p0 - ggplot(DATA, aes(Freq, Var1))
p1 - p0+ geom_point(aes(Freq, reorder(Var1, rep(score,cl.count)), colour=col)) 
 
p2  - p1 +geom_segment(aes(x = 0, xend = Freq, y = Var1, yend = Var1, 
colour=col))
p3 - p2 + facet_grid(.~Var2)
plot(p3)



 THE DATA #

#class(DATA) = data.frame
#class(DATA$Var1) = class(DATA$Var2) =  factor

#class(DATA$Freq) = numeric
#class(DATA$col) = character

Var1Var2Freqcol 
1   208869_s_at JT  10.6802376685463blue
2   203394_s_at JT  10.0160470327077blue
3   201533_at   JT  9.58401500697783blue
4   216520_s_at JT  9.07764840614892blue
5   210999_s_at JT  9.00219110130877green
6   212284_x_at JT  8.62193952504277blue
7   203752_s_at JT  8.69193736253539green
8   203574_at   JT  8.41492571590263blue
9   219629_at   JT  8.19111292436667blue
10  201473_at   JT  8.035082989931  green
11  210592_s_at JT  8.00639829720742green
12  200768_s_at JT  7.88012483915651green
13  201565_s_at JT  7.89885432096935green
14  AFFX-r2-P1-cre-3_at JT  7.86490927895639blue
15  202014_at   JT  7.69345791769434green
16  212671_s_at JT  -7.43350555284605   green
17  203395_s_at JT  7.51127977823914blue
18  208980_s_at JT  7.52175408445448blue
19  207783_x_at JT  7.31954223019292blue
20  215446_s_at JT  -6.28236730203077   green
21  203034_s_at JT  7.24582647671987blue
22  211943_x_at JT  7.22247828112639green
23  203974_at   JT  -6.84217612309489   green
24  201810_s_at JT  7.0727443704914 green
25  201693_s_at JT  7.11350154823655blue
26  213614_x_at JT  7.07586402329325green
27  AFFX-CreX-5_at  JT  7.05274590106307blue
28  201798_s_at JT  -6.98858491240942   blue
29  212869_x_at JT  6.97833756793094green
30  201531_at   JT  6.96660504363297green
31  201170_s_at JT  6.90904695259236green
32  200886_s_at JT  -6.92645789612039   blue
33  AFFX-r2-P1-cre-5_at JT  6.85399276205727blue
34  201429_s_at JT  6.68557384216737green
35  212665_at   JT  6.75579868986925green
36  208695_s_at JT  6.8087149011011 green
37  211654_x_at JT  -6.7426888322764green
38  209927_s_at JT  -6.74856557366229   green
39  203107_x_at JT  6.72120597236789blue
40  211296_x_at JT  6.60226581063165green
41  208869_s_at OA  -3.73983541027906   green
42  203394_s_at OA  -3.29203821581412   green
43  201533_at   OA  -3.2383756900468blue
44  216520_s_at OA  -4.59979375515969   blue
45  210999_s_at OA  -5.10853597491871   green
46  212284_x_at OA  -5.84925048581651   blue
47  203752_s_at OA  -4.54427623838229   blue
48  203574_at   OA  -2.59882534850623   blue
49  219629_at   OA  -4.35550869055387   blue
50  201473_at   OA  -3.15685663855675   blue
51  210592_s_at OA  -4.52611461089035   blue
52  200768_s_at OA  -2.76833454650619   blue
53  201565_s_at OA  -3.80972141262264   green
54  AFFX-r2-P1-cre-3_at OA  -3.53240421347696   green
55  202014_at   OA  -2.6078496058   blue
56  212671_s_at OA  1.68584117381632green
57  203395_s_at OA  -2.27910272551108   blue
58  208980_s_at OA  -3.66266591800146   green
59  207783_x_at OA  -3.93093352561262   blue
60  215446_s_at OA  6.26626194024723green
61  203034_s_at OA  -3.84606488854982   blue
62  211943_x_at OA  -3.30831181470312   green
63  203974_at   OA  1.17068337099947green
64  201810_s_at OA  -2.07855331860079   green
65  201693_s_at OA  -2.74740330465003   blue
66  213614_x_at OA  -3.0385167086   

Re: [R] error message in Linkcomm package

2012-11-22 Thread Jeff Newmiller
Your questions are all but unanswerable. Read the posting guide and

 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
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 Duncan nickd...@gmail.com wrote:

Dear All,

Some of the functions in Linkcomm return an error:
unused argument(s) (v = V(x$igraph))

Although I follow the guidance in the manual a number of the functions
return this error. The igraph vector is an edgelist.

Many thanks for any guidance.
Best,
Nick

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

2012-11-22 Thread Berend Hasselman

On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hello,
 
 I would appreciate if someone could help me resolve the following:
 
 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work
 
 2. Is these message harmful?  The following object(s) are masked from 'df1 
 (position 3)':
X1, X2, X3, X4, X5
 
 Thanks,
 
 Pradip Muhuri
 
 
 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.na( X1),][,1:5] # This works
 
 #delete rows if any of them NA for X1, X2, X3, X4 or X5
 df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

Yet another way of doing this is 

df1[!is.na(rowSums(df1)),][1:5]

But Petr's solution appears to be quickest.
See this:

 N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))  
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
 f2 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
 f3 - function(df) {df[complete.cases(df),][1:ncol(df)]}

 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
1 d1 - f1(df)   3.675   13.172  100
2 d2 - f2(df)   0.4011.437  100
3 d3 - f3(df)   0.2791.000  100

 identical(d1,d2)
[1] TRUE
 identical(d1,d3)
[1] TRUE


Berend

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


Re: [R] Data Extraction

2012-11-22 Thread Bert Gunter
Unnecessarily complicated. ?na.omit (linked from ?complete.cases)

df - na.omit(df)

-- Bert


On Thu, Nov 22, 2012 at 6:49 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

  Hello,
 
  I would appreciate if someone could help me resolve the following:
 
  1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work
 
  2. Is these message harmful?  The following object(s) are masked from
 'df1 (position 3)':
 X1, X2, X3, X4, X5
 
  Thanks,
 
  Pradip Muhuri
 
 
  #Reproducible Example
  set.seed(5)
  df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
  attach (df1)
  #delete rows if any of them NA for X1
  df1[!is.na( X1),][,1:5] # This works
 
  #delete rows if any of them NA for X1, X2, X3, X4 or X5
  df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

 Yet another way of doing this is

 df1[!is.na(rowSums(df1)),][1:5]

 But Petr's solution appears to be quickest.
 See this:

  N - 10
  set.seed(13)
  df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
  library(rbenchmark)
 
  f1 - function(df) {df[apply(df, 1, function(x)all(!is.na
 (x))),][,1:ncol(df)]}
  f2 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
  f3 - function(df) {df[complete.cases(df),][1:ncol(df)]}
 
  benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df),
 columns=c(test,elapsed, relative, replications))
   test elapsed relative replications
 1 d1 - f1(df)   3.675   13.172  100
 2 d2 - f2(df)   0.4011.437  100
 3 d3 - f3(df)   0.2791.000  100

  identical(d1,d2)
 [1] TRUE
  identical(d1,d3)
 [1] TRUE


 Berend

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




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

[[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] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Petr,

You have shown a solution that is the simplest.

Thanks and regards,

Pradip Muhuri
Beginner useR


From: PIKAL Petr [petr.pi...@precheza.cz]
Sent: Thursday, November 22, 2012 9:33 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org
Subject: RE: Data Extraction

Hi

do you want this?

 df1[complete.cases(df1),]
   X1 X2 X3 X4 X5
2   8  8  3  2 10
6   8  6  7 10  1
11  4  5  5 10  8
12  6  1  7  8  4
17  5  7  3  1  3
18 10  7  3  8  7
19  7  5  3  5  6
20 10  5  2  4  6

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Muhuri, Pradip (SAMHSA/CBHSQ)
 Sent: Thursday, November 22, 2012 3:11 PM
 To: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org
 Subject: [R] Data Extraction

 Hello,

 I would appreciate if someone could help me resolve the following:

 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

 2. Is these message harmful?  The following object(s) are masked from
 'df1 (position 3)':
 X1, X2, X3, X4, X5

 Thanks,

 Pradip Muhuri


 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.na( X1),][,1:5] # This works

 #delete rows if any of them NA for X1, X2, X3, X4 or X5 df1[!is.na( X1
 | X2 | X3 | X4 | X5),][,1:5] # This does not work

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

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Bert,

Your solution is similar to Petr's.

Thanks and regards,

Pradip Muhuri
BeginneR UseR


From: Bert Gunter [gunter.ber...@gene.com]
Sent: Thursday, November 22, 2012 10:20 AM
To: Berend Hasselman
Cc: Muhuri, Pradip (SAMHSA/CBHSQ); r-help@r-project.org
Subject: Re: [R] Data Extraction

Unnecessarily complicated. ?na.omit (linked from ?complete.cases)

df - na.omit(df)

-- Bert


On Thu, Nov 22, 2012 at 6:49 AM, Berend Hasselman 
b...@xs4all.nlmailto:b...@xs4all.nl wrote:

On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hello,

 I would appreciate if someone could help me resolve the following:

 1. df1[!is.nahttp://is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not 
 work

 2. Is these message harmful?  The following object(s) are masked from 'df1 
 (position 3)':
X1, X2, X3, X4, X5

 Thanks,

 Pradip Muhuri


 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.nahttp://is.na( X1),][,1:5] # This works

 #delete rows if any of them NA for X1, X2, X3, X4 or X5
 df1[!is.nahttp://is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

Yet another way of doing this is

df1[!is.nahttp://is.na(rowSums(df1)),][1:5]

But Petr's solution appears to be quickest.
See this:

 N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, 
 function(x)all(!is.nahttp://is.na(x))),][,1:ncol(df)]}
 f2 - function(df) {df[!is.nahttp://is.na(rowSums(df)),][1:ncol(df)]}
 f3 - function(df) {df[complete.cases(df),][1:ncol(df)]}

 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
1 d1 - f1(df)   3.675   13.172  100
2 d2 - f2(df)   0.4011.437  100
3 d3 - f3(df)   0.2791.000  100

 identical(d1,d2)
[1] TRUE
 identical(d1,d3)
[1] TRUE


Berend

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



--

Bert Gunter
Genentech Nonclinical Biostatistics

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

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


Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Berend,

You have compared all 3 ways.  ... very nicely evaluated. 

Thanks and regards,

Pradip Muhuri

Beginner UseR


From: Berend Hasselman [b...@xs4all.nl]
Sent: Thursday, November 22, 2012 9:49 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help@r-project.org
Subject: Re: [R] Data Extraction

On 22-11-2012, at 15:11, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hello,

 I would appreciate if someone could help me resolve the following:

 1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

 2. Is these message harmful?  The following object(s) are masked from 'df1 
 (position 3)':
X1, X2, X3, X4, X5

 Thanks,

 Pradip Muhuri


 #Reproducible Example
 set.seed(5)
 df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
 attach (df1)
 #delete rows if any of them NA for X1
 df1[!is.na( X1),][,1:5] # This works

 #delete rows if any of them NA for X1, X2, X3, X4 or X5
 df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

Yet another way of doing this is

df1[!is.na(rowSums(df1)),][1:5]

But Petr's solution appears to be quickest.
See this:

 N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
 f2 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
 f3 - function(df) {df[complete.cases(df),][1:ncol(df)]}

 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
1 d1 - f1(df)   3.675   13.172  100
2 d2 - f2(df)   0.4011.437  100
3 d3 - f3(df)   0.2791.000  100

 identical(d1,d2)
[1] TRUE
 identical(d1,d3)
[1] TRUE


Berend

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


Re: [R] selcting a random sample and saving it in a seprate dataframe and also remaining part in other data frame

2012-11-22 Thread arun
HI Madhu,

I guess you got your solution from Rui:
 dat1-data.frame(x=c(1,1,2,2,2,3,4,4,4),y=c(23,45,87,46,78,12,87,79,76))
s-sample(unique(dat1[,1]),length(unique(dat1[,1]))*0.8)
 s
#[1] 3 4 2
You can have a list containing both the dataframes
list1-list(dat1[dat1$x%in%s,],dat1[!dat1$x%in%s,])
list1
[[1]]
#  x  y
#3 2 87
#4 2 46
#5 2 78
#6 3 12
#7 4 87
#8 4 79
#9 4 76

#[[2]]
 # x  y
#1 1 23
#2 1 45

is.data.frame(list1[[1]])
#[1] TRUE

A.K.



- Original Message -
From: Madhu Ganganapalli mganganapa...@upstreamsoftware.com
To: arun smartpink...@yahoo.com
Cc: 
Sent: Thursday, November 22, 2012 2:53 AM
Subject: selcting a random sample and saving it in a seprate dataframe and also 
remaining part in other data frame

**
My question is:

I have the following data frame and my distinct values of variable x are 
1,2,3,4.

    data-data.frame(x=c(1,1,2,2,2,3,4,4,4),y=c(23,45,87,46,78,12,87,79));**

Here my data has 8 observations but I mentioned that distinct observations are 
4 so 80% data means I have to get a random sample from these 4 observations 
only,  in such a way that 
Suppose while selecting 80% random sample from x I got 1,2, and 3(80% means 
80/100*4=3 roughly) so I want a following out put in separate data frame.
X   y
1  23
1  45
2  87
2  46
2  78
3  12

That means if 1 is in 80% of  my random sample then  the data corresponding  to 
remaining 1's also should be there in my data frame.

One more thing is after creating this data frame, we have only one distinct 
observations which is 4 in our actual data frame

What I mean is we have to get two data sets simultaneously in two different 
data frames, which is of above output format. 

In this case second data frame is 

X   y
4  12
4  87
4  79

This will help while building a model, because we use only 80% data for 
modeling and remaining 20% for validation so that is way I want two datasets 
simultaneously in two different data frames. 

Please help me.

Thanks,
Madhu.

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


Re: [R] Data Extraction

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Sarah,

I am glad you have precisely caught where I made the mistake.  Thank you so 
much.

regards,

Pradip Muhuri


From: Sarah Goslee [sarah.gos...@gmail.com]
Sent: Thursday, November 22, 2012 9:21 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help@r-project.org
Subject: Re: [R] Data Extraction

Hi,

is.nahttp://is.na/( X1 | X2 | X3 | X4 | X5)
isn't a valid construct.

You'd need
!(is.nahttp://is.na(X1) | is.nahttp://is.na(X2) etc )

Or more elegantly
df1[apply(df1, 1, function(x)all(!is.nahttp://is.na(x))), ]

Sarah

On Thursday, November 22, 2012, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:
Hello,

I would appreciate if someone could help me resolve the following:

1. df1[!is.nahttp://is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not 
work

2. Is these message harmful?  The following object(s) are masked from 'df1 
(position 3)':
X1, X2, X3, X4, X5

Thanks,

Pradip Muhuri


#Reproducible Example
set.seed(5)
df1-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
attach (df1)
#delete rows if any of them NA for X1
df1[!is.nahttp://is.na( X1),][,1:5] # This works

#delete rows if any of them NA for X1, X2, X3, X4 or X5
df1[!is.nahttp://is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work

__
R-help@r-project.orgjavascript:; mailing list
https://stat.ethz.ch/mailman/listinfo/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.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

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


Re: [R] Data Extraction

2012-11-22 Thread Berend Hasselman

On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hi Berend,
 
 You have compared all 3 ways.  ... very nicely evaluated. 
 

Bert's solution is indeed nice and simple. But Petr's solution is still the 
quickest:

N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),]}
 f2 - function(df) {df[!is.na(rowSums(df)),]}
 f3 - function(df) {df[complete.cases(df),]}
 f4 - function(df) {data.frame(na.omit(df))}
 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), d4 - f4(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
1 d1 - f1(df)   3.588   14.888  100
2 d2 - f2(df)   0.4031.672  100
3 d3 - f3(df)   0.2411.000  100
4 d4 - f4(df)   0.5572.311  100

 identical(d1,d2)
[1] TRUE
 identical(d1,d3)
[1] TRUE
 identical(d1,d4)
[1] TRUE

Berend

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


Re: [R] ggplot2 and the legend

2012-11-22 Thread Jeff Newmiller
a) Don't crosspost. Read the posting guide(s) for more cautions. This question 
is probably more appropriate on the ggplot Google Group than either of these 
two mailing lists.

b) Post reproducible examples.

c) Use data frames with ggplot, not matrices. The read.csv or read.table 
functions automatically create data frames. It really is important for you to 
show how you create the data objects that give you problems when asking for 
help, since for all we know you just don't know the difference. See point (a) 
above.
---
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.

Peter Kupfer peter.kup...@me.com wrote:

Dear all,
i try to plot with ggplot2. Therefor I have an matrix with 3 colums.
With cbind I add an additional column called col. I need this column
col because in a later step and want to specify here some plot
details which I will get from another analysis
If I want to plot with this code, I have the problem that the legend is
wrong. 
Blue changed to green and green to blue. Furthermore the colors in the
plot seem a little bit strange. Can anybody help me out?
All the best and thanks
Peter



#THE CODE


p0 - ggplot(DATA, aes(Freq, Var1))
p1 - p0+ geom_point(aes(Freq, reorder(Var1, rep(score,cl.count)),
colour=col)) 
 
p2  - p1 +geom_segment(aes(x = 0, xend = Freq, y = Var1, yend = Var1,
colour=col))
p3 - p2 + facet_grid(.~Var2)
plot(p3)



 THE DATA #

#class(DATA) = data.frame
#class(DATA$Var1) = class(DATA$Var2) =  factor

#class(DATA$Freq) = numeric
#class(DATA$col) = character

Var1   Var2Freqcol 
1  208869_s_at JT  10.6802376685463blue
2  203394_s_at JT  10.0160470327077blue
3  201533_at   JT  9.58401500697783blue
4  216520_s_at JT  9.07764840614892blue
5  210999_s_at JT  9.00219110130877green
6  212284_x_at JT  8.62193952504277blue
7  203752_s_at JT  8.69193736253539green
8  203574_at   JT  8.41492571590263blue
9  219629_at   JT  8.19111292436667blue
10 201473_at   JT  8.035082989931  green
11 210592_s_at JT  8.00639829720742green
12 200768_s_at JT  7.88012483915651green
13 201565_s_at JT  7.89885432096935green
14 AFFX-r2-P1-cre-3_at JT  7.86490927895639blue
15 202014_at   JT  7.69345791769434green
16 212671_s_at JT  -7.43350555284605   green
17 203395_s_at JT  7.51127977823914blue
18 208980_s_at JT  7.52175408445448blue
19 207783_x_at JT  7.31954223019292blue
20 215446_s_at JT  -6.28236730203077   green
21 203034_s_at JT  7.24582647671987blue
22 211943_x_at JT  7.22247828112639green
23 203974_at   JT  -6.84217612309489   green
24 201810_s_at JT  7.0727443704914 green
25 201693_s_at JT  7.11350154823655blue
26 213614_x_at JT  7.07586402329325green
27 AFFX-CreX-5_at  JT  7.05274590106307blue
28 201798_s_at JT  -6.98858491240942   blue
29 212869_x_at JT  6.97833756793094green
30 201531_at   JT  6.96660504363297green
31 201170_s_at JT  6.90904695259236green
32 200886_s_at JT  -6.92645789612039   blue
33 AFFX-r2-P1-cre-5_at JT  6.85399276205727blue
34 201429_s_at JT  6.68557384216737green
35 212665_at   JT  6.75579868986925green
36 208695_s_at JT  6.8087149011011 green
37 211654_x_at JT  -6.7426888322764green
38 209927_s_at JT  -6.74856557366229   green
39 203107_x_at JT  6.72120597236789blue
40 211296_x_at JT  6.60226581063165green
41 208869_s_at OA  -3.73983541027906   green
42 203394_s_at OA  -3.29203821581412   green
43 201533_at   OA  -3.2383756900468blue
44 216520_s_at OA  -4.59979375515969   blue
45 210999_s_at OA  -5.10853597491871   green
46 212284_x_at OA  -5.84925048581651   blue
47 203752_s_at OA  -4.54427623838229   blue
48 203574_at   OA  -2.59882534850623   blue
49 219629_at   OA

Re: [R] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Berend,

I see you are one of the contributors to the rbecnhmark package. 

I am sorry that I am bothering you again.  I have tried to run your  code 
(slightly tweaked)  involving the benchmark function, and I am getting the 
following error message. What am I doing wrong?


Error in benchmark(d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df),  : 
  could not find function s1

 
 identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
 identical (d1,d6)
Error: unexpected ',' in identical (d1,d2),

 sessionInfo ()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] rbenchmark_1.0.0

loaded via a namespace (and not attached):
[1] tools_2.15.1



I would appreciate receiving your help if your time permits ..


Thanks and regards,

Pradip Muhuri

#  Berend's code extended
N - 10
set.seed(13)
df-data.frame(matrix(sample(c(1:10,NA),N, replace=TRUE),ncol=50))
s1 - df[complete.cases(df),]
s2 - na.omit(df)
s3 - df[apply(df, 1, function(x)all(!is.na(x))), ]
s4 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
s5 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
s6 - function(df) {df[complete.cases(df),][1:ncol(df)]}

require(rbenchmark)
 
benchmark( d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df), d5 - 
s5(df), d6 - s6(df),
columns=c(test,elapsed, relative, replications) )

identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
identical (d1,d6)





From: Berend Hasselman [b...@xs4all.nl]
Sent: Thursday, November 22, 2012 11:03 AM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help@r-project.org
Subject: Re: [R] Data Extraction

On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hi Berend,

 You have compared all 3 ways.  ... very nicely evaluated.


Bert's solution is indeed nice and simple. But Petr's solution is still the 
quickest:

N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),]}
 f2 - function(df) {df[!is.na(rowSums(df)),]}
 f3 - function(df) {df[complete.cases(df),]}
 f4 - function(df) {data.frame(na.omit(df))}
 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), d4 - f4(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
1 d1 - f1(df)   3.588   14.888  100
2 d2 - f2(df)   0.4031.672  100
3 d3 - f3(df)   0.2411.000  100
4 d4 - f4(df)   0.5572.311  100

 identical(d1,d2)
[1] TRUE
 identical(d1,d3)
[1] TRUE
 identical(d1,d4)
[1] TRUE

Berend

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


[R] error in replor: Results suspect!

2012-11-22 Thread Anera Salucci
Hello all,
I am trying to fit a gee model using repolr and  I get a warning message  
that Results suspect.

Warning message:
 Note: In ogee(formula, data = , id =.,  :  Cgee  had an error (code= 
 104).  Results suspect.

I checked the  source code as Prof. Ripley advice in 2007  but the reason of

this warning is not clear  yet.
Can anybody explain the reason of this error please ?

 
Ana
[[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] Data Extraction

2012-11-22 Thread Bert Gunter
Berend et. al:

1, Except you did not use my solution. It is not what you have but
instead:

f4 - function(df)na.omit.df

wrapping the return in data.frame() is both unnecessary and inefficient.

2. But my point is not to be the speediest nor even to show how clever I am
-- using a built-in function is hardly being clever. Rather to emphasize
that the OP requested a standard task for which R ALREADY HAS BUILT IN
FUNCTIONALITY.  Reading ?na.omit shows that the returned object contains
information (about the omitted rows) that other R functions (e.g.
predict()  ) make use of.  That is the point. Rather than roll your own,
one should use that functionality. It is generally there for a good reason,
as in this case.

Cheers,
Bert


On Thu, Nov 22, 2012 at 8:03 AM, Berend Hasselman b...@xs4all.nl wrote:


 On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

  Hi Berend,
 
  You have compared all 3 ways.  ... very nicely evaluated.
 

 Bert's solution is indeed nice and simple. But Petr's solution is still
 the quickest:

 N - 10
  set.seed(13)
  df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
  library(rbenchmark)
 
  f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),]}
  f2 - function(df) {df[!is.na(rowSums(df)),]}
  f3 - function(df) {df[complete.cases(df),]}
  f4 - function(df) {data.frame(na.omit(df))}
  benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), d4 - f4(df),
 columns=c(test,elapsed, relative, replications))
   test elapsed relative replications
 1 d1 - f1(df)   3.588   14.888  100
 2 d2 - f2(df)   0.4031.672  100
 3 d3 - f3(df)   0.2411.000  100
 4 d4 - f4(df)   0.5572.311  100
 
  identical(d1,d2)
 [1] TRUE
  identical(d1,d3)
 [1] TRUE
  identical(d1,d4)
 [1] TRUE

 Berend

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




-- 

Bert Gunter
Genentech Nonclinical Biostatistics

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

[[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] Data Extraction - benchmark()

2012-11-22 Thread Berend Hasselman

On 22-11-2012, at 18:20, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hi Berend,
 
 I see you are one of the contributors to the rbecnhmark package. 
 
 I am sorry that I am bothering you again.  I have tried to run your  code 
 (slightly tweaked)  involving the benchmark function, and I am getting the 
 following error message. What am I doing wrong?
 
 
 Error in benchmark(d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df),  : 
  could not find function s1
 


Because you haven't defined a function s1 (or s2, s3, s4 for that matter).
You did s1 - df[complete.cases(df),]

Berend

 
 identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
 identical (d1,d6)
 Error: unexpected ',' in identical (d1,d2),
 
 sessionInfo ()
 R version 2.15.1 (2012-06-22)
 Platform: i386-pc-mingw32/i386 (32-bit)
 
 locale:
 [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
 States.1252LC_MONETARY=English_United States.1252
 [4] LC_NUMERIC=C   LC_TIME=English_United States.1252 

 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base 
 
 other attached packages:
 [1] rbenchmark_1.0.0
 
 loaded via a namespace (and not attached):
 [1] tools_2.15.1
 
 
 
 I would appreciate receiving your help if your time permits ..
 
 
 Thanks and regards,
 
 Pradip Muhuri
 
 #  Berend's code extended
 N - 10
 set.seed(13)
 df-data.frame(matrix(sample(c(1:10,NA),N, replace=TRUE),ncol=50))
 s1 - df[complete.cases(df),]
 s2 - na.omit(df)
 s3 - df[apply(df, 1, function(x)all(!is.na(x))), ]
 s4 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
 s5 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
 s6 - function(df) {df[complete.cases(df),][1:ncol(df)]}
 
 require(rbenchmark)
 
 benchmark( d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df), d5 - 
 s5(df), d6 - s6(df),
columns=c(test,elapsed, relative, replications) )
 
 identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
 identical (d1,d6)
 
 
 
 
 
 From: Berend Hasselman [b...@xs4all.nl]
 Sent: Thursday, November 22, 2012 11:03 AM
 To: Muhuri, Pradip (SAMHSA/CBHSQ)
 Cc: r-help@r-project.org
 Subject: Re: [R] Data Extraction
 
 On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:
 
 Hi Berend,
 
 You have compared all 3 ways.  ... very nicely evaluated.
 
 
 Bert's solution is indeed nice and simple. But Petr's solution is still the 
 quickest:
 
 N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)
 
 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),]}
 f2 - function(df) {df[!is.na(rowSums(df)),]}
 f3 - function(df) {df[complete.cases(df),]}
 f4 - function(df) {data.frame(na.omit(df))}
 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), d4 - f4(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
 1 d1 - f1(df)   3.588   14.888  100
 2 d2 - f2(df)   0.4031.672  100
 3 d3 - f3(df)   0.2411.000  100
 4 d4 - f4(df)   0.5572.311  100
 
 identical(d1,d2)
 [1] TRUE
 identical(d1,d3)
 [1] TRUE
 identical(d1,d4)
 [1] TRUE
 
 Berend
 

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


Re: [R] printing difftime summary

2012-11-22 Thread Sam Steingold
 * R. Michael Weylandt zvpunry.jrlyn...@tznvy.pbz [2012-11-22 12:11:55 
 +]:

 I now think that what I want is
 --8---cut here---start-8---
 difftime.summary - function (v) {
   s - summary(as.numeric(v))
   r - as.data.frame(sapply(s,difftime2string),stringsAsFactors=FALSE)
   names(r) - c(string)
   r[[units(v)]] - s
   r
 }

 Any reason not summary.difftime to get S3 dispatch?

I hoped that someone will ask this :-)

1. because its argument has type vector of difftime, not difftime
(coming from CLOS, I do not expect summary(vector of difftime) to
dispatch to summary.difftime, but to summary.vector.of.difftime or something)

2. because difftime.summary returns a data.frame and not a
Classes 'summaryDefault', 'table' as I assume summary must return.

if these are not valid issues, then I wonder why my function should not
be the system default method.

-- 
Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
http://www.childpsy.net/ http://memri.org http://honestreporting.com
http://jihadwatch.org http://openvotingconsortium.org http://ffii.org
Sex is like air.  It's only a big deal if you can't get any.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 read jpeg image with russian font in R?

2012-11-22 Thread David Winsemius


On Nov 21, 2012, at 11:21 PM, Manish Gupta wrote:


Hi,

I m working on R and read one image with russian font using readjpeg()
function and write it on pdf (using grid). But russian text is not  
visible

on pdf. How can i fix my pblm?


You are working with two different plotting paradigms. pdf and ps are  
vector formats and do encode the text as individual characters. But  
jpeg is a lossy bitmap format, so text is not separately encoded as  
characters.


Regards http://r.789695.n4.nabble.com/file/n4650417/pointer.jpg
library(JPEG)


There is a package named 'jpeg so I'm wondering if you are unaware  
the case in naming objects in R is enforced?


--
David.

library(grid)
pdf(out.pdf , width = 6.6 ,height = 4.2,family= URWHelvetica,
encoding=KOI8-R)
a-readJPEG(ArrowImage)# name of arrow
grid.newpage()
pushViewport(viewport(width=0.9, height=0.9))
pushViewport(viewport(yscale=c(0,0), xscale=c(0,1), x=0, y=0,  
width=0.15,

height=1.0, just=c(left, bottom)))
grid.raster(a, y=unit(ypos.img, native))
popViewport()
popViewport()
dev.off()

Regards



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-read-jpeg-image-with-russian-font-in-R-tp4650417.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
Alameda, CA, USA

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


Re: [R] [BioC] lapack routines cannot be loaded [Help request]

2012-11-22 Thread Martin Morgan

On 11/22/2012 03:23 AM, Manca Marco (PATH) wrote:


Dear BioConductor and R fellow users

I apologize in advance for double posting, but I am not sure which list would 
actually be best fit for this message.


It helps to narrow the problem down. It looks like the problem occurs when 
chol2inv is invoked, and in a plain R session


  R --vanilla

the following would fail

  example(chol2inv)

hence a problem with your installed R (since chol2inv is in the 'base' package), 
rather than Bioconductor. How did you install your R, especially how was it 
configured to use LAPACK? Have you modified your system's LAPACK after installing R?


Martin




I am experiencing a weird error with my R installation on Ubuntu 10.04.4 (LTS) 
64bit:

When I run R on the terminal everything goes smoothly:

$R
R version 2.15.2 (2012-10-26) -- Trick or Treat
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

   Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


However, as soon as I try to use limma (or WGCNA... I haven't tried other 
packages yet) the following mistake pops up ( lapack routines cannot be loaded )


library(limma)



fit - lmFit(Data.rma, design)

Error in chol2inv(fit$qr$qr, size = fit$qr$rank) :
   lapack routines cannot be loaded
In addition: Warning message:
In chol2inv(fit$qr$qr, size = fit$qr$rank) :
   unable to load shared object '/usr/lib64/R/modules//lapack.so':
   /usr/lib64/R/modules//lapack.so: undefined symbol: dpstrf_




It is independent of the dataset I am using.

I have already tried to recompile the whole BioConductor set of packages, and 
updated the general packages via CRAN, but nothing changed.

Following I am attaching my sessionInfo(), and you will find enclosed to this 
email the (incriminated) lapack.so file, should you be willing/able to take a 
look at it.

Any insights into what could be going on, and how to address the issue?


sessionInfo()

R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.utf8   LC_NUMERIC=C
  [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8
  [5] LC_MONETARY=en_US.utf8LC_MESSAGES=en_US.utf8
  [7] LC_PAPER=CLC_NAME=C
  [9] LC_ADDRESS=C  LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C

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

other attached packages:
[1] limma_3.12.3  hgu133plus2cdf_2.10.0 AnnotationDbi_1.18.4
[4] affy_1.34.0   Biobase_2.16.0BiocGenerics_0.2.0

loaded via a namespace (and not attached):
[1] affyio_1.24.0 BiocInstaller_1.4.9   DBI_0.2-5
[4] IRanges_1.14.4preprocessCore_1.18.0 RSQLite_0.11.2
[7] stats4_2.15.2 tools_2.15.2  zlibbioc_1.2.0



Thank you in advance,
Marco


--
Dr Marco Manca
University of Maastricht
Faculty of Health, Medicine and Life Sciences (FHML)
Cardiovascular Research Institute (CARIM)

Mailing address: PO Box 616, 6200 MD Maastricht (The Netherlands)
Visiting address: UNS40 West building - 5th floor Room5.544, Universiteit 
Singel 40, 6229  HX Maastricht

E-mail: m.ma...@maastrichtuniversity.nl
Office telephone: +31(0)433884289
Personal mobile: +31(0)626441205
Twitter: @markomanka


*

This email and any files transmitted with it are confidential and solely for 
the use of the intended recipient.

It may contain material protected by privacy or 
doctor-patient/consultant-client privilege. If you are not the intended 
recipient or the person responsible for

delivering to the intended recipient, be advised that you have received this 
email in error and that any use is STRICTLY PROHIBITED.

If you have received this email in error please notify us by telephone on 
+31626441205 Dr Marco MANCA

*



___
Bioconductor mailing list
bioconduc...@r-project.org
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives: 
http://news.gmane.org/gmane.science.biology.informatics.conductor




--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793


[R] Using cumsum with 'group by' ?

2012-11-22 Thread TheRealJimShady
Hi,

First post here. Grateful for any help you can give. I have data which looks
like this:

idtimex
1   12:015
1   12:02   14
1   12:03   6
1   12:04   3
2   12:01   98
2   12:02   23
2   12:03   1
2   12:04   4
3   12:01   5
3   12:02   65
3   12:03   23
3   12:04   23

But I want to add a column which is the cumulative sum of X, but only by id.
I've used cumsum before, but not in this way. So the result should be
something like:

id   time  xcumsum
1  12:01   55
1  12:02  14  19 
1  12:03  6 25
1  12:04  3 28
2  12:01  98   98  
2  12:02  23   121
2  12:03  1 122
2  12:04  4 126
3  12:01  5  5
3  12:02  65   70
3  12:03  23   93 
3  12:04  23   116

Any ideas please?




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

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


Re: [R] Help with loop

2012-11-22 Thread arun
HI,

If it is possible to remove those NA values:
 dat$time - as.Date(dat$time,format=%Y-%m-%d)
newdat-dat[complete.cases(dat),]

 change-cumsum(c(FALSE,abs(diff(newdat$Salt))0.05))  #Rui's solution
 split(newdat,change)
A.K.



- Original Message -
From: Hefri helenefrigs...@hotmail.com
To: r-help@r-project.org
Cc: 
Sent: Thursday, November 22, 2012 6:43 AM
Subject: Re: [R] Help with loop

Hi again,

I was thinking that the interval would stop when there was a NA, ignore
subsequent NAs and only start a new interval when there was a new value. So
in the example below, the interval would stop at row 320, and a new interval
started at row 334.

 head (D, 20)
        Salt       time
319 35.63190 2004-07-26
320 35.66033 2004-07-27
321       NA 2004-07-28
322       NA 2004-07-29
323       NA 2004-07-30
324       NA 2004-07-31
325       NA 2004-08-01
326       NA 2004-08-02
327       NA 2004-08-03
328       NA 2004-08-04
329       NA 2004-08-05
330       NA 2004-08-06
331       NA 2004-08-07
332       NA 2004-08-08
333       NA 2004-08-09
334 35.57781 2004-08-10
335 35.59829 2004-08-11

Many thanks, Helene



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

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


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


[R] How to control plotting formula above lm diagnostic plots?

2012-11-22 Thread ksaw
Dear All,

I am trying to plot four diagnostic plots for my lm in one window. 

Here is some random data for an example:
  a = rnorm(20, mean=2, sd=0.2)
  b = rnorm(20, mean=1, sd=0.4)
  model=lm(a~b)

When I set the page as:
  par(mfrow=c(1,1), oma=c(1,0,2,0))
and plot my model:
  plot(model)

above all four plots the formula lm(a~b) is printed.

What is interesting if I set the page to have two plots per page (still
plotting all four using plot(model)), the formula is plotted only above the
last two. When I set the page to have one plot per page (still plotting all
four using plot(model)) the formula is not printed above any of the plots.

Is there any way to control plotting the formula above the diagnostic plots
if I have multiple per page? To control the text size, font, position, or
just not to have it plotted it at all? Playing with the option 'main' or
'cex.main' inside the 'plot' function does not change anything.

Many thanks

Kasia





--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-control-plotting-formula-above-lm-diagnostic-plots-tp4650465.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] Partial dependence plot in randomForest package (all flat responses)

2012-11-22 Thread Oritteropus
Hi,
I'm trying to make a partial plot with package randomForest in R. After I
perform my random forest object I type

partialPlot(data.rforest, pred.data=act2, x.var=centroid, C) 

where data.rforest is my randomforest object, act2 is the original dataset,
centroid is one of the predictor and C is one of the classes in my response
variable. 
Whatever predictor or response class I try I always get a plot with a
straight line (a completely flat response). Similarly, If I set a
categorical variable as predictor, I get a barplot with all the bar with the
same height. I suppose I'm doing something wrong here because all other
analysis on the same rforest object seem correct (e.g. varImp or MDSplot).
Is it possible it is related to some option set in random forest object? Can
somebody see the problem here?
Thanks for your time



--
View this message in context: 
http://r.789695.n4.nabble.com/Partial-dependence-plot-in-randomForest-package-all-flat-responses-tp4650470.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] Mixed models and learning curves

2012-11-22 Thread Giovanna Ottaviani
My name is Giovanna and I am a PhD student in Norway.
I am a beginner with statistics and R,  hence my ignorance. Apologies from 
now.

I have been collecting data on time performances of 5 subjects using a 1:3 
scale tower yarder. The task was consisting in yarding 5 small logs placed on 
permanently marked course. Four subjects had different previous experiences 
(None, Some) and the fifth was a trainer (Control).
Each cycle time per each log was registered, the sum of the 5 logs' cycle time 
was giving the replication time. We had 6 replication per subject .
I would like to predict the time necessary to perform the task.

I have been modelling the time to perform the task (prod.time)versus the 
replication number (Trial-in the dataset), the previous experience (factor) and 
their interaction. As random effect I have been using the subjects.



 ma-lme(prod.time~Trial+Previous.experience+Trial*Previous.experience, data=  
 Data27_04, random=~1|Student, method=ML)
 summary(ma)
Linear mixed-effects model fit by maximum likelihood
Data: Data27_04
   AIC  BIClogLik
  1517.445 1541.259 -750.7226

Random effects:
Formula: ~1 | Student
(Intercept) Residual
StdDev:7.337648 42.42332

Fixed effects: prod.time ~ Trial + Previous.experience + Trial * 
Previous.experience
   Value Std.Error  DF   t-value p-value
(Intercept)102.44173  9.561987 137 10.713435  0.
Trial   -6.48494  2.252271 137 -2.879291  0.0046
Previous.experience1   -37.36173 14.786033   2 -2.526826  0.1274
Previous.experience247.22627 12.451072   2  3.792948  0.0630
Trial:Previous.experience1   6.55351  3.496401 137  1.874360  0.0630
Trial:Previous.experience2  -7.55163  2.940879 137 -2.567813  0.0113
Correlation:
   (Intr) Trial  Prvs.1 Prvs.2 Tr:P.1
Trial  -0.841
Previous.experience10.253 -0.208
Previous.experience2   -0.234  0.199 -0.540
Trial:Previous.experience1 -0.207  0.264 -0.835  0.447
Trial:Previous.experience2  0.199 -0.226  0.447 -0.836 -0.550

Standardized Within-Group Residuals:
   Min Q1Med Q3Max
-2.3519731 -0.6903211 -0.1031114  0.6503216  4.6699702

Number of Observations: 145
Number of Groups: 5


Do you think this is good enough to demonstrate a learning effect.
Learning curves are exponential. I have been trying to log transform the 
response variable but then p-values are saying that previous experience has no 
significance.

  mb-lme(log.prodtime~Trial+Previous.experience+Trial*Previous.experience, 
 data=  Data27_04, random=~1|Student, method=ML)
 summary(mb)
Linear mixed-effects model fit by maximum likelihood
Data: Data27_04
   AIC  BIClogLik
  225.1042 248.9181 -104.5521

Random effects:
Formula: ~1 | Student
(Intercept) Residual
StdDev:  0.04484554 0.495812

Fixed effects: log.prodtime ~ Trial + Previous.experience + Trial * 
Previous.experience
   Value  Std.Error  DF  t-value p-value
(Intercept) 4.448206 0.10593072 137 41.99165  0.
Trial  -0.060150 0.02629765 137 -2.28726  0.0237
Previous.experience1   -0.333664 0.16351518   2 -2.04057  0.1781
Previous.experience20.368358 0.13776525   2  2.67381  0.1160
Trial:Previous.experience1  0.051714 0.04084708 137  1.26604  0.2076
Trial:Previous.experience2 -0.043036 0.03435150 137 -1.25282  0.2124
Correlation:
   (Intr) Trial  Prvs.1 Prvs.2 Tr:P.1
Trial  -0.886
Previous.experience10.248 -0.221
Previous.experience2   -0.237  0.209 -0.535
Trial:Previous.experience1 -0.220  0.266 -0.881  0.473
Trial:Previous.experience2  0.208 -0.225  0.474 -0.883 -0.551

Standardized Within-Group Residuals:
   Min Q1Med Q3Max
-2.7119095 -0.8005032  0.1127388  0.8621127  2.1988560

Number of Observations: 145
Number of Groups: 5


The model is surely better (AIC, BIC) also the residuals are looking better but 
then should I reduce the model leaving only the Trial number?

How would you present the results in a clear way? I am still struggling to 
figure it out. The concept of mixed models is clear in my head but it is hard 
to present it.

How should I then plot the learning curve?
I have been plotting the data I have adding a smooth line. Is this good enough?

Looking forward for your response
Best regards
Giovanna


Giovanna Ottaviani Aalmo
Stipendiat/Ph..D. Student
---
Norsk institutt for skog og landskap
Pb 115, NO-1431 Ås
T (+47) 64 94 9094
M(+47) 980 30 422
F(+47) 64 94  90 80
---
www.skogoglandskap.nohttp://www.skogoglandskap.no/
---


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list

Re: [R] cluster analysis in R

2012-11-22 Thread KitKat
These are the errors I've been having. I have been trying 3 different things

1- Mclust:
This is the example I have been following:
# Model Based Clustering
library(mclust)
fit - Mclust(mydata)
plot(fit, mydata) # plot results 
print(fit) # display the best model 
 
What I have done:
 fit - Mclust(mydat)
 plot(fit, mydat) #plot results
Error in match.arg(what, c(BIC, classification, uncertainty,
density),  : 
  'arg' must be NULL or a character vector

2- Mclust using different website (cran-r) instructions
This is the example: 
 mydatMclust - Mclust(mydat)
 summary(mydatMclust)
 summary(mydatMclust, parameters = TRUE)
 plot(mydatMclust)

There are a couple other steps but the plot is the problem. I get two plots,
there should be four. One should be plotting all my individuals but it's
plotting my variables instead. It's also taking a very long time. R script
at this point says: Waiting to confirm page change… 

3. Mcclust 
Instructions from cran-r:
data(cls.draw2)
# sample of 500 clusterings from a Bayesian cluster model
tru.class - rep(1:8,each=50)
# the true grouping of the observations
psm2 - comp.psm(cls.draw2)
# posterior similarity matrix
# optimize criteria based on PSM
mbind2 - minbinder(psm2)
mpear2 - maxpear(psm2)
# Relabelling
k - apply(cls.draw2,1, function(cl) length(table(cl)))
max.k - as.numeric(names(table(k))[which.max(table(k))])
relab2 - relabel(cls.draw2[k==max.k,])
# compare clusterings found by different methods with true grouping
arandi(mpear2$cl, tru.class)
arandi(mbind2$cl, tru.class)
arandi(relab2$cl, tru.class)

I called my data: mydat so I changed that where appropriate. I cannot get
past one early step, psm2 - comp.psm(cls.draw2).. the error reads: Error:
could not find function comp.psm

I think I have all appropriate packages installed. I don't know what more to
do on these three errors.  Any help would be great! Thank you




--
View this message in context: 
http://r.789695.n4.nabble.com/cluster-analysis-in-R-tp4649635p4650466.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] ROC Curve: negative AUC

2012-11-22 Thread brunosm
Hi all,

does anyone know why the area under the curve (AUC) is negative?

I'm using ROC function with a logistic regression, package Epi.

First time it happens...

Thanks a lot!

Bruno



--
View this message in context: 
http://r.789695.n4.nabble.com/ROC-Curve-negative-AUC-tp4650469.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Using cumsum with 'group by' ?

2012-11-22 Thread William Dunlap
 transform(d, cumsumXById = ave(x, id, FUN=cumsum))
   id  time  x cumsumXById
1   1 12:01  5   5
2   1 12:02 14  19
3   1 12:03  6  25
4   1 12:04  3  28
5   2 12:01 98  98
6   2 12:02 23 121
7   2 12:03  1 122
8   2 12:04  4 126
9   3 12:01  5   5
10  3 12:02 65  70
11  3 12:03 23  93
12  3 12:04 23 116

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of TheRealJimShady
 Sent: Thursday, November 22, 2012 9:09 AM
 To: r-help@r-project.org
 Subject: [R] Using cumsum with 'group by' ?
 
 Hi,
 
 First post here. Grateful for any help you can give. I have data which looks
 like this:
 
 idtimex
 1   12:015
 1   12:02   14
 1   12:03   6
 1   12:04   3
 2   12:01   98
 2   12:02   23
 2   12:03   1
 2   12:04   4
 3   12:01   5
 3   12:02   65
 3   12:03   23
 3   12:04   23
 
 But I want to add a column which is the cumulative sum of X, but only by id.
 I've used cumsum before, but not in this way. So the result should be
 something like:
 
 id   time  xcumsum
 1  12:01   55
 1  12:02  14  19
 1  12:03  6 25
 1  12:04  3 28
 2  12:01  98   98
 2  12:02  23   121
 2  12:03  1 122
 2  12:04  4 126
 3  12:01  5  5
 3  12:02  65   70
 3  12:03  23   93
 3  12:04  23   116
 
 Any ideas please?
 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Using-cumsum-with-
 group-by-tp4650457.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] Data Extraction - benchmark()

2012-11-22 Thread Muhuri, Pradip (SAMHSA/CBHSQ)
Hi Berend,

Thank you very much for pointing out the mistake and for your patience. I have 
corrected the the script, which  has worked fine.

regards,

Pradip Muhuri



From: Berend Hasselman [b...@xs4all.nl]
Sent: Thursday, November 22, 2012 12:42 PM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: r-help@r-project.org
Subject: Re: [R] Data Extraction - benchmark()

On 22-11-2012, at 18:20, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hi Berend,

 I see you are one of the contributors to the rbecnhmark package.

 I am sorry that I am bothering you again.  I have tried to run your  code 
 (slightly tweaked)  involving the benchmark function, and I am getting the 
 following error message. What am I doing wrong?


 Error in benchmark(d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df),  :
  could not find function s1



Because you haven't defined a function s1 (or s2, s3, s4 for that matter).
You did s1 - df[complete.cases(df),]

Berend


 identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
 identical (d1,d6)
 Error: unexpected ',' in identical (d1,d2),

 sessionInfo ()
 R version 2.15.1 (2012-06-22)
 Platform: i386-pc-mingw32/i386 (32-bit)

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

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

 other attached packages:
 [1] rbenchmark_1.0.0

 loaded via a namespace (and not attached):
 [1] tools_2.15.1



 I would appreciate receiving your help if your time permits ..


 Thanks and regards,

 Pradip Muhuri

 #  Berend's code extended
 N - 10
 set.seed(13)
 df-data.frame(matrix(sample(c(1:10,NA),N, replace=TRUE),ncol=50))
 s1 - df[complete.cases(df),]
 s2 - na.omit(df)
 s3 - df[apply(df, 1, function(x)all(!is.na(x))), ]
 s4 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),][,1:ncol(df)]}
 s5 - function(df) {df[!is.na(rowSums(df)),][1:ncol(df)]}
 s6 - function(df) {df[complete.cases(df),][1:ncol(df)]}

 require(rbenchmark)

 benchmark( d1 - s1(df), d2 - s2(df), d3 - s3(df), d4 - s4(df), d5 - 
 s5(df), d6 - s6(df),
columns=c(test,elapsed, relative, replications) )

 identical (d1,d2), identical (d1,d3), identical (d1,d4), identical (d1,d5), 
 identical (d1,d6)




 
 From: Berend Hasselman [b...@xs4all.nl]
 Sent: Thursday, November 22, 2012 11:03 AM
 To: Muhuri, Pradip (SAMHSA/CBHSQ)
 Cc: r-help@r-project.org
 Subject: Re: [R] Data Extraction

 On 22-11-2012, at 16:50, Muhuri, Pradip (SAMHSA/CBHSQ) wrote:

 Hi Berend,

 You have compared all 3 ways.  ... very nicely evaluated.


 Bert's solution is indeed nice and simple. But Petr's solution is still the 
 quickest:

 N - 10
 set.seed(13)
 df - data.frame(matrix(sample(c(1:10,NA),N,replace=TRUE),ncol=50))
 library(rbenchmark)

 f1 - function(df) {df[apply(df, 1, function(x)all(!is.na(x))),]}
 f2 - function(df) {df[!is.na(rowSums(df)),]}
 f3 - function(df) {df[complete.cases(df),]}
 f4 - function(df) {data.frame(na.omit(df))}
 benchmark(d1 - f1(df), d2 - f2(df), d3 - f3(df), d4 - f4(df), 
 columns=c(test,elapsed, relative, replications))
  test elapsed relative replications
 1 d1 - f1(df)   3.588   14.888  100
 2 d2 - f2(df)   0.4031.672  100
 3 d3 - f3(df)   0.2411.000  100
 4 d4 - f4(df)   0.5572.311  100

 identical(d1,d2)
 [1] TRUE
 identical(d1,d3)
 [1] TRUE
 identical(d1,d4)
 [1] TRUE

 Berend


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


Re: [R] Using cumsum with 'group by' ?

2012-11-22 Thread Berend Hasselman

On 22-11-2012, at 18:08, TheRealJimShady wrote:

 Hi,
 
 First post here. Grateful for any help you can give. I have data which looks
 like this:
 
 idtimex
 1   12:015
 1   12:02   14
 1   12:03   6
 1   12:04   3
 2   12:01   98
 2   12:02   23
 2   12:03   1
 2   12:04   4
 3   12:01   5
 3   12:02   65
 3   12:03   23
 3   12:04   23
 
 But I want to add a column which is the cumulative sum of X, but only by id.
 I've used cumsum before, but not in this way. So the result should be
 something like:
 
 id   time  xcumsum
 1  12:01   55
 1  12:02  14  19 
 1  12:03  6 25
 1  12:04  3 28
 2  12:01  98   98  
 2  12:02  23   121
 2  12:03  1 122
 2  12:04  4 126
 3  12:01  5  5
 3  12:02  65   70
 3  12:03  23   93 
 3  12:04  23   116
 
 Any ideas please?


Assuming your data are in a dataframe named df this should do what you want

df[,cumsum] - ave(df$x,by=df$id, FUN=cumsum)


Berend

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


Re: [R] ROC Curve: negative AUC

2012-11-22 Thread Wensui Liu
wrong direction for ranking

On Thu, Nov 22, 2012 at 1:58 PM, brunosm brunos...@gmail.com wrote:

 the area under the curve (AUC) is negative?

 I'm using ROC function with a logistic regression, package Epi.

 First time it happens...

 Thanks a lot!

 Bruno




-- 
==
WenSui Liu
Credit Risk Manager, 53 Bancorp
wensui@53.com
513-295-4370
==

[[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] ROC Curve: negative AUC

2012-11-22 Thread Thomas Lumley
On Fri, Nov 23, 2012 at 7:58 AM, brunosm brunos...@gmail.com wrote:

 Hi all,

 does anyone know why the area under the curve (AUC) is negative?

 I'm using ROC function with a logistic regression, package Epi.

 First time it happens...


Have you looked at the ROC curve?

That should tell you whether there's some strange non-convexity going on or
whether the variable is just being put into the calculations backwards.

   -thomas


-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

[[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] Plotting specific points with type='l'

2012-11-22 Thread eric
I have a dataframe (x) and I'm plotting the 5th column vs the index. I also
have a vector (v) with a few select points that I want to emphasize with a
dot for those points

 head(x)
period   AP   EU   LA   NA
1 Jan 2007 0.18 0.45 0.19 3.19
2 Feb 2007 0.14 0.48 0.36 3.55
3 Mar 2007 0.14 0.42 0.46 2.61
4 Apr 2007 0.24 0.73 0.32 4.32
5 May 2007 0.19 0.60 0.32 4.40
6 Jun 2007 0.14 0.38 0.32 1.09

v -c(2,4,7)
plot(x[,5], type='l')

How do I put a solid dot at just the points I want to highlight ? In other
words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other
points according the the type='l'. I tried ... points(x[v,5], pch=19) ...
but the points didn't plot in the right spot. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.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 VEC

2012-11-22 Thread Laura Catalina Echeverri
Hello everyone,

I have estimated a VEC using functions of package urca. Now I need to
simulate several trajectories of the variables of the model based in the
information of the model. To do that first I converted the VEC to a VAR
using vec2var (from package vars) and then I converted de VAR to an ARMA
using ARMA function of package dse. The idea is to use the function simulate
(from package dse), to simulate the ARMA from the VEC using the initial
values of the variables of the model, the exogenous variables in the
simulation period and the matrix of covariances of the residuals of the VEC
model, to model the residuals in each simulation. Then I made several
iterations of this simulation, to obtain different trajectories and conclude
about the model; but sometimes the plot of the simulations shows values of
the variables on the order of +-1e137 (a really big number) and I don't know
why it is happening. Does anyone of you know what can be happening?

Thanks in advance,

Laura Echeverri 



--
View this message in context: 
http://r.789695.n4.nabble.com/Simulating-a-VEC-tp4650463.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] ifelse + numeric

2012-11-22 Thread djbanana
Thanks, it worked without quotation marks.



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

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


Re: [R] Plotting specific points with type='l'

2012-11-22 Thread jim holtman
try this

 # you need to provide sample data
 x - runif(10)
 v - c(2, 4, 7)
 plot(x, type = 'l')
 # highlight points
 points(v, x[v], pch = 19)



On Thu, Nov 22, 2012 at 2:22 PM, eric ericst...@aol.com wrote:
 I have a dataframe (x) and I'm plotting the 5th column vs the index. I also
 have a vector (v) with a few select points that I want to emphasize with a
 dot for those points

 head(x)
 period   AP   EU   LA   NA
 1 Jan 2007 0.18 0.45 0.19 3.19
 2 Feb 2007 0.14 0.48 0.36 3.55
 3 Mar 2007 0.14 0.42 0.46 2.61
 4 Apr 2007 0.24 0.73 0.32 4.32
 5 May 2007 0.19 0.60 0.32 4.40
 6 Jun 2007 0.14 0.38 0.32 1.09

 v -c(2,4,7)
 plot(x[,5], type='l')

 How do I put a solid dot at just the points I want to highlight ? In other
 words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other
 points according the the type='l'. I tried ... points(x[v,5], pch=19) ...
 but the points didn't plot in the right spot.



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.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
Data Munger Guru

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

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


[R] SEM raw moment matrix

2012-11-22 Thread Maya Abou Zeid
Hello,

I estimated a model using SEM package in R, which was fit to a raw moment 
matrix, and includes an intercept term. The only goodness of fit statistics 
that are output are Model Chisquare, AIC, AICc, BIC, CAIC, and normalized 
residuals.

How can I get the other goodness of fit statistics, like adjusted goodness of 
fit, RMSEA, and R-squared? And how can I get the final value of the 
log-likelihood of the model?

Thanks,
Maya

[[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] plotting 1000 simulations, error message: plot.new has not been called yet

2012-11-22 Thread Greg Snow
Why are you using jpeg to create files with a .png extension? wouldn't it
make more sense to use the png function?

There are a couple of options, you could plot using the matplot function
(with different subsets in the loop).

Or you can start an initial empty plot and use lines to add to it, then use
dev.copy to copy the current version to a file.

Or you can look at the animation package.

Or you could do nested loops, but hopefully one of the above is better than
that approach.


On Wed, Nov 21, 2012 at 11:07 AM, Maximilian Lklweryc maxlklwe...@gmail.com
 wrote:

 Hi,
 I know this is not a mailing list for r, but I posted my question on
 several help pages and did not get any help. I really don't know how
 to solve my problem, maybe you could help me?

 want to simulate stock paths. I have simulated 1000 paths with 22
 trading days (1 starting value). Now I want to include it into my
 presentation, but animated, so I need the png files.

 I want to create 1000 png files, starting with the first stock path,
 then the second and so on.

 So I start with the first path, add a second to the plot, add the
 third and so on, so at the end I have a plot with 1000 simulations,
 here is my code:

 for(i in 1:1000){
 #jpeg(paste(1000s,i,.png,sep=))
 plot(c(1:23),matrix[,1],type=l,ylim=c(17,24))
 lines(c(1:23),matrix[,i],type=l,col=i)
 #dev.off()
 }

 Here is the problem, that each additional part disappears when the
 loop gets to the next value, so I tried:

 plot(0,0 , xlim=c(1,23),ylim=c(17,24),xlab=,ylab=)
 for(i in 1:1000){
 jpeg(paste(1000s,i,.png,sep=))
 lines(c(1:23),matrix[,i],type=l,col=i)
 dev.off()
 }

 (I know this is not a working example, but my problem is just a
 logical one with the loop) I get the following error message when I
 the last code: plot.new has not been called yet.

 The matrix has 1000 columns and 23 row entries, this should be 1000
 simulations of stock pathes for 22 trading days.

 How can I change that the error does not appear anymore? 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.




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

[[alternative HTML version deleted]]

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


Re: [R] Summary statistics for matrix columns

2012-11-22 Thread Pete Brecknock
frespider wrote
 Hi,
 
 is there a way I can calculate a summary statistics for a columns matrix
  let say we have this matrix 
 x - matrix(sample(1:8000),nrow=100)
 colnames(x)- paste(Col,1:ncol(x),sep=)
 
 if I used summary 
 summary(x) 
 
 i get the output for each column but I need the output to be in matrix
 with rownames  and all the columns beside it 
 
 this how I want it 
 
 Col76 Col77
  Min.  :739  
  1st Qu. :1846   1630   
  Median :   3631   3376   
  Mean:   3804   3617 
 Sd  :   
  3rd Qu.:5772   5544  
 IQR:
  Max.   :79527779  
 
 Is there an easy way?
 
 Thanks

How about ...

x - matrix(sample(1:8000),nrow=100)
colnames(x)- paste(Col,1:ncol(x),sep=)

apply(x,2,function(x) c(summary(x), sd=sd(x), IQR=IQR(x)))

HTH

Pete



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650490.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] Data frame manipulation

2012-11-22 Thread Raoni Rodrigues
Hello,

I have a table that was constructed in a wrong way (dput data on bottom -
wrong data-frame):

Local   Mês Dia Colonia X6h X7h X8h X9hX10hX11h
   X12hX13hX14hX15hX16hX17h
1  Conceição Junho   1   3 2.16137 2.20412 2.08991 1.72428 1.69897
1.62325 1.44716 1.51851 1.43136 1.47712 1.51851 1.04139
2  Conceição Junho   2   3 2.46538 2.13672 2.06819 1.97772 2.0
1.80618 1.64345 1.20412 1.62325 1.36173 1.69020 1.57978
3  Conceição Junho   3   3 2.53275 2.52504 2.49276 2.3 2.12710
2.26007 2.24551 1.95424 2.09342 1.04139 1.53148 1.17609
4  Conceição Junho   1   4 1.65321 2.16435 1.91381 1.75587 1.74036
1.17609 1.66276 1.51851 1.39794 1.04139 1.11394 1.04139
5  Conceição Junho   2   4 2.30320 1.71600 2.02531 2.05690 1.86332
1.66276 1.17609 1.04139 1.30103 1.27875 1.3 1.3
6  Conceição Junho   3   4 2.71012 2.30320 2.53403 1.80618 2.24551
2.20683 2.02531 1.07918 1.36173 1.39794 1.11394 1.93450
7  Conceição Junho   1   5 2.21748 1.99564 2.26007 2.28103 2.10380
1.41497 0.47712 1.07918 0.90309 1.04139 1.49136 1.23045
8  Conceição Junho   2   5 2.10721 2.16435 2.05308 2.38561 2.14613
1.61278 1.27875 0.47712 1.61278 1.0 1.44716 1.07918
9  Conceição Junho   3   5 1.62325 1.93450 2.33041 2.24797 2.29885
2.48001 2.29003 1.43136 1.49136 1.17609 1.41497 1.14613
10 Conceição julho   1   3 2.20952 2.01284 1.79239 1.59106 1.62325
1.51851 1.41497 1.38021 1.66276 1.46240 1.53148 1.66276


I have to create a new column (hour) and transpose just the last 12
columns, and first four columns have to be copied 12 time, like this (dput
data on bottom - correct data-frame):

 Local   Mês Dia Colonia HoraN
1  Conceição Junho   1   3   6h 2.161370
2  Conceição Junho   1   3   7h 2.204120
3  Conceição Junho   1   3   8h 2.089910
4  Conceição Junho   1   3   9h 1.724280
5  Conceição Junho   1   3  10h 1.698970
6  Conceição Junho   1   3  11h 1.623250
7  Conceição Junho   1   3  12h 1.447160
8  Conceição Junho   1   3  13h 1.518510
9  Conceição Junho   1   3  14h 1.431360
10 Conceição Junho   1   3  15h 1.477120
11 Conceição Junho   1   3  16h 1.518510
12 Conceição Junho   1   3  17h 1.041390
13 Conceição Junho   2   3   6h 2.465383

Some one could give me some ideas? I don't even know how to start...

Thanks in advanced,

-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.ra...@gmail.com

wrong data frame:

structure(list(Local = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = Conceição, class = factor), Mês = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c(julho, Junho
), class = factor), Dia = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L), Colonia = c(3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 3L),
X6h = c(2.16137, 2.46538, 2.53275, 1.65321, 2.3032, 2.71012,
2.21748, 2.10721, 1.62325, 2.20952), X7h = c(2.20412, 2.13672,
2.52504, 2.16435, 1.716, 2.3032, 1.99564, 2.16435, 1.9345,
2.01284), X8h = c(2.08991, 2.06819, 2.49276, 1.91381, 2.02531,
2.53403, 2.26007, 2.05308, 2.33041, 1.79239), X9h = c(1.72428,
1.97772, 2.3, 1.75587, 2.0569, 1.80618, 2.28103, 2.38561,
2.24797, 1.59106), X10h = c(1.69897, 2, 2.1271, 1.74036,
1.86332, 2.24551, 2.1038, 2.14613, 2.29885, 1.62325), X11h = c(1.62325,
1.80618, 2.26007, 1.17609, 1.66276, 2.20683, 1.41497, 1.61278,
2.48001, 1.51851), X12h = c(1.44716, 1.64345, 2.24551, 1.66276,
1.17609, 2.02531, 0.47712, 1.27875, 2.29003, 1.41497), X13h =
c(1.51851,
1.20412, 1.95424, 1.51851, 1.04139, 1.07918, 1.07918, 0.47712,
1.43136, 1.38021), X14h = c(1.43136, 1.62325, 2.09342, 1.39794,
1.30103, 1.36173, 0.90309, 1.61278, 1.49136, 1.66276), X15h =
c(1.47712,
1.36173, 1.04139, 1.04139, 1.27875, 1.39794, 1.04139, 1,
1.17609, 1.4624), X16h = c(1.51851, 1.6902, 1.53148, 1.11394,
1.3, 1.11394, 1.49136, 1.44716, 1.41497, 1.53148), X17h =
c(1.04139,
1.57978, 1.17609, 1.04139, 1.3, 1.9345, 1.23045, 1.07918,
1.14613, 1.66276)), .Names = c(Local, Mês, Dia, Colonia,
X6h, X7h, X8h, X9h, X10h, X11h, X12h, X13h, X14h,
X15h, X16h, X17h), row.names = c(NA, 10L), class = data.frame)



Correct data frame:

structure(list(Local = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = Conceição, class = factor), Mês = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(julho, Junho
), class = factor), Dia = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), Colonia = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
Hora = structure(1:10, .Label = c(6h, 7h, 8h, 9h,
10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h), class =
factor),
N = c(2.16137, 2.20412, 2.08991, 1.72428, 1.69897, 1.62325,
1.44716, 1.51851, 1.43136, 1.47712)), .Names = c(Local,
Mês, Dia, Colonia, Hora, N), row.names = c(NA, 10L), class =
data.frame)

[[alternative HTML version deleted]]


Re: [R] [lattice] Increase distance between tick labels and ticks in wireframe plot (pad)

2012-11-22 Thread Peter Ehlers

On 2012-11-22 01:16, Felix Schönbrodt wrote:

Hello,

I try to increase the distance between tick labels and ticks in a lattice 
wireframe plot. Here's a minimal example:

## Minimal example
x - y - z - c(1,2,3)
df - data.frame(x, y, z)
wireframe(z ~ x*y, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6))


I tried the axis.components option 
(http://r.789695.n4.nabble.com/Lattice-distance-of-tick-labels-from-axis-line-tp3693014p3693014.html).
 This works for xyplot, but *not* for wireframe:

xyplot(z ~ x, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6), par.settings=list(axis.components=list(left=list(pad1=2

wireframe(z ~ x*y, df,  scales = list(arrows = FALSE, col = black, font = 1, 
tck=0.6), par.settings=list(axis.components=list(left=list(pad1=2

Any ideas on how to pad the axis labels in wireframe plots?

Thanks,
Felix


I think that you want the 'distance=' argument to scales (which is
documented in ?wireframe).

Try this:
wireframe(z ~ x*y, df,
  scales = list(arrows = FALSE,
col = black,
font = 1,
tck = c(0.8, 0.6, 0.4),
distance =c(2, 5, 8)))

Adjust as you prefer.

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.


[R] Adding a function with default parameters into the Rcmdr menu

2012-11-22 Thread vincent guyader
Hi everyone,

I made some tests with Rcmdr, to add a function with default parameters :

For example (very simple):

myfunction-function(var=314){
print(hello)
print(var)
}

if I run myfunction() directly i see :

 myfunction()
[1] hello
[1] 314

it's ok.

But if i edit de Rcmdr-menu.txt (in
C:\Users\myname\Documents\R\win-library\2.15\Rcmdr\etc)
and add :

menuMyMenutopMenu

  
itemtopMenu  cascade
MyTestMyMenu   
itemMyMenu   command Test
myfunction 

and I put myfonction into a file Rcmdr-test.R in the same folder

I have a new button with a cascade menu, and myfunction is corectly
sourced.. but :


that's what append :

 library(Rcmdr)
Loading required package: tcltk
Loading Tcl/Tk interface ... done
Loading required package: car
Loading required package: MASS
Loading required package: nnet
Sourced: Rcmdr-test.r


Rcmdr Version 1.9-2

If i use the Menu :

[1] hello
[1] %var

-there are %var instead off 314.
 myfunction
function(var=314){
print(hello)
print(var)
}

I think that I made a mistake but I dont know were. How can I use Rcmdr
menu AND a default parameter ?

Can you help me?

Thx a lot.

[[alternative HTML version deleted]]

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


Re: [R] Data frame manipulation

2012-11-22 Thread jim holtman
The 'reshape2' package is your friend:

 require(reshape2)
 x - melt(wrong, id = c(Local, Mês, Dia, Colonia), variable.name = 
 Hora)
 # remove X from Hora
 x$Hora - as.character(substring(x$Hora, 2))
 head(x)  # not in the right order
  Local   Mês Dia Colonia Hora   value
1 Conceição Junho   1   3   6h 2.16137
2 Conceição Junho   2   3   6h 2.46538
3 Conceição Junho   3   3   6h 2.53275
4 Conceição Junho   1   4   6h 1.65321
5 Conceição Junho   2   4   6h 2.30320
6 Conceição Junho   3   4   6h 2.71012
 # sort, but first add blank on Hora for less that 10h for sorting
 x$Hora - ifelse(nchar(x$Hora) == 2, paste0( , x$Hora), x$Hora)
 x - x[order(x$Local, x$Mês, x$Dia, x$Colonia, x$Hora), ]

 head(x,20)
Local   Mês Dia Colonia Hora   value
10  Conceição julho   1   3   6h 2.20952
20  Conceição julho   1   3   7h 2.01284
30  Conceição julho   1   3   8h 1.79239
40  Conceição julho   1   3   9h 1.59106
50  Conceição julho   1   3  10h 1.62325
60  Conceição julho   1   3  11h 1.51851
70  Conceição julho   1   3  12h 1.41497
80  Conceição julho   1   3  13h 1.38021
90  Conceição julho   1   3  14h 1.66276
100 Conceição julho   1   3  15h 1.46240
110 Conceição julho   1   3  16h 1.53148
120 Conceição julho   1   3  17h 1.66276
1   Conceição Junho   1   3   6h 2.16137
11  Conceição Junho   1   3   7h 2.20412
21  Conceição Junho   1   3   8h 2.08991
31  Conceição Junho   1   3   9h 1.72428
41  Conceição Junho   1   3  10h 1.69897
51  Conceição Junho   1   3  11h 1.62325
61  Conceição Junho   1   3  12h 1.44716
71  Conceição Junho   1   3  13h 1.51851



On Thu, Nov 22, 2012 at 8:53 PM, Raoni Rodrigues
caciquesamu...@gmail.com wrote:
 structure(list(Local = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L, 1L), .Label = Conceição, class = factor), Mês = structure(c(2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(julho, Junho
 ), class = factor), Dia = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
 1L, 1L), Colonia = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L),
 Hora = structure(1:10, .Label = c(6h, 7h, 8h, 9h,
 10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h), class =
 factor),
 N = c(2.16137, 2.20412, 2.08991, 1.72428, 1.69897, 1.62325,
 1.44716, 1.51851, 1.43136, 1.47712)), .Names = c(Local,
 Mês, Dia, Colonia, Hora, N), row.names = c(NA, 10L), class =
 data.frame)



-- 
Jim Holtman
Data Munger Guru

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

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


[R] Constant (= wrong) historical quotes via get.hist.quote() from yahoo.finance

2012-11-22 Thread Marius Hofert
Dear expeRts,

I would like to download a time series of historical data from the ticker with 
symbol ROG.VX. Interestingly, I obtain constant values (138.3 for each day in 
the chosen period) although the yahoo.finance website tells me that the time 
series is not at all constant. What's wrong?

Cheers,

Marius


require(tseries)
hq - get.hist.quote(instrument=ROG.VX, start=2011-09-09, end=2012-03-28,
 quote=Close, provider=yahoo, drop=TRUE)
plot(hq) # = constant
stopifnot(hq==138.3) # = constant 138.3
## However, under 
http://finance.yahoo.com/q/hp?s=ROG.VXa=08b=09c=2011d=02e=28f=2012g=dz=66y=132
## the historical prices are not all equal to 138.3


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


Re: [R] Summary statistics for matrix columns

2012-11-22 Thread frespider

I also don't like to use split function because I have like around 800 columns 

Date: Thu, 22 Nov 2012 18:08:54 -0800
From: ml-node+s789695n4650496...@n4.nabble.com
To: frespi...@hotmail.com
Subject: RE: Summary statistics for matrix columns

Hi,

How about this:

res-do.call(cbind,lapply(split(x,col(x)),function(x) 
c(summary(x),sd=sd(x),IQR=IQR(x

 colnames(res)-colnames(x)

 is.matrix(res)

[1] TRUE

 res

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Min.10.0  1.0 17.0  3.0 18.0 11.0 13.0 15.0

1st Qu. 24.75000 29.5 26.0  7.75000 40.0 17.25000 27.5 34.75000

Median  34.0 46.0 42.5 35.5 49.5 23.5 51.5 51.5

Mean42.5 42.75000 41.75000 35.75000 44.88000 26.88000 44.75000 50.12000

3rd Qu. 67.75000 58.5 50.0 63.25000 54.25000 30.25000 56.25000 70.5

Max.74.0 77.0 76.0 70.0 65.0 63.0 79.0 80.0

sd  25.05993 27.77846 19.57221 28.40397 16.39196 16.60841 21.97239 25.51995

IQR 43.0 29.0 24.0 55.5 14.25000 13.0 28.75000 35.75000

Col9Col10

Min. 2.0  6.0

1st Qu. 24.5 12.5

Median  33.5 48.0

Mean34.88000 40.75000

3rd Qu. 45.25000 63.0

Max.71.0 72.0

sd  24.39811 28.21727

IQR 20.75000 50.5

A.K.









If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650496.html


This email was sent by arun kirshna (via Nabble)


  



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650498.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] Summary statistics for matrix columns

2012-11-22 Thread frespider
Hi,

is there a way I can calculate a summary statistics for a columns matrix
 let say we have this matrix 
x - matrix(sample(1:8000),nrow=100)
colnames(x)- paste(Col,1:ncol(x),sep=)

if I used summary 
summary(x) 

i get the output for each column but I need the output to be in matrix with
rownames  and all the columns beside it 

this how I want it 

Col76 Col77
 Min.  :739  
 1st Qu. :1846   1630   
 Median :   3631   3376   
 Mean:   3804   3617 
Sd  :   
 3rd Qu.:5772   5544  
IQR:
 Max.   :79527779  

Is there an easy way?

Thanks 




--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489.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] Summary statistics for matrix columns

2012-11-22 Thread frespider
Hi peter,

but this doesn't give me them in the order I want.

Is there a better approach 

Thanks 



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650492.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] Summary statistics for matrix columns

2012-11-22 Thread frespider

There is still missing some statistics, 
like sd and IQR and I prefer the output to be matrix 

Thanks 

Date: Thu, 22 Nov 2012 18:00:20 -0800
From: ml-node+s789695n4650493...@n4.nabble.com
To: frespi...@hotmail.com
Subject: Re: Summary statistics for matrix columns



HI,

You could try this:

set.seed(125)

x - matrix(sample(1:80),nrow=8)

colnames(x)- paste(Col,1:ncol(x),sep=) 

 sapply(data.frame(x),function(x) summary(x))

# Col1  Col2  Col3  Col4  Col5  Col6  Col7  Col8  Col9 Col10

#Min.10.00  1.00 17.00  3.00 18.00 11.00 13.00 15.00  2.00  6.00

#1st Qu. 24.75 29.50 26.00  7.75 40.00 17.25 27.50 34.75 24.50 12.50

#Median  34.00 46.00 42.50 35.50 49.50 23.50 51.50 51.50 33.50 48.00

#Mean42.50 42.75 41.75 35.75 44.88 26.88 44.75 50.12 34.88 40.75

#3rd Qu. 67.75 58.50 50.00 63.25 54.25 30.25 56.25 70.50 45.25 63.00

#Max.74.00 77.00 76.00 70.00 65.00 63.00 79.00 80.00 71.00 72.00

A.K.










If you reply to this email, your message will be added to the 
discussion below:

http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650493.html



To unsubscribe from Summary statistics for matrix columns, 
click here.

NAML
  



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650494.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Summary statistics for matrix columns

2012-11-22 Thread frespider

HI,

but Sd and IQR not in the order I want ,

Thanks 

Date: Thu, 22 Nov 2012 18:08:57 -0800
From: ml-node+s789695n4650496...@n4.nabble.com
To: frespi...@hotmail.com
Subject: RE: Summary statistics for matrix columns



Hi,

How about this:

res-do.call(cbind,lapply(split(x,col(x)),function(x) 
c(summary(x),sd=sd(x),IQR=IQR(x

 colnames(res)-colnames(x)

 is.matrix(res)

[1] TRUE

 res

Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

Min.10.0  1.0 17.0  3.0 18.0 11.0 13.0 15.0

1st Qu. 24.75000 29.5 26.0  7.75000 40.0 17.25000 27.5 34.75000

Median  34.0 46.0 42.5 35.5 49.5 23.5 51.5 51.5

Mean42.5 42.75000 41.75000 35.75000 44.88000 26.88000 44.75000 50.12000

3rd Qu. 67.75000 58.5 50.0 63.25000 54.25000 30.25000 56.25000 70.5

Max.74.0 77.0 76.0 70.0 65.0 63.0 79.0 80.0

sd  25.05993 27.77846 19.57221 28.40397 16.39196 16.60841 21.97239 25.51995

IQR 43.0 29.0 24.0 55.5 14.25000 13.0 28.75000 35.75000

Col9Col10

Min. 2.0  6.0

1st Qu. 24.5 12.5

Median  33.5 48.0

Mean34.88000 40.75000

3rd Qu. 45.25000 63.0

Max.71.0 72.0

sd  24.39811 28.21727

IQR 20.75000 50.5

A.K.










If you reply to this email, your message will be added to the 
discussion below:

http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650496.html



To unsubscribe from Summary statistics for matrix columns, 
click here.

NAML
  



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650497.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Summary statistics for matrix columns

2012-11-22 Thread frespider

Hi,

it is possible. but don't you think it will slow the code if you convert to 
data.frame?

Thanks 

Date: Thu, 22 Nov 2012 18:31:35 -0800
From: ml-node+s789695n4650500...@n4.nabble.com
To: frespi...@hotmail.com
Subject: RE: Summary statistics for matrix columns



HI,

Is it possible to use as.matrix()?

res-sapply(data.frame(x),function(x) c(summary(x),sd=sd(x),IQR=IQR(x)))

 res1-as.matrix(res)

 is.matrix(res1)

#[1] TRUE

res1[c(1:4,7,5,8,6),]

#Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8

#Min.10.0  1.0 17.0  3.0 18.0 11.0 13.0 15.0

#1st Qu. 24.75000 29.5 26.0  7.75000 40.0 17.25000 27.5 34.75000

#Median  34.0 46.0 42.5 35.5 49.5 23.5 51.5 51.5

#Mean42.5 42.75000 41.75000 35.75000 44.88000 26.88000 44.75000 50.12000

#sd  25.05993 27.77846 19.57221 28.40397 16.39196 16.60841 21.97239 25.51995

#3rd Qu. 67.75000 58.5 50.0 63.25000 54.25000 30.25000 56.25000 70.5

#IQR 43.0 29.0 24.0 55.5 14.25000 13.0 28.75000 35.75000

#Max.74.0 77.0 76.0 70.0 65.0 63.0 79.0 80.0

  #  Col9Col10

#Min. 2.0  6.0

#1st Qu. 24.5 12.5

#Median  33.5 48.0

#Mean34.88000 40.75000

#sd  24.39811 28.21727

#3rd Qu. 45.25000 63.0

#IQR 20.75000 50.5

#Max.71.0 72.0

Solves the order and the matrix output!

A.K.














If you reply to this email, your message will be added to the 
discussion below:

http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650500.html



To unsubscribe from Summary statistics for matrix columns, 
click here.

NAML
  



--
View this message in context: 
http://r.789695.n4.nabble.com/Summary-statistics-for-matrix-columns-tp4650489p4650501.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] Plotting specific points with type='l'

2012-11-22 Thread arun
Hi,
If you wanted to emphasize the select points from the 5th column:
You could try:
plot(x[,5], type='l')
 points(dat2[c(2,4,7),5],pch=19)
A.K.




- Original Message -
From: eric ericst...@aol.com
To: r-help@r-project.org
Cc: 
Sent: Thursday, November 22, 2012 2:22 PM
Subject: [R] Plotting specific points with type='l'

I have a dataframe (x) and I'm plotting the 5th column vs the index. I also
have a vector (v) with a few select points that I want to emphasize with a
dot for those points

 head(x)
    period   AP   EU   LA   NA
1 Jan 2007 0.18 0.45 0.19 3.19
2 Feb 2007 0.14 0.48 0.36 3.55
3 Mar 2007 0.14 0.42 0.46 2.61
4 Apr 2007 0.24 0.73 0.32 4.32
5 May 2007 0.19 0.60 0.32 4.40
6 Jun 2007 0.14 0.38 0.32 1.09

v -c(2,4,7)
plot(x[,5], type='l')

How do I put a solid dot at just the points I want to highlight ? In other
words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other
points according the the type='l'. I tried ... points(x[v,5], pch=19) ...
but the points didn't plot in the right spot. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.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] Factor function for coded numerical values

2012-11-22 Thread maths123
I have s data set where 2 of the columns give the coded versions of the
factors A and B. Factor A is coded with 1, 2, 3. Factor B is coded with 1,2. 

How do  use the factor function to convert these variables into factors, and
also use the labels=  command to give them a more informative name?



--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-for-coded-numerical-values-tp4650483.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Using cumsum with 'group by' ?

2012-11-22 Thread arun
Hi,
No problem.
One more method if you wanted to try:
library(data.table)
dat2-data.table(dat1)
dat2[,list(x,time,Cumsum=cumsum(x)),list(id)]
 #   id  x  time Cumsum
 #1:  1  5 12:01  5
 #2:  1 14 12:02 19
 #3:  1  6 12:03 25
 #4:  1  3 12:04 28
 #5:  2 98 12:01 98
 #6:  2 23 12:02    121
 #7:  2  1 12:03    122
 #8:  2  4 12:04    126
 #9:  3  5 12:01  5
#10:  3 65 12:02 70
#11:  3 23 12:03 93
#12:  3 23 12:04    116


A.K.



- Original Message -
From: TheRealJimShady james.david.sm...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Thursday, November 22, 2012 12:27 PM
Subject: Re: [R] Using cumsum with 'group by' ?

Thank you very much, I will try these tomorrow morning.

On 22 November 2012 17:25, arun kirshna [via R]
ml-node+s789695n4650459...@n4.nabble.com wrote:
 HI,
 You can do this in many ways:
 dat1-read.table(text=
 id    time    x
 1   12:01    5
 1   12:02   14
 1   12:03   6
 1   12:04   3
 2   12:01   98
 2   12:02   23
 2   12:03   1
 2   12:04   4
 3   12:01   5
 3   12:02   65
 3   12:03   23
 3   12:04   23
 ,sep=,header=TRUE,stringsAsFactors=FALSE)
  dat1$Cumsum-ave(dat1$x,dat1$id,FUN=cumsum)
 #or
  unlist(tapply(dat1$x,dat1$id,FUN=cumsum),use.names=FALSE)
 # [1]   5  19  25  28  98 121 122 126   5  70  93 116
 #or
 library(plyr)
  ddply(dat1,.(id),function(x) cumsum(x[3]))[,2]
 # [1]   5  19  25  28  98 121 122 126   5  70  93 116
 head(dat1)
 #  id  time  x Cumsum
 #1  1 12:01  5      5
 #2  1 12:02 14     19
 #3  1 12:03  6     25
 #4  1 12:04  3     28
 #5  2 12:01 98     98
 #6  2 12:02 23    121
 A.K.




 
 If you reply to this email, your message will be added to the discussion
 below:
 http://r.789695.n4.nabble.com/Using-cumsum-with-group-by-tp4650457p4650459.html
 To unsubscribe from Using cumsum with 'group by' ?, click here.
 NAML




--
View this message in context: 
http://r.789695.n4.nabble.com/Using-cumsum-with-group-by-tp4650457p4650461.html
Sent from the R help mailing list archive at Nabble.com.
    [[alternative HTML version deleted]]

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


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


[R] Optimizing nested function with nlminb()

2012-11-22 Thread Дмитрий Островский
I am trying to optimize custom likelyhood with nlminb()
Arguments h and f are meant to be fixed.

example.R:

compute.hyper.log.likelyhood - function(a, h, f) {
  a1 - a[1]
  a2 - a[2]
  l - 0.0
  for (j in 1:length(f)) {
l - l + lbeta(a1 + f[j], a2 + h - f[j]) - lbeta(a1, a2)
  }
  return(l)
}

compute.optimal.hyper.params - function(start, limits, h_, f_) {
  result - nlminb(start,
   compute.hyper.log.likelyhood,
   h=h_,
   f=f_,
   scale = -1,
   lower = c(limits[1],limits[1]),
   upper = c(limits[2],limits[2]))
  return (result[[1]])
}

Console launch:

source('~/Desktop/Dropbox/example.R')
h - 1000
start - c(3,3)
limits - c(0.01,100)
f - c(40,30,50)
compute.optimal.hyper.params(start,limits,h,f)


produces the following:

Error in a2 + h : 'h' is missing


Could you please explain me why?

R version 2.15.1 (2012-06-22) -- Roasted Marshmallows
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i686-pc-linux-gnu (32-bit)

--
Best regards,
Dmitry

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

2012-11-22 Thread Sarah_R_edu
hi guys and gals ... How are you all ...

i have to do something in robust regression by R programm , and i have some
problems as following:

*the first :*
 suppose 
w(r) =1/(1 r^2) and r - c(7.01,2.07,7.061,5.607,8.502,54.909,12.222)
and i want to exclude some values from r so that (abs(r)4.9 )...
after ,i want to used (w) to get on coefficients beta0 and beta1 (B1 -
(sum(w*y*x)-sum(w*y)*sum(w*x))/(sum(w*(x^2))-(sum(w*x))^2/sum(w))
 B0 - (sum(w*y)-B1*sum(x*w))/sum(w).
this process must to repeat it until (w) be 0.001 ( tolerance - 0.001)
How can i get on this in one program?
- i tried to do it by if -else , repeat and while - 


*the second:*
in simple robust regression we have two way to fit the model

1- rlm(formula, data, weights, ..., subset, na.action,
method = c(M, MM, model.frame),
wt.method = c(inv.var, case),
model = TRUE, x.ret = TRUE, y.ret = FALSE, contrasts = NULL)

2- rlm(x, y, weights, ..., w = rep(1, nrow(x)),
init = ls, psi = psi.huber,
scale.est = c(MAD, Huber, proposal 2), k2 = 1.345,
method = c(M, MM), wt.method = c(inv.var, case),
maxit = 20, acc = 1e-4, test.vec = resid, lqs.control = NULL)
psi.huber(u, k = 1.345, deriv = 0)
psi.hampel(u, a = 2, b = 4, c = 8, deriv = 0)
psi.bisquare(u, c = 4.685, deriv = 0)

and all these ways works by default function as psi.huber and i want to add
new psi ( psi.a=r/(1+(r/k)^2)) ,k=1.345 and get on new coefficients to the
model, and, Is all the arguments are necessary ?  i want short code

again ... *how can i do this ... *


thanks in advance ...
/my best wishes.../



-
We are all like the bright moon, we still have our darker side 

--
View this message in context: 
http://r.789695.n4.nabble.com/help-in-M-estimator-by-R-tp4650485.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] (no subject)

2012-11-22 Thread Sarah AdDawsary

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


Re: [R] Data frame manipulation

2012-11-22 Thread arun
Hi,
May be this helps:
library(reshape)
dat1 # data that needs to be converted
res-melt(dat1,id=c(Local,Mês,Dia,Colonia))
 names(res)[5:6]-c(Hora,N)
 res1-res[order(res$Dia),] 

 row.names(res1)-1:nrow(res1)
res1$Hora-gsub([X],,res1$Hora)
 head(res1)
#  Local   Mês Dia Colonia Hora   N
#1 Conceição Junho   1   3   6h 2.16137
#2 Conceição Junho   1   4   6h 1.65321
#3 Conceição Junho   1   5   6h 2.21748
#4 Conceição julho   1   3   6h 2.20952
#5 Conceição Junho   1   3   7h 2.20412
#6 Conceição Junho   1   4   7h 2.16435
A.K.


To: r-help@r-project.org
Cc: 
Sent: Thursday, November 22, 2012 8:53 PM
Subject: [R] Data frame manipulation

Hello,

I have a table that was constructed in a wrong way (dput data on bottom -
wrong data-frame):

    Local   Mês Dia Colonia     X6h     X7h     X8h     X9h    X10h    X11h
   X12h    X13h    X14h    X15h    X16h    X17h
1  Conceição Junho   1       3 2.16137 2.20412 2.08991 1.72428 1.69897
1.62325 1.44716 1.51851 1.43136 1.47712 1.51851 1.04139
2  Conceição Junho   2       3 2.46538 2.13672 2.06819 1.97772 2.0
1.80618 1.64345 1.20412 1.62325 1.36173 1.69020 1.57978
3  Conceição Junho   3       3 2.53275 2.52504 2.49276 2.3 2.12710
2.26007 2.24551 1.95424 2.09342 1.04139 1.53148 1.17609
4  Conceição Junho   1       4 1.65321 2.16435 1.91381 1.75587 1.74036
1.17609 1.66276 1.51851 1.39794 1.04139 1.11394 1.04139
5  Conceição Junho   2       4 2.30320 1.71600 2.02531 2.05690 1.86332
1.66276 1.17609 1.04139 1.30103 1.27875 1.3 1.3
6  Conceição Junho   3       4 2.71012 2.30320 2.53403 1.80618 2.24551
2.20683 2.02531 1.07918 1.36173 1.39794 1.11394 1.93450
7  Conceição Junho   1       5 2.21748 1.99564 2.26007 2.28103 2.10380
1.41497 0.47712 1.07918 0.90309 1.04139 1.49136 1.23045
8  Conceição Junho   2       5 2.10721 2.16435 2.05308 2.38561 2.14613
1.61278 1.27875 0.47712 1.61278 1.0 1.44716 1.07918
9  Conceição Junho   3       5 1.62325 1.93450 2.33041 2.24797 2.29885
2.48001 2.29003 1.43136 1.49136 1.17609 1.41497 1.14613
10 Conceição julho   1       3 2.20952 2.01284 1.79239 1.59106 1.62325
1.51851 1.41497 1.38021 1.66276 1.46240 1.53148 1.66276


I have to create a new column (hour) and transpose just the last 12
columns, and first four columns have to be copied 12 time, like this (dput
data on bottom - correct data-frame):

     Local   Mês Dia Colonia Hora        N
1  Conceição Junho   1       3   6h 2.161370
2  Conceição Junho   1       3   7h 2.204120
3  Conceição Junho   1       3   8h 2.089910
4  Conceição Junho   1       3   9h 1.724280
5  Conceição Junho   1       3  10h 1.698970
6  Conceição Junho   1       3  11h 1.623250
7  Conceição Junho   1       3  12h 1.447160
8  Conceição Junho   1       3  13h 1.518510
9  Conceição Junho   1       3  14h 1.431360
10 Conceição Junho   1       3  15h 1.477120
11 Conceição Junho   1       3  16h 1.518510
12 Conceição Junho   1       3  17h 1.041390
13 Conceição Junho   2       3   6h 2.465383

Some one could give me some ideas? I don't even know how to start...

Thanks in advanced,

-- 
Raoni Rosa Rodrigues
Research Associate of Fish Transposition Center CTPeixes
Universidade Federal de Minas Gerais - UFMG
Brasil
rodrigues.ra...@gmail.com

wrong data frame:

structure(list(Local = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), .Label = Conceição, class = factor), Mês = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L), .Label = c(julho, Junho
), class = factor), Dia = c(1L, 2L, 3L, 1L, 2L, 3L, 1L, 2L,
3L, 1L), Colonia = c(3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 3L),
    X6h = c(2.16137, 2.46538, 2.53275, 1.65321, 2.3032, 2.71012,
    2.21748, 2.10721, 1.62325, 2.20952), X7h = c(2.20412, 2.13672,
    2.52504, 2.16435, 1.716, 2.3032, 1.99564, 2.16435, 1.9345,
    2.01284), X8h = c(2.08991, 2.06819, 2.49276, 1.91381, 2.02531,
    2.53403, 2.26007, 2.05308, 2.33041, 1.79239), X9h = c(1.72428,
    1.97772, 2.3, 1.75587, 2.0569, 1.80618, 2.28103, 2.38561,
    2.24797, 1.59106), X10h = c(1.69897, 2, 2.1271, 1.74036,
    1.86332, 2.24551, 2.1038, 2.14613, 2.29885, 1.62325), X11h = c(1.62325,
    1.80618, 2.26007, 1.17609, 1.66276, 2.20683, 1.41497, 1.61278,
    2.48001, 1.51851), X12h = c(1.44716, 1.64345, 2.24551, 1.66276,
    1.17609, 2.02531, 0.47712, 1.27875, 2.29003, 1.41497), X13h =
c(1.51851,
    1.20412, 1.95424, 1.51851, 1.04139, 1.07918, 1.07918, 0.47712,
    1.43136, 1.38021), X14h = c(1.43136, 1.62325, 2.09342, 1.39794,
    1.30103, 1.36173, 0.90309, 1.61278, 1.49136, 1.66276), X15h =
c(1.47712,
    1.36173, 1.04139, 1.04139, 1.27875, 1.39794, 1.04139, 1,
    1.17609, 1.4624), X16h = c(1.51851, 1.6902, 1.53148, 1.11394,
    1.3, 1.11394, 1.49136, 1.44716, 1.41497, 1.53148), X17h =
c(1.04139,
    1.57978, 1.17609, 1.04139, 1.3, 1.9345, 1.23045, 1.07918,
    1.14613, 1.66276)), .Names = c(Local, Mês, Dia, Colonia,
X6h, X7h, X8h, X9h, X10h, X11h, X12h, X13h, X14h,
X15h, X16h, X17h), row.names = c(NA, 10L), class = data.frame)



Correct data frame:


[R] What is the . in formula ~. syntax?

2012-11-22 Thread Brian Feeny
I know if I have a dataframe with columns y, x1, x2 and I wish to have y as my 
y value and x1 and x2 as x values I can do:
y ~ x1 + x2

or 

y ~.

but can someone explain what . actually is or what its transposed into?

I searched for this with no success, reading the formula manual pages.

Brian

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

2012-11-22 Thread wampeh
How do I get gvarbrowser to display the contents of data.frame named, say
atab1?  That is modify the Filter by: entries to only show data.frame

Also, how do I turn off the selection pull down box, given that I know the
name of the data.frame variable?  Basically, I will like to browse the
variable name in a data.frame

gdf(atab1, container =gwindow(Object browser), expand=TRUE)
displays the data values, I an interest in showing just the names in a GUI
environment similar to gvarbrowser 


I tried the following

age=18:29; height=1:12; 
atab1 - data.frame(age=age,height=height)

mydefaultclasses -  list(Data sets1=c(data.frame)   )

v - gvarbrowser(
  container =gwindow(Object broser),  
  gvarbrowser_classes=mydefaultclasses 
  )

This did not seem to work, displayed default selection entries

I also tried:
options(gWidgets:gvarbrowser_classes=mydefaultclasses)

v - gvarbrowser(  container =gwindow(Object broser))




--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-override-gWidgets-gvarbrowser-classes-tp4650509.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] Odp: Object Browser

2012-11-22 Thread wampeh
How do I get gvarbrowser to display only data.frame named, say atab1 or
atab2 or atab*?

Also, how do I turn off the selection pull down box?


#I tried:
mydefaultclasses -  list(Data sets1=c(data.frame)   )
# 
# Then
v - gvarbrowser(  container =gwindow(Object broser), 
gWidgets:gvarbrowser_classes=mydefaultclasses )

#--
# but it does not seem to work

#I also tried:
options(gWidgets:gvarbrowser_classes=mydefaultclasses)

#then
v - gvarbrowser(  container =gwindow(Object broser))

#this too did not work

#I would simply like to display the variable browser window for data.frame
atab1 (say).

Thank you



--
View this message in context: 
http://r.789695.n4.nabble.com/Object-Browser-tp2594912p4650511.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] Barplot with lines

2012-11-22 Thread Ripples
Hi,

I'm trying to plot stacked barplot with lines on it.  Here is the data.

emp days val1 val2 score
1 21 1 0 1200
2 35 1 1 na
3 42 na na 3000
4 53 2 1 2100
5 64 1 0 na
6 73 na na 1400

My X-axis is days. I'm looking to plot val1,val2 as stacked bars and score
as lines with different y-axis. I could get the bar plot and lines on it
but the problem is the bars and lines are not aligning well for same point
on X-axis. Note, that there might not be a score for some when there is
val1 and val2 or vice versa. Any help in this regard is highly appreciated.

Thanks in Advance!

SK

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