[R] How numerical data is stored inside ts time series objects

2015-04-20 Thread Paul
I'm getting familiar with the stl function in the stats packcage by
trying it on an example from Brockwell  Davis's 2002 Introduction to
Times Series and Forcasting.  Specifically, I'm using a subset of his
red wine sales data.  It's a detour from the stl material at
http://www.stat.pitt.edu/stoffer/tsa3/R_toot.htm (at some point, I
have to stop simply following and try to make it work with new data).

I need a minimum of 36 wine sales data points in the series, since stl
otherwise complains about the data being less than 2 cycles.  The data
is in ~/tmp/wine.txt:

464
675
703
887
1139
1077
1318
1260
1120
963
996
960
530
883
894
1045
1199
1287
1565
1577
1076
918
1008
1063
544
635
804
980
1018
1064
1404
1286
1104
999
996
1015

My sourced test code is buried in a repeat loop so that I can use a
break command to circumvent the final error-causing statement that I'm
trying to figure out:

repeat{

# Clear variables (from stackexchange)
rm( list=setdiff( ls( all.names=TRUE ), lsf.str(all.names=TRUE ) ) )
ls()

head( wine - read.table(~/tmp/wine.txt) )
( x - ts(wine[[1]],frequency=12) )
( y - ts(wine,frequency=12) )
( a=stl(x,per) )
#break
( b=stl(y,per) )
}

The final statement causes the error 'Error in stl(y, per) : only
univariate series are allowed'.  I found an explanation at
http://stackoverflow.com/questions/10492155/time-series-and-stl-in-r-error-
only-univariate-series-are-allowed.
That's how I came up with the assignment to x using wine[[1]].  I
found an explanation to the need for
double square brackets at
http://www.r-tutor.com/r-introduction/list/named-list-members.

My problem is that it's not very clear what is happening inside the ts
structures x and y.  If I simply print them, they look 100% identical:

|  x
|Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
| 1  464  675  703  887 1139 1077 1318 1260 1120  963  996  960
| 2  530  883  894 1045 1199 1287 1565 1577 1076  918 1008 1063
| 3  544  635  804  980 1018 1064 1404 1286 1104  999  996 1015
|  y
|Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
| 1  464  675  703  887 1139 1077 1318 1260 1120  963  996  960
| 2  530  883  894 1045 1199 1287 1565 1577 1076  918 1008 1063
| 3  544  635  804  980 1018 1064 1404 1286 1104  999  996 1015

Whatever their differences, it's not causing R to misinterpret the
data; that is, they each look like in single series of numerical data.

Can anyone illuminate the difference in the data inside the ts data
structures?  The potential incompatibility with stl is just one
symptom.  Right now, the solution is black magic to me, and I would
like to get a clearer picture so that I know when else (and how) to
watch out for this.

I've posted this to the R Help mailing list
http://news.gmane.org/gmane.comp.lang.r.general and to stackoverflow
at
http://stackoverflow.com/questions/29759928/how-numerical-data-is-stored-
inside-ts-time-series-objects.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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 numerical data is stored inside ts time series objects

2015-04-20 Thread William Dunlap
Use the str() function to see the internal structure of most objects.  In
your case it would show something like:

 Data - data.frame(theData=round(sin(1:38),1))
 x - ts(Data[[1]], frequency=12) # or Data[,1]
 y - ts(Data, frequency=12)
 str(x)
 Time-Series [1:38] from 1 to 4.08: 0.8 0.9 0.1 -0.8 -1 -0.3 0.7 1 0.4 -0.5
...
 str(y)
 ts [1:38, 1] 0.8 0.9 0.1 -0.8 -1 -0.3 0.7 1 0.4 -0.5 ...
 - attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr theData
 - attr(*, tsp)= num [1:3] 1 4.08 12

'x' contains a vector of data and 'y' contains a 1-column matrix of data.
stl(x,per) and stl(y, per) give similar results as you got.

Evidently, stl() does not know that 1-column matrices can be treated much
the same as vectors and gives an error message.  Thus you must extract
the one column into a vector: stl(y[,1], per).




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Apr 20, 2015 at 4:04 PM, Paul paul.domas...@gmail.com wrote:

 I'm getting familiar with the stl function in the stats packcage by
 trying it on an example from Brockwell  Davis's 2002 Introduction to
 Times Series and Forcasting.  Specifically, I'm using a subset of his
 red wine sales data.  It's a detour from the stl material at
 http://www.stat.pitt.edu/stoffer/tsa3/R_toot.htm (at some point, I
 have to stop simply following and try to make it work with new data).

 I need a minimum of 36 wine sales data points in the series, since stl
 otherwise complains about the data being less than 2 cycles.  The data
 is in ~/tmp/wine.txt:

 464
 675
 703
 887
 1139
 1077
 1318
 1260
 1120
 963
 996
 960
 530
 883
 894
 1045
 1199
 1287
 1565
 1577
 1076
 918
 1008
 1063
 544
 635
 804
 980
 1018
 1064
 1404
 1286
 1104
 999
 996
 1015

 My sourced test code is buried in a repeat loop so that I can use a
 break command to circumvent the final error-causing statement that I'm
 trying to figure out:

 repeat{

 # Clear variables (from stackexchange)
 rm( list=setdiff( ls( all.names=TRUE ), lsf.str(all.names=TRUE ) )
 )
 ls()

 head( wine - read.table(~/tmp/wine.txt) )
 ( x - ts(wine[[1]],frequency=12) )
 ( y - ts(wine,frequency=12) )
 ( a=stl(x,per) )
 #break
 ( b=stl(y,per) )
 }

 The final statement causes the error 'Error in stl(y, per) : only
 univariate series are allowed'.  I found an explanation at
 http://stackoverflow.com/questions/10492155/time-series-and-stl-in-r-error-
 only-univariate-series-are-allowed.
 That's how I came up with the assignment to x using wine[[1]].  I
 found an explanation to the need for
 double square brackets at
 http://www.r-tutor.com/r-introduction/list/named-list-members.

 My problem is that it's not very clear what is happening inside the ts
 structures x and y.  If I simply print them, they look 100% identical:

 |  x
 |Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
 | 1  464  675  703  887 1139 1077 1318 1260 1120  963  996  960
 | 2  530  883  894 1045 1199 1287 1565 1577 1076  918 1008 1063
 | 3  544  635  804  980 1018 1064 1404 1286 1104  999  996 1015
 |  y
 |Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
 | 1  464  675  703  887 1139 1077 1318 1260 1120  963  996  960
 | 2  530  883  894 1045 1199 1287 1565 1577 1076  918 1008 1063
 | 3  544  635  804  980 1018 1064 1404 1286 1104  999  996 1015

 Whatever their differences, it's not causing R to misinterpret the
 data; that is, they each look like in single series of numerical data.

 Can anyone illuminate the difference in the data inside the ts data
 structures?  The potential incompatibility with stl is just one
 symptom.  Right now, the solution is black magic to me, and I would
 like to get a clearer picture so that I know when else (and how) to
 watch out for this.

 I've posted this to the R Help mailing list
 http://news.gmane.org/gmane.comp.lang.r.general and to stackoverflow
 at
 http://stackoverflow.com/questions/29759928/how-numerical-data-is-stored-
 inside-ts-time-series-objects.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] feature selection

2015-04-20 Thread Rolf Turner

On 21/04/15 05:19, ismail hakkı sonalcan wrote:

Hi,

I want to make feature selection.
Could you help me.

Thanks.


This posting should win some sort of prize for inanity.

cheers,

Rolf Turner

--
Rolf Turner
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619

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

Re: [R] high density plots using lattice dotplot()

2015-04-20 Thread Duncan Mackay
Hi Luigi

Strips take up space so if you are willing to not have strip and put the
strip values within the plot area then

  xyplot(y ~ x|cond.factor, data = ...,
 as.table = T,
 groups   = ...,
 layout   = ...,
 drop.unused = T,
 par.settings = list(axis.text = list(cex = 0.6),
 par.xlab.text = list(cex = 0.75),
 par.ylab.text = list(cex = 0.75)
 superpose.symbol = list(pch = ., cex = 2)
),
 strip= FALSE,
 scales   = list(x = list(alternating = 2),
 y = list(alternating = FALSE)
 ),
 type = p,
 panel = function(x,y, subscripts, groups,...){
panel.superpose(x,y,subscripts,groups,...,
col = ...)
panel.text(x,y,...,cex = 0.6)
}
  )

if the text values are a vector
  stext = ...
  xyplot(y ~ x|cond.factor, data = ...,
 as.table = T,
 groups   = ...,
 layout   = ...,
 drop.unused = T,
 par.settings = list(axis.text = list(cex = 0.6),
 par.xlab.text = list(cex = 0.75),
 par.ylab.text = list(cex = 0.75)
 superpose.symbol = list(pch = ., cex = 2)
),
 strip= FALSE,
 scales   = list(x = list(alternating = 2),
 y = list(alternating = FALSE)
 ),
 type = p,
 panel = function(x,y, subscripts, groups,...){
   pnl = panel.number()
panel.superpose(x,y,subscripts,groups,...,
col = ...)
panel.text(x,y,stext[pnl],cex = 0.6)
}
  )

you could also you group.number instead of pnl if it is needed elsewhere.
text position could be done in a similar fashion if needed to be in
different places for some panels.

If you require the strip then an additional par.settings is
layout.heights = list(strip = 0.8)
or even untested in this situation
strip = FALSE
strip.left  = TRUE

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
Marongiu
Sent: Sunday, 19 April 2015 19:28
To: r-help
Subject: [R] high density plots using lattice dotplot()

Dear all,
I am trying to plot the results of a PCR experiments that involves 384
individual plots. Admittedly the space for the plots will be tiny, but
I just nedd some icon to have a feeling of the layout of the
experiment and a quick comparison of the plots.
I believe that lattice would be the right tool, but when I tried to
implement i got an error. Specifically the output would be a A4 pdf,
so with about 600 cm2 of drawing space, which gives about 1.5 cm2 for
each plot; removing the labels that might just work.
So I have the y values = 'fluorescence', x 'values' = cycles and 384
'well' data. I implemented to begin with:

xyplot(fluorescence ~ cycles | well,
 ylab=Fluorescence,
 xlab=Cycles,
 main=list(draw = FALSE),
 scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
 layout = c(24,16),
 par.settings = list(strip.background=list(col=white)),
 pch = .
  )

but the  the individual graphs show only the writing data instead of
the actual plots.
How can I overcome this error?
Thank you
Best regards
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Metafor - rma.mv function - variance components

2015-04-20 Thread Lists
Carlijn Wibbelink wibbelt...@hotmail.com wrote :

Dear Carlijn
I think that if you set sigma2 to a vector of length 2 it will be possible.

 Hi all,
 
 I have a question about metafor and the rma.mv function. I have fitted a
 multivariate model (effect sizes are nested within studies) and I've found two
 variances: 
 
 Variance Components: 
   estimsqrt nlvls  fixed  factor
 sigma^2.1  0.0257  0.1602 72 no   y
 sigma^2.2  0.0694  0.2635 10 no  ID 
 
 I want to test whether there is significant variantion between the effect 
 sizes
 within studies (sigma^2.1: 0.0257) and/or between studies (sigma^2.2: 0.0694).
 In metaSEM you can fix for example the variance within studies (sigma^2.1) to
 zero to test whether there is a significant difference in fit between the 
 models
 (and if so, then there is significant heterogeneity between the effect sizes
 within studies). I was wondering if this is also possible in metafor. If I fix
 sigma2 to zero, then both variances are fixed to zero. However, I want to fix
 only one variance to zero. 
 I hope that someone can help me. Thank you in advance!
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org
 mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] xtractomatic package

2015-04-20 Thread Michael Sumner
Wow, thank you! This is a very important contribution to our research
community.

Cheers,  Mike

On Sun, 19 Apr 2015 02:58 Roy Mendelssohn - NOAA Federal 
roy.mendelss...@noaa.gov wrote:

 xtractomatic R package for accessing environmental data

 xtractomatic is an R package developed to subset and extract satellite and
 other oceanographic related data from a remote server. The program can
 extract data for a moving point in time along a user-supplied set of
 longitude, latitude and time points; in a 3D bounding box; or within a
 polygon (through time). The xtractomatic functions were originally
 developed for the marine biology tagging community, to match up
 environmental data available from satellites (sea-surface temperature,
 sea-surface chlorophyll, sea-surface height, sea-surface salinity, vector
 winds) to track data from various tagged animals or shiptracks (xtracto).
 The package has since been extended to include the routines that extract
 data a 3D bounding box (xtracto_3D) or within a polygon (xtractogon). The
 xtractomatic package accesses data that are served through the ERDDAP
 (Environmental Research Division Data Access Program) server at the
 NOAA/SWFSC Environmental Research Division in Santa Cruz, California!
  . The ERDDAP server can also be directly accessed at
 http://coastwatch.pfeg.noaa.gov/erddap. ERDDAP is a simple to use yet
 powerful web data service developed by Bob Simons.

 At present the package can access well over 100TB of data.  Due to some
 problems with certain required packages and CRAN  (most notably ncdf4)
 xtractomatic at present is only available through Github.  Instructions for
 installation are at:

 https://github.com/rmendels/xtractomatic

 -Roy M.


 **
 The contents of this message do not reflect any position of the U.S.
 Government or NOAA.
 **
 Roy Mendelssohn
 Supervisory Operations Research Analyst
 NOAA/NMFS
 Environmental Research Division
 Southwest Fisheries Science Center
 ***Note new address and phone***
 110 Shaffer Road
 Santa Cruz, CA 95060
 Phone: (831)-420-3666
 Fax: (831) 420-3980
 e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/

 Old age and treachery will overcome youth and skill.
 From those who have been given much, much will be expected
 the arc of the moral universe is long, but it bends toward justice -MLK
 Jr.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] suggestion of regex pattern

2015-04-20 Thread Fernando Gama
Ok, I'll try to do this...

Thanks :D

2015-04-18 18:55 GMT-03:00 Boris Steipe boris.ste...@utoronto.ca:

 Re-reading your question and taking a wild guess, perhaps you are looking
 for parse() and eval() ...

 xyz - data.frame( a=c(1,2), b=c(3,4))
 xyz

   a b
 1 1 3
 2 2 4

 expp - parse(text=xyz$a  1  xyz$b == 4)   # turn a string into an
 expression
 expp

 expression(xyz$a  1  xyz$b == 4)

 xyz[eval(expp), ]  # evaluate an expression in
 place
   a b
 2 2 4

 ... but really, it's just a guess at what you might be trying to do.

 B.




 On Apr 18, 2015, at 1:30 PM, Boris Steipe boris.ste...@utoronto.ca
 wrote:

  Sorry - it's not entirely clear to me what you need to do.
 
  See here for some hints on how to ask questions on this list. I'm sure
 we'll be able to help quickly.
  http://adv-r.had.co.nz/Reproducibility.html
 
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
  (and don't post in HTML   :-)
 
 
  B.
 
  On Apr 18, 2015, at 11:10 AM, Fernando Gama f.fabiogam...@gmail.com
 wrote:
 
  Hello Boris,
 
  thanks for your response.
 
  So, firstly considered that  i've been input a set of serches strings
 (.txt format) and i'm using regex to transform in a suitable  format to my
 script. This part is a final part of my code and i wish putting in input to
 a subset.
 
  (.txt formatted)
 
   STRINGS (INPUT)
 
  [1]  municipio =='Limeira' 
  [2]  municipio =='Limeira'  mesincident =='marco' 
  [3]  ​municipio =='Limeira'  mesincident =='marco'  trechoklmetros 
 1.00 12.300
  ...
  ..
  ..
  ..
  [n] ..
 
  --
 
  desired_fomart - ​it will reveice all strings to filter in a dataset
 by subset below:
 
 
  a loop each line:
 
  subset(dataset_read, desired_fomart[i])
 
  My question: taking into consideration this cenario, in your oppinion
 your reply is my suitable for my problem, whereas i will to map each value
 in database?
 
  Once again, thank so much! :)
 
  2015-04-18 11:04 GMT-03:00 Boris Steipe boris.ste...@utoronto.ca:
  This is not a regular expression but simply a conjunction (sequence of
 '') of logical expressions. Moreover it's not wrong. Consider:
 
  xyz - data.frame(municipio = c('Limeira'), mesincident = c('marco'),
 trechoklmetros = c(3.00, -4.00, 30))
  xyz
 
   municipio mesincident trechoklmetros
  1   Limeira   marco  3
  2   Limeira   marco -4
  3   Limeira   marco 30
 
 
  xyz$municipio =='Limeira'  xyz$mesincident =='marco' 
 xyz$trechoklmetros  1.00
  [1]  TRUE FALSE  TRUE
 
  xyz$municipio =='Limeira'  xyz$mesincident =='marco' 
 xyz$trechoklmetros  1.00  xyz$trechoklmetros = 12.3
  [1]  TRUE FALSE FALSE
 
 
  If there's a problem it seems to be elsewhere.
  Cheers,
  Boris
 
 
  On Apr 17, 2015, at 4:22 PM, Fernando Gama f.fabiogam...@gmail.com
 wrote:
 
  Hello,
 
  I have benn problems to construct the pattern for this:
 
  municipio =='Limeira'  mesincident =='marco'  trechoklmetros  1.00
 12.300
 
  I would like:
 
  municipio =='Limeira'  mesincident =='marco'  trechoklmetros  1.00
  * **trechoklmetros
  = *12.300
  ​
  ​Any suggestion?​
 
 
  --
  Att,
 
  Fernando Gama da Mata
 
   [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Att,
 
  Fernando Gama da Mata
 
 
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.




-- 
Att,

Fernando Gama da Mata

Vale of Institute Technology

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Fwd: REngine hangs when called within java code

2015-04-20 Thread aruni karunarathne
Dear All,

I fixed my issue.

 String newargs1[] = {--no-save};

Rengine r1 = Rengine.getMainEngine();
   if (r1 == null) {
   r1 = new Rengine(newargs1, false, null);
   }

i added/modified the above part when setting up the rengine.
Somehow, now it works.
may be that in the previous coding, one instance of rengine do not
really end.hence it hangs when it comes to another instance.

Many thanks.


-- Forwarded message --
From: aruni karunarathne arunikarunarat...@gmail.com
Date: Wed, Apr 15, 2015 at 11:17 PM
Subject: REngine hangs when called within java code
To: r-help@r-project.org


Dear All,

I'm creating a project which uses both java and R.

I created the java class named MyClass and within that wrote two
separate methods (graphing1() and fitness()) to call the r scripts.

public void graphing1() throws IOException {

String newargs1[] = {--no-save};

Rengine r1 = new Rengine(newargs1, false, null);

r1.eval(source('test2.R'));

r1.end();

}



public void fitness() throws IOException {

String newargs1[] = {--no-save};

Rengine r3 = new Rengine(newargs1, false, null);

r3.eval(source('A.R'));

r3.eval(source('B.R'));

r3.end();

}

Both of the above methods are in java class MyClass.

From another class in the same project for which I created a gui, I
accessed the fitness() function and it worked fine. But when I try to
call the graphing1() function it did not work. (both were called
through the gui) The programme hangs at ;

Rengine r1 = new Rengine(newargs1, false, null);

without any notification. In both instances I called the function as follows:

1st instance:

MyClass test=new MyClass();

test.fitness() ;

2nd instance:

MyClass test1 = new MyClass();

test1.graphing1();



All the 3 scripts are coded to create png files. test2.R and A.R
scripts use the ROCR library and B.R do not use any. All the 3 files
end with dev.off() statement.

I have installed R 3.1.3. I’m using netbeans as the editor and working
in windows environment.

The 3 scripts work fine when executed in R environment. The issue
arises when it’s called from the java code.

I'm a student who is new to R and was struggling to solve this issue
for several weeks. Your help is greatly appreciated.

Thanks in advance.


REngine hangs when called within java code -- problem.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] erv.inv NOT FOUND

2015-04-20 Thread Prof Brian Ripley

On 20/04/2015 13:15, CHIRIBOGA Xavier wrote:

Dear members, in this case

Error: could not find function erf.inv

Anyone knows the package?


See ?pnorm for a definition of erfinv, which also exists in package 
pracma.  'erf.inv' is not in any of the packages I have installed (which 
includes all of CRAN).


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

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


Re: [R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

2015-04-20 Thread Miloš Žarković
Do you have 64-bit Java installed?

Regards
Miloš


On Saturday, April 18, 2015, John Sorkin jsor...@grecc.umaryland.edu
wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103


 I am having difficulty loading and installing the xlsx package. The
 loading occurred without any problem, however the library command
 library(xlsx) produced an error related to rJava. I tried to install
 rJava seperately, re-loaded the xlsx package, and entered the
 library(xlsx) command but received the same error message about rJave.
 Please see terminal messages below. Any suggestion that would allow me
 to load and run xlsx would be appreciated.
 Thank you,
 John


  install.packages(xlsx)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/xlsx_0.5.7.zip'
 Content type 'application/zip' length 400944 bytes (391 KB)
 opened URL
 downloaded 391 KB


 package ‘xlsx’ successfully unpacked and MD5 sums checked


 The downloaded binary packages are in
 C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
  library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package ‘rJava’ could not be loaded
  install.packages(rJava)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/rJava_0.9-6.zip'
 Content type 'application/zip' length 759396 bytes (741 KB)
 opened URL
 downloaded 741 KB


 package ‘rJava’ successfully unpacked and MD5 sums checked


 The downloaded binary packages are in
 C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
  library(rJava)
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package or namespace load failed for ‘rJava’
  library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package ‘rJava’ could not be loaded


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of
 the intended recipient(s) and may contain confidential and privileged
 information. Any unauthorized use, disclosure or distribution is
 prohibited. If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
 __
 R-help@r-project.org javascript:; mailing list -- To UNSUBSCRIBE and
 more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] ABOUT STATS FORUM

2015-04-20 Thread Boris Steipe
Cross Validated at http://stats.stackexchange.com/

B.



On Apr 19, 2015, at 10:37 AM, CHIRIBOGA Xavier xavier.chirib...@unine.ch 
wrote:

 Dear members,
 
 
 
 Since this is not a Forum for Stats questions...does anyone can recomend me a 
 good forum to post questions about statistics?
 
 
 
 Thank you for info,
 
 
 
 Xavier
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RODBC did not found

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 5:59 AM, CHIRIBOGA Xavier xavier.chirib...@unine.ch
 wrote:

 Dear members,

 What can I do if I get this message: ?

 library(RODBC)
 Error in library(RODBC) : aucun package nommé ‘RODBC’ n'est trouvé

 Thanks in advcance,

 Xavier


​If I understand the message correctly, it is saying that the RODBC package
is not found, just as you said in the subject. That either means that you
have not installed it, or it is not on the library path. Perhaps the
simplest thing to try is to reinstall the RODBC package with the R
statement:

install.packages('RODBC')

then try again. If you need more help, you might want to post the output
from the commands: Sys.info() and .libPaths() and the value of the .Library
variable​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] erv.inv NOT FOUND

2015-04-20 Thread CHIRIBOGA Xavier
Dear members, in this case



Error: could not find function erf.inv



Anyone knows the package?

Thanks a lot!



Xavier

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


Re: [R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

2015-04-20 Thread Rainer Hurling
Hi John,

Am 18.04.2015 um 22:07 schrieb John Sorkin:
 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103
 
 
 I am having difficulty loading and installing the xlsx package. The
 loading occurred without any problem, however the library command
 library(xlsx) produced an error related to rJava. I tried to install
 rJava seperately, re-loaded the xlsx package, and entered the
 library(xlsx) command but received the same error message about rJave.
 Please see terminal messages below. Any suggestion that would allow me
 to load and run xlsx would be appreciated.
 Thank you,
 John
 
 
 install.packages(xlsx)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/xlsx_0.5.7.zip'
 Content type 'application/zip' length 400944 bytes (391 KB)
 opened URL
 downloaded 391 KB
 
 
 package ‘xlsx’ successfully unpacked and MD5 sums checked
 
 
 The downloaded binary packages are in
   C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
 library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.
 
 
 Error: package ‘rJava’ could not be loaded
 install.packages(rJava)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/rJava_0.9-6.zip'
 Content type 'application/zip' length 759396 bytes (741 KB)
 opened URL
 downloaded 741 KB
 
 
 package ‘rJava’ successfully unpacked and MD5 sums checked
 
 
 The downloaded binary packages are in
   C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
 library(rJava)
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.
 
 
 Error: package or namespace load failed for ‘rJava’
 library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.
 
 
 Error: package ‘rJava’ could not be loaded

There are several possibilities, why your rJava does not find rJava.dll.
A good start give [1] to [3].

Did you have the right installation of JAVA itself?

I think, in your case, the JAVA installation itself should be the 64bit
version, and probably better version 1.8 than 1.7 [3] (someone please
correct me, if I am wrong here).

You get some hints about parameters with
R CMD javareconf --help

HTH.
Regards,
Rainer Hurling


[1]
http://cran.at.r-project.org/doc/manuals/r-release/R-admin.html#Java-support
[2]
http://cran.at.r-project.org/bin/windows/base/rw-FAQ.html#Loading-a-package-fails_002e
[3]
http://stackoverflow.com/questions/7019912/using-the-rjava-package-on-win7-64-bit-with-r


 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)

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

Re: [R] basic q re: parsing functions, declaration order

2015-04-20 Thread J Robertson-Burns

On 18/04/2015 18:14, Gowder, Paul wrote:

Hi there,

So I’m doing some serious coding in R for the first time—writing a strategic 
simulation to run for a few (or many) thousand iterations,* and doing so in 
proper functional programming form,


[...]


   write.table(results, file=simul_results.csv, row.names=TRUE, col.names=TRUE, 
sep=,”)
# bonus question: there’s probably a vastly more efficient way to do this final 
write, any suggestions welcomed


Unless your results are massive, this is not worth
worrying about.


}



[...]

  


I’m just putting it all in one source file, which I plan to load using source(), 
and then actual execution will be via console input  simulate.strat(number of 
runs), leave town for the weekend, hopefully come back to find a csv with a bunch 
of results.

But I’m not quite sure how the parser works with respect to defining all these 
functions.  Do I have to define them from inside out like one would in python?  
(So, on the code above, that would mean defining, say, dist.goods() and 
dist.power() first, then outer.wrapper(), then simulate.strat().)  Or is there 
a way to prototype them like one would in C?  Or--- and I really hope this is 
the answer so I don’t have untangle the tangled web of functions I’m writing— 
is R smart enough/lazy enough to accept that the function defined at line K can 
call a function defined at line K+N and not stress about it?


Yes.  Functions just need to be defined at the
time they are used.



thanks so much!  My google-fu is failing me on this one.

-Paul


* why on earth, you might ask, am I doing this in R, rather than C or 
something?  Because I have a ton of computing resources and a huge workload. 
CPU time is cheap and my time is expensive…


Correct.  Not a line of thinking that you are
likely to need to defend among this crowd.

An answer to the question that you didn't ask is:

http://www.burns-stat.com/documents/books/the-r-inferno/

That question is:  Where do I look when I discover
it isn't doing what I intend it to do?

Pat


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 using by, Error in tapply(response, list(x.factor, trace.factor), fun) : argument trace.factor is missing, with no default

2015-04-20 Thread John Sorkin


I am receiving an error message from the by function that I don't understand:
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument trace.factor is missing, with no default



My code follows:


 summary(ipd)
 group  valuestime  subjects weaned disp  
 1:55   Min.   :0.   Min.   :0   Min.   :115.0   1:65   2:45  
 2:35   1st Qu.:0.1950   1st Qu.:1   1st Qu.:121.0   2:25   3: 5  
Median :0.3400   Median :2   Median :126.0  4:20  
Mean   :0.3479   Mean   :2   Mean   :127.6  5:20  
3rd Qu.:0.5000   3rd Qu.:3   3rd Qu.:134.0
Max.   :0.7300   Max.   :4   Max.   :144.0
NA's   :48
 by(ipd[,c(time,subjects,values)],ipd[,group],interaction.plot)
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument trace.factor is missing, with no default




These are my data.
 ipd
   group values time subjects weaned disp
1  1   0.000  115  12
2  1   0.001  115  12
3  1   0.182  115  12
4  1   0.173  115  12
5  1 NA4  115  12
6  1   0.620  116  12
7  1 NA1  116  12
8  1 NA2  116  12
9  1 NA3  116  12
10 1 NA4  116  12
11 1   0.000  118  12
12 1   0.211  118  12
13 1   0.342  118  12
14 1   0.493  118  12
15 1 NA4  118  12
16 2   0.520  119  24
17 2 NA1  119  24
18 2 NA2  119  24
19 2 NA3  119  24
20 2 NA4  119  24
21 2   0.350  121  23
22 2   0.531  121  23
23 2   0.352  121  23
24 2   0.443  121  23
25 2   0.564  121  23
26 1   0.160  122  15
27 1   0.221  122  15
28 1 NA2  122  15
29 1 NA3  122  15
30 1 NA4  122  15
31 1   0.190  123  25
32 1 NA1  123  25
33 1 NA2  123  25
34 1 NA3  123  25
35 1 NA4  123  25
36 2   0.290  124  14
37 2   0.221  124  14
38 2 NA2  124  14
39 2 NA3  124  14
40 2 NA4  124  14
41 1   0.380  125  14
42 1   0.451  125  14
43 1 NA2  125  14
44 1 NA3  125  14
45 1 NA4  125  14
46 1   0.220  127  12
47 1   0.371  127  12
48 1   0.282  127  12
49 1   0.503  127  12
50 1 NA4  127  12
51 1   0.300  130  12
52 1   0.491  130  12
53 1 NA2  130  12
54 1 NA3  130  12
55 1 NA4  130  12
56 1   0.700  131  12
57 1 NA1  131  12
58 1 NA2  131  12
59 1 NA3  131  12
60 1 NA4  131  12
61 2   0.000  133  12
62 2   0.501  133  12
63 2   0.562  133  12
64 2   0.733  133  12
65 2 NA4  133  12
66 1   0.220  134  12
67 1   0.651  134  12
68 1 NA2  134  12
69 1 NA3  134  12
70 1 NA4  134  12
71 2   0.340  135  12
72 2   0.731  135  12
73 2   0.712  135  12
74 2 NA3  135  12
75 2 NA4  135  12
76 2   0.260  139  25
77 2 NA1  139  25
78 2 NA2  139  25
79 2 NA3  139  25
80 2 NA4  139  25
81 1   0.000  140  15
82 1   0.191  140  15
83 1 NA2  140  15
84 1 NA3  140  15
85 1 NA4  140  15
86 2   0.190  144  24
87 2 NA1  144  24
88 2 NA2  144  24
89 2 NA3  144  24
90 2 NA4  144  24


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA 

Re: [R-es] Como leer una BD con una estructura inadecuada

2015-04-20 Thread Carlos Ortega
Hola Eric,

He probado el nuevo paquete de Hadley Wickham para leer ficheros, como
alternativa al read.table() y parece que funciona:

 library(readr)
 datIn - read_table(cdb.txt)
 head(datIn)
  ID Number Name Fed Sex Tit WTit OTit SRtng SGm SK
RRtng RGm Rk BRtng BGm BK B-day Flag
1  14319110   Van Der Walt, Dina RSA   F  NA   NA   NANA  NA
NANA  NA NANA  NA NA 0w
2  10218181 (mastar Marine), Asaduzzaman BAN   M  NA   NA   NANA  NA
NANA  NA NANA  NA NA  1969
3  13802860 .Sultanov Zhamalidin KGZ   M  NA   NA   NANA  NA
NANA  NA NANA  NA NA  2008
4   5700230  A B, Muhammad Yusop MAS   M  NA   NA   NANA  NA
NANA  NA NANA  NA NA 0
5  35077023   A Chakravarthy IND   M  NA   NA   NA  1151   0
40NA  NA NANA  NA NA  1986
6  10207538 A E M, Doshtagir BAN   M  NA   NA   NA  1840   0
40  1836   0 20  1860   0 20  1974

Saludos,
Carlos Ortega
www.qualityexcellence.es



El 19 de abril de 2015, 1:03, eric ericconchamu...@gmail.com escribió:

 Estimados, tengo el siguiente problema:

 Tengo una BD de 19 columnas y aprox 500 mil filas, la que tiene muchas
 celdas vacias y esta separada con espacios para hacer coincidir los datos
 bajo los encabezados.

 Mi problema es que al tratar de importar a R la BD no se como tratar con
 los espacios vacios cuando se trata de una columna de numeros (para el
 texto puse na.strings = NA) y tampoco se como hacer para que al leer cada
 dato este asociado al encabezado correcto, pues el numero de espacios que
 esta puesto entre cada dato varia de acuerdo a la extension en caracteres
 del dato (hay numeros, nombres, etc). Incluso hay encabezados de dos
 palabras y parece que R los considera dos encabezados distintos. Me explico
 ?

 Como puedo hacer para leer la BD correctamente ? Alguna idea ??

 Adjunto un archivo de muestra.

 Muchas gracias.

 Eric.




 --
 Forest Engineer
 Master in Environmental and Natural Resource Economics
 Ph.D. student in Sciences of Natural Resources at La Frontera University
 Member in AguaDeTemu2030, citizen movement for Temuco with green city
 standards for living

 Nota: Las tildes se han omitido para asegurar compatibilidad con algunos
 lectores de correo.

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es




-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread William Dunlap
Look more at help(rep) and help(seq):
n - 7
rep(seq_len(n), each=4)
[1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Sun, Apr 19, 2015 at 6:44 AM, John Sorkin jsor...@grecc.umaryland.edu
wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103


 I am trying to generate a list of  length 4n which consists of the
 integers 1 to n repeated in groups of four, i.e.

 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

 (The spaces in the list are added only for clarity.)

  I can generate the list as follows, but the code must be modified for any
 value n, and the code is UGLY!

 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

 Can anyone help me?

 Thank you,
 John

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Confidentiality Statement:
 This email message, including any attachments, is for the sole use of the
 intended recipient(s) and may contain confidential and privileged
 information. Any unauthorized use, disclosure or distribution is
 prohibited. If you are not the intended recipient, please contact the
 sender by reply email and destroy all copies of the original message.
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Predict in glmnet for cox family

2015-04-20 Thread jitvis
Dear All, 

I am in some difficulty with predicting 'expected time of survival' for each
observation for a glmnet cox family with LASSO. 

I have two dataset 5 * 450 (obs * Var) and 8000 * 450 (obs * var), I
considered first one as train and second one as test. 

I got the predict output and I am bit lost here,   

pre - predict(fit,type=response, newx =selectedVar[1:20,]) 

 s0 
1  0.9454985 
2  0.6684135   
3  0.5941740 
4  0.5241938 
5  0.5376783 

This is the output I am getting - I understood with type response gives
the fitted relative-risk for cox family. 

I would like to know how I can convert it or change the fitted relative-risk
to 'expected time of survival' ? 

Any help would be great, thanks for all your time and effort.

Sincerely,



--
View this message in context: 
http://r.789695.n4.nabble.com/Predict-in-glmnet-for-cox-family-tp4706070.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Two stage cluster in R(two step in spss), which package implement it ?

2015-04-20 Thread PO SU

Dear, expeRts,
  I am confused in finding an implementation of two stage cluster in R(which is 
two step cluster in spss), i do some searching, but still can not find it. Has 
someone happen to know it ?






--

PO SU
mail: desolato...@163.com 
Majored in Statistics from SJTU
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] list server problem?

2015-04-20 Thread Ivan Calandra

Dear all,

I use Thunderbird 31.6.0 on Mac OS 10.6.8 to download my e-mails.
Since this morning, Thunderbird downloads several times the same e-mails 
from the list, some even being from yesterday. It occurs only with 
e-mails from the R-help and not with my other professional and private 
e-mails.


I also checked that it was not a problem with the server on which I get 
e-mails from the R-help: the problematic e-mails are erased every time 
from the server but are received several times. So I would say that the 
R-help server has sent these e-mails several times.


I am wondering if there is currently an issue with the R-help server. Is 
someone else having the same problem?


Thanks!
Ivan

--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

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


Re: [R-es] Como leer una BD con una estructura inadecuada

2015-04-20 Thread Javier Marcuzzi
Estimado Eric

¿Cuál es el que necesita? Mire la página que usted dice, pero los archivos
no son de 70 mb o 180 mb. Hay otras opciones pero se me ocurrió pasarlo a
 mysql o sqlite y enviarle los datos en sql. Aunque si logra usar xml, o
como leí utilizando más especificaciónes con read.fwf el inconveniente se
solucionaría.

Aunque puede haber un problema, y es con la memoria, al respecto podría
procesar de la forma que más fácil le resulte, pero por partes (archivos) y
guardar el resultado del data.frame en el disco, borrar la memoria de R,
procesar la siguiente parte, y luego unir todos los archivos que guardo en
el disco.

Si tiene inconvenientes, yo no tendía problemas en pasar todo a sql y usted
luego lo importa.

Javier Marcuzzi

El 19 de abril de 2015, 0:37, eric ericconchamu...@gmail.com escribió:

 Estimado Javier:

 Disculpe mi imprecision al hablar de base de datos en este caso, en
 realidad es un conjunto interesante de datos pero no tiene exactamente
 estandar de BD .. en fin ... este conjunto de datos lo baje directamente de
 la pagina de la FIDE, que es la federacion internacional de ajedrez, en
 http://ratings.fide.com/download.phtml, es decir, estos datos son la BD
 original.

 Los datos se ofrecen en formato .txt, que es como yo los baje (70 MB), y
 en formato XML. que tambien lo baje, pero el archivo pesa alrededor de 180
 megas y se vuelve inmanejable con mi modesto portatil. Ni siquiera es
 posible visualizar los datos. Por esto use el archivo .txt para trate de
 importarlo en R y tuve los problemas que ya señale.

 Pense por un momento en que quiza seria posible reemplazar un conjunto de
 puntos de cualquier largo por un \tab o algo asi, pero al tener casillas
 vacias se pierde el orden de los datos. Es decir, si un dato corresponde a
 la ultima columna y todas las anteriores estan vacias, al final de la
 sustitucion quedara asociado a la primera columna. Al no haber patrones es
 dificil corregir la estructura del archivo de forma automatica y son
 demiados datos para intentar siquiera algo a manos.

 Esa es la situacion mas o menos.

 Alguna idea ??

 Saludos y gracias,

 Eric.







 On 18/04/15 22:45, Javier Marcuzzi wrote:

 Estimado Eric Concha

 Como usted dice, hay un problema, yo encontré inconvenientes al intentar
 importar los datos que usted suministro. Pero se me ocurre una pregunta
 ¿tiene usted acceso a la base de datos original? Porque si tiene acceso
 hay dos posibilidades, el acceso real donde usted puede (depende que DB)
 usar la parte de R para esa base de datos en particular, o si tiene
 acceso pero por medio de otra persona, podría solicitar una consulta sql
 de acuerdo a sus requerimientos y guardar los datos como a usted le
 convenga. Otra posibilidad es preguntar si en lugar de un archivo txt
 puede recibirlo en json, o sql (¿excel?), csv es bueno pero puede ser
 que se presente algún problema (no es tan seguro como los anteriores),
 pensando en que usted use otra base de datos.

 Javier Marcuzzi

 El 18 de abril de 2015, 20:03, eric ericconchamu...@gmail.com
 mailto:ericconchamu...@gmail.com escribió:


 Estimados, tengo el siguiente problema:

 Tengo una BD de 19 columnas y aprox 500 mil filas, la que tiene
 muchas celdas vacias y esta separada con espacios para hacer
 coincidir los datos bajo los encabezados.

 Mi problema es que al tratar de importar a R la BD no se como tratar
 con los espacios vacios cuando se trata de una columna de numeros
 (para el texto puse na.strings = NA) y tampoco se como hacer para
 que al leer cada dato este asociado al encabezado correcto, pues el
 numero de espacios que esta puesto entre cada dato varia de acuerdo
 a la extension en caracteres del dato (hay numeros, nombres, etc).
 Incluso hay encabezados de dos palabras y parece que R los considera
 dos encabezados distintos. Me explico ?

 Como puedo hacer para leer la BD correctamente ? Alguna idea ??

 Adjunto un archivo de muestra.

 Muchas gracias.

 Eric.




 --
 Forest Engineer
 Master in Environmental and Natural Resource Economics
 Ph.D. student in Sciences of Natural Resources at La Frontera
 University
 Member in AguaDeTemu2030, citizen movement for Temuco with green
 city standards for living

 Nota: Las tildes se han omitido para asegurar compatibilidad con
 algunos lectores de correo.

 ___
 R-help-es mailing list
 R-help-es@r-project.org mailto:R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es



 --
 Forest Engineer
 Master in Environmental and Natural Resource Economics
 Ph.D. student in Sciences of Natural Resources at La Frontera University
 Member in AguaDeTemu2030, citizen movement for Temuco with green city
 standards for living

 Nota: Las tildes se han omitido para asegurar compatibilidad con algunos
 lectores de correo.

___

Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Rmh
rep(1:n, each=4)

Sent from my iPhone

 On Apr 19, 2015, at 09:44, John Sorkin jsor...@grecc.umaryland.edu wrote:
 
 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103
 
 
 I am trying to generate a list of  length 4n which consists of the integers 1 
 to n repeated in groups of four, i.e.
 
 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n
 
 (The spaces in the list are added only for clarity.)
 
 I can generate the list as follows, but the code must be modified for any 
 value n, and the code is UGLY!
 
 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))
 
 Can anyone help me?
 
 Thank you,
 John
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:12}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] ABOUT STATS FORUM

2015-04-20 Thread CHIRIBOGA Xavier
Dear members,



Since this is not a Forum for Stats questions...does anyone can recomend me a 
good forum to post questions about statistics?



Thank you for info,



Xavier

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Sven E. Templer
In '?rep' find out about the 'each' argument.
Also there is the function 'gl' which creates a factor and offers a shorter
syntax for your problem.

If n equals 5 use one of:

rep(seq(5), each = 4)
gl(5,4)

On 19 April 2015 at 15:44, John Sorkin jsor...@grecc.umaryland.edu wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103


 I am trying to generate a list of  length 4n which consists of the
 integers 1 to n repeated in groups of four, i.e.

 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

 (The spaces in the list are added only for clarity.)

  I can generate the list as follows, but the code must be modified for any
 value n, and the code is UGLY!

 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

 Can anyone help me?

 Thank you,
 John

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:16}}

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


Re: [R-es] Como leer una BD con una estructura inadecuada

2015-04-20 Thread Javier Marcuzzi
Eric y Carlos

No recibí la sugerencia de Carlos, me gustaría poder leerla porque
personalmente prefiero json o xml sobre csv, porque tiene un cuidado
mayor sobre los datos aunque incrementa el tamaño del archivo.

Javier Marcuzzi

El 19 de abril de 2015, 21:27, Eric ericconchamu...@gmail.com escribió:

 Muchas gracias Jose Luis, Carlos y Javier ... probe la libreria sugerida
 por Carlos y me sorprendio lo rapido que se cargaron los 77.2 MB comparado
 con el formato XML, le tomo apenas unos 10 segundos, luego pase el
 data.frame a data.table y todo funciona muy rapido. La libreria que
 recomienda Carlos de alguna identifico correctamente la columna que
 corresponde a cada dato y todo siguio impecable, solo hay que tener la
 precaucion de que los encabezados no sean de dos palabras ni usen como
 separador el signo menos, porque entonces R piensa que es una resta.

 Javier, los archivos en la pagina de la FIDE estan comprimidos, por eso
 aparecen con un tamaño notablemente menor.

 Muchas gracias a todos por su rapida y efectiva ayuda.

 Saludos, Eric..



 2015-04-19 11:55 GMT-03:00 Javier Marcuzzi 
 javier.ruben.marcu...@gmail.com:

 Estimado Eric

 ¿Cuál es el que necesita? Mire la página que usted dice, pero los
 archivos no son de 70 mb o 180 mb. Hay otras opciones pero se me ocurrió
 pasarlo a  mysql o sqlite y enviarle los datos en sql. Aunque si logra usar
 xml, o como leí utilizando más especificaciónes con read.fwf el
 inconveniente se solucionaría.

 Aunque puede haber un problema, y es con la memoria, al respecto podría
 procesar de la forma que más fácil le resulte, pero por partes (archivos) y
 guardar el resultado del data.frame en el disco, borrar la memoria de R,
 procesar la siguiente parte, y luego unir todos los archivos que guardo en
 el disco.

 Si tiene inconvenientes, yo no tendía problemas en pasar todo a sql y
 usted luego lo importa.

 Javier Marcuzzi

 El 19 de abril de 2015, 0:37, eric ericconchamu...@gmail.com escribió:

 Estimado Javier:

 Disculpe mi imprecision al hablar de base de datos en este caso, en
 realidad es un conjunto interesante de datos pero no tiene exactamente
 estandar de BD .. en fin ... este conjunto de datos lo baje directamente de
 la pagina de la FIDE, que es la federacion internacional de ajedrez, en
 http://ratings.fide.com/download.phtml, es decir, estos datos son la BD
 original.

 Los datos se ofrecen en formato .txt, que es como yo los baje (70 MB), y
 en formato XML. que tambien lo baje, pero el archivo pesa alrededor de 180
 megas y se vuelve inmanejable con mi modesto portatil. Ni siquiera es
 posible visualizar los datos. Por esto use el archivo .txt para trate de
 importarlo en R y tuve los problemas que ya señale.

 Pense por un momento en que quiza seria posible reemplazar un conjunto
 de puntos de cualquier largo por un \tab o algo asi, pero al tener casillas
 vacias se pierde el orden de los datos. Es decir, si un dato corresponde a
 la ultima columna y todas las anteriores estan vacias, al final de la
 sustitucion quedara asociado a la primera columna. Al no haber patrones es
 dificil corregir la estructura del archivo de forma automatica y son
 demiados datos para intentar siquiera algo a manos.

 Esa es la situacion mas o menos.

 Alguna idea ??

 Saludos y gracias,

 Eric.







 On 18/04/15 22:45, Javier Marcuzzi wrote:

 Estimado Eric Concha

 Como usted dice, hay un problema, yo encontré inconvenientes al intentar
 importar los datos que usted suministro. Pero se me ocurre una pregunta
 ¿tiene usted acceso a la base de datos original? Porque si tiene acceso
 hay dos posibilidades, el acceso real donde usted puede (depende que DB)
 usar la parte de R para esa base de datos en particular, o si tiene
 acceso pero por medio de otra persona, podría solicitar una consulta sql
 de acuerdo a sus requerimientos y guardar los datos como a usted le
 convenga. Otra posibilidad es preguntar si en lugar de un archivo txt
 puede recibirlo en json, o sql (¿excel?), csv es bueno pero puede ser
 que se presente algún problema (no es tan seguro como los anteriores),
 pensando en que usted use otra base de datos.

 Javier Marcuzzi

 El 18 de abril de 2015, 20:03, eric ericconchamu...@gmail.com
 mailto:ericconchamu...@gmail.com escribió:


 Estimados, tengo el siguiente problema:

 Tengo una BD de 19 columnas y aprox 500 mil filas, la que tiene
 muchas celdas vacias y esta separada con espacios para hacer
 coincidir los datos bajo los encabezados.

 Mi problema es que al tratar de importar a R la BD no se como tratar
 con los espacios vacios cuando se trata de una columna de numeros
 (para el texto puse na.strings = NA) y tampoco se como hacer para
 que al leer cada dato este asociado al encabezado correcto, pues el
 numero de espacios que esta puesto entre cada dato varia de acuerdo
 a la extension en caracteres del dato (hay numeros, nombres, etc).
 Incluso hay encabezados de dos palabras y parece que R los 

[R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] RODBC package not found (in English)

2015-04-20 Thread CHIRIBOGA Xavier
Dear members,



What can I do if I get this message: ?



library(RODBC)
Error in library(RODBC) : any package called ‘RODBC’ was found





Thanks in advcance,



Xavier

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


Re: [R] RODBC package not found (in English)

2015-04-20 Thread Duncan Murdoch
On 20/04/2015 7:01 AM, CHIRIBOGA Xavier wrote:
 Dear members,
 
 
 
 What can I do if I get this message: ?
 
 
 
 library(RODBC)
 Error in library(RODBC) : any package called ‘RODBC’ was found

That means that you haven't installed it.  You need to run

install.packages(RODBC)

first.  Depending on which platform you're working on, this might fail;
in that case, you'll need to give us more details.

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R code/package for calculation of Wasserstein distance between two densities

2015-04-20 Thread Ranjan Maitra
Dear friends, 

Before reinventing the wheel, I was wondering if anyone can point me to code 
for calculating the Wasserstein distance between two densities. I am 
particularly interested in mixture densities (in functional form). I know that 
we have the earthmovers distance in R via the emdist package but it appears to 
me upon a quick look that this can not handle densities in functional form. So, 
I was wondering if anyone had any ideas on code for this problem. 

Many thanks and best wishes,
Ranjan


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords  protects your account.

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Jeff Newmiller
You are not generating lists, you are generating vectors.

Try

rep( seq.int( n ), each= 4 )
---
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.

On April 19, 2015 6:44:56 AM PDT, John Sorkin jsor...@grecc.umaryland.edu 
wrote:
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the
integers 1 to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

I can generate the list as follows, but the code must be modified for
any value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and
Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for t...{{dropped:12}}

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Ben Tupper

On Apr 19, 2015, at 9:44 AM, John Sorkin jsor...@grecc.umaryland.edu wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103
 
 
 I am trying to generate a list of  length 4n which consists of the integers 1 
 to n repeated in groups of four, i.e.
 
 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n
 

Hi,

Like this?

 x - 1:4
 xx - rep(x, each = 4)
 xx
 [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4

Cheers,
Ben



 (The spaces in the list are added only for clarity.)
 
 I can generate the list as follows, but the code must be modified for any 
 value n, and the code is UGLY!
 
 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))
 
 Can anyone help me?
 
 Thank you,
 John
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:25}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread arnaud gaboury
R 3.2.0 on Linux


library(tidyr)

playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
Portals Visited 1,038,
XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed 11,126,
Links Created 1,744, Control Fields Created 294, Mind Units
Captured 2,995,484 MUs,
Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
Captured 486,
Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
Links Destroyed 3,169,
Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
Max Link Length x Days 276 km-days, Max Time Field Held 4days,
Largest Field MUs x Days 83,226 MU-days)

---
 extract_numeric(playerStats)
 [1] 10 5671448600   1038   15327123
   14268  11126   17442942995484
[10] 75 1897313006364   1204
 486  12481   1240   3169   1394
[19]230240 15 NA
   4 NA


 playerStats[c(22,24)]
[1] Max Link Length x Days 276 km-days  Largest Field MUs x
Days 83,226 MU-days


I do not understand why these two vectors return NA when the function
extract_numeric() works well for others,

Any wrong settings in my env?

Thank you for hints.



-- 

google.com/+arnaudgabourygabx

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] clusterR (fun=aggregate) error number of items to replace is not a multiple of replacement length

2015-04-20 Thread nevil amos
I am getting the above  error with clusterR and aggregate:

works fine without parralell:

library(raster)
r-raster(matrix(data = sample(c(1:10,NA),1,replace=T),100,100),xmn=0,
xmx=1000,ymn=0,ymx=1000)
beginCluster()
Parr_agg-clusterR(r,fun=aggregate,args=list(fact=3,fun=modal,expand=TRUE,na.rm=TRUE))
endCluster()
agg-aggregate(r,3,fun=modal,na.rm=TRUE)
plot(agg)

[[alternative HTML version deleted]]

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


Re: [R] Handling NA values in a if statement

2015-04-20 Thread Luigi Marongiu
Dear David and Mark,
thank you for your reply. I have implemented the suggestions you have
made in the following:
x - c(-Inf,  Inf,NA,5.9,6.08,5281391136138.75,
   4.35,4.79,
   9474097322.96,3.64,16.42,-12211.11,4.37,
   -1097.79,4.78,
   3.71,32.59,4.01,35.36,3.17,1.61,
   -3678.28,2.9,4.67,
   4.1,348410866.78,5.35,4.3101519459837E+016,
   1467030866.75,
   1.10376094956278E+018,32.55,1.17,5339028670388.94,
   34.14,
   33205967009.57,4.42,1.76,7.08,-8428.84,
   -113491.08,17.81)
ll - 1
ul - 45

clipper - function(x, ll, ul) {
  for(i in 1:length(x)) {
if(is.finite(x[i])  ll  is.finite(x[i])  ul) {
  x[i] - NA
} else if (is.infinite(x[i]) == TRUE) {
  x[i] - NA
} else {
  x[i] - x[i]
}
  }
  return(x)
}
(X-clipper(x, ll, ul))

that works all right.
Best regards
Luigi


On Fri, Apr 17, 2015 at 11:43 PM, Marc Schwartz marc_schwa...@me.com wrote:
 On Apr 17, 2015, at 5:23 PM, Luigi Marongiu marongiu.lu...@gmail.com wrote:

 Dear all,
 I have a vector with a certain range of values including infinity and
 NA. I would like to remove the values that are outside a given range
 (lower level = ll and upper level = ul) but I am getting the error due
 to the NA values (missing value where TRUE/FALSE needed). I then
 included the !is.na() but now the resulting error is all NA, as in the
 example.
 In addition, here I have implemented a for loop to scan all the
 elements of the vector, but I should be able to use the sapply();
 however I don't know how to send the ll and ul arguments to sapply().
 Could you please help?
 best regards
 Luigi

 EXAMPLE

 x - c(-Inf,  Inf,NA,5.9,6.08,5281391136138.75,
 4.35,4.79,
   9474097322.96,3.64,16.42,-12211.11,4.37,
 -1097.79,4.78,
   3.71,32.59,4.01,35.36,3.17,1.61,
 -3678.28,2.9,4.67,
   4.1,348410866.78,5.35,4.3101519459837E+016,
 1467030866.75,
   1.10376094956278E+018,32.55,1.17,5339028670388.94,
  34.14,
   33205967009.57,4.42,1.76,7.08,-8428.84,
 -113491.08,17.81)
 ll - 1
 ul - 45

 clipper - function(x, ll, ul) {
  for(i in 1:length(x)) {
if(x[i]  ll) {
  x[i] - NA
} else if(x[i]  ul) {
  x[i] - NA
} else {
  x[i] - x[i]
}
  }
 return(x)
 }
 (X-clipper(x, ll, ul))
 missing value where TRUE/FALSE needed


 clipper - function(x, ll, ul) {
  for(i in 1:length(x)) {
if(!is.na(x[i])  ll) {
  x[i] - NA
} else if(!is.na(x[i])  ul) {
  x[i] - NA
} else {
  x[i] - x[i]
}
  }
 return(x)
 }
 (X-clipper(x, ll, ul))

 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 NA NA NA NA NA
 [28] NA NA NA NA NA NA NA NA NA NA NA NA NA NA


 Hi,

 Something along the lines of:

 subset(x, is.finite(x)  (x  ll)  (x  ul))
  [1]  5.90  6.08  4.35  4.79  3.64 16.42  4.37  4.78  3.71 32.59  4.01
 [12] 35.36  3.17  1.61  2.90  4.67  4.10  5.35 32.55  1.17 34.14  4.42
 [23]  1.76  7.08 17.81

 or:

 x[is.finite(x)  (x  ll)  (x  ul)]
  [1]  5.90  6.08  4.35  4.79  3.64 16.42  4.37  4.78  3.71 32.59  4.01
 [12] 35.36  3.17  1.61  2.90  4.67  4.10  5.35 32.55  1.17 34.14  4.42
 [23]  1.76  7.08 17.81


 See ?subset and ?is.finite:

 is.finite(x)
  [1] FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 [12]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 [23]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
 [34]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE


 Regards,

 Marc Schwartz


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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Gerrit Eichner

Hi, John,

doesn't

n - your number
lapply( 1:n, rep, each = 4)

do what you need?

 Hth  --  Gerrit


On Sat, 18 Apr 2015, John Sorkin wrote:


Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103



I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.


1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n


(The spaces in the list are added only for clarity.)


I can generate the list as follows, but the code must be modified for any value 
n, and the code is UGLY!


c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))


Can anyone help me?


Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] select portion of text file using R

2015-04-20 Thread Duncan Murdoch
On 20/04/2015 3:28 AM, Luigi Marongiu wrote:
 Dear all,
 I have a flat file (tab delimited) derived from an excel file which is
 subdivided in different parts: a first part is reporting metadata,
 then there is a first spreadsheet indicated by [ ], then the actual
 data and the second spreadsheet with the same format [ ] and then the
 data.
 How can I import such file using for instance read.table()?

read.table() by itself can't recognize where the data starts, but it has
arguments skip and nrows to control how much gets read.  If you
don't know the values for those arguments, you can use readLines() to
read the entire file, then use grep() to recognize your table data, and
either re-read the file, or just extract those lines and read from them
as a textConnection.

Duncan Murdoch

 Many thanks
 regards
 Luigi
 
 Here is a sample of the file:
 * Experiment Barcode =
 * Experiment Comments =
 * Experiment File Name = F:\array 59
 * Experiment Name = 2015-04-13 171216
 * Experiment Run End Time = 2015-04-13 18:07:57 PM PDT
 ...
 [Amplification Data]
 WellCycleTarget NameRnDelta Rn
 11Adeno 1-Adeno 10.820-0.051
 12Adeno 1-Adeno 10.827-0.042
 13Adeno 1-Adeno 10.843-0.025
 14Adeno 1-Adeno 10.852-0.015
 15Adeno 1-Adeno 10.858-0.008
 16Adeno 1-Adeno 10.862-0.002
 ...
 [Results]
 WellWell PositionOmitSample NameTarget NameTask
 ReporterQuencherRQRQ MinRQ MaxCTCt MeanCt
 SDQuantityDelta Ct MeanDelta Ct SDDelta Delta Ct
 Automatic Ct ThresholdCt ThresholdAutomatic Baseline
 Baseline StartBaseline EndEfficiencyCommentsCustom1
 Custom2Custom3Custom4Custom5Custom6NOAMP
 EXPFAIL
 1A1falseP17Adeno 1-Adeno 1UNKNOWNFAM
 NFQ-MGBUndeterminedfalse
  0.200true3441.000N/AN
Y
 2A2falseP17Adeno 40/41 EH-AIQJCT3UNKNOWNFAM
 NFQ-MGBUndetermined
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread arnaud gaboury
On Mon, Apr 20, 2015 at 12:09 PM, Jim Lemon drjimle...@gmail.com wrote:
 Hi arnaud,
 At a guess, it is the two hyphens that are present in those strings. I
 think that the function you are using interprets them as subtraction
 operators and since the string following the hyphen would produce NA,
 the result would be NA.

I was thinking of 'x' as being the culprit (interpreted as multiply)
but you are right indeed

noHyphens - str_replace(playerStats[c(22,24)],'-','')
 extract_numeric(noHyphens)
[1]   276 83226


in fact:
-
 extract_numeric
function (x)
{
as.numeric(gsub([^0-9.-]+, , as.character(x)))
}
environment: namespace:tidyr
-

Is there any particular reason for the hyphen in gsub() ? Why not
remove it thus ?

TY much Jim


 Jim


 On Mon, Apr 20, 2015 at 7:46 PM, arnaud gaboury
 arnaud.gabo...@gmail.com wrote:
 On Mon, Apr 20, 2015 at 9:10 AM, arnaud gaboury
 arnaud.gabo...@gmail.com wrote:
 R 3.2.0 on Linux
 

 library(tidyr)

 playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
 Portals Visited 1,038,
 XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed 11,126,
 Links Created 1,744, Control Fields Created 294, Mind Units
 Captured 2,995,484 MUs,
 Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
 XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
 Captured 486,
 Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
 Links Destroyed 3,169,
 Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
 Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
 Max Link Length x Days 276 km-days, Max Time Field Held 4days,
 Largest Field MUs x Days 83,226 MU-days)

 ---
  extract_numeric(playerStats)
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15 NA
4 NA

 
  playerStats[c(22,24)]
 [1] Max Link Length x Days 276 km-days  Largest Field MUs x
 Days 83,226 MU-days
 

 I do not understand why these two vectors return NA when the function
 extract_numeric() works well for others,

 Any wrong settings in my env?

 -
  as.numeric(gsub([^0-9], ,playerStats))
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15276
4  83226
 

 The above command does the job, but I still can not figure out why
 extract_numeric() returns two NA


 Thank you for hints.



 --

 google.com/+arnaudgabourygabx



 --

 google.com/+arnaudgabourygabx

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



-- 

google.com/+arnaudgabourygabx

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


Re: [R] error using by, Error in tapply(response, list(x.factor, trace.factor), fun) : argument trace.factor is missing, with no default

2015-04-20 Thread Rolf Turner

On 20/04/15 01:44, John Sorkin wrote:



I am receiving an error message from the by function that I don't understand:
Error in tapply(response, list(x.factor, trace.factor), fun) :
   argument trace.factor is missing, with no default



My code follows:



summary(ipd)

  group  valuestime  subjects weaned disp
  1:55   Min.   :0.   Min.   :0   Min.   :115.0   1:65   2:45
  2:35   1st Qu.:0.1950   1st Qu.:1   1st Qu.:121.0   2:25   3: 5
 Median :0.3400   Median :2   Median :126.0  4:20
 Mean   :0.3479   Mean   :2   Mean   :127.6  5:20
 3rd Qu.:0.5000   3rd Qu.:3   3rd Qu.:134.0
 Max.   :0.7300   Max.   :4   Max.   :144.0
 NA's   :48

by(ipd[,c(time,subjects,values)],ipd[,group],interaction.plot)

Error in tapply(response, list(x.factor, trace.factor), fun) :
   argument trace.factor is missing, with no default


SNIP

The error is not from tapply(), it is from interaction.plot().  You 
cannot supply a dataframe to this function, you must supply the three

arguments x.factor, trace.factor and response.

You could do:

 by(ipd[,c(time,subjects,values)],ipd[,group],
function(x){names(x) - c(x.factor,trace.factor,
  response);
do.call(interaction.plot,x)})


There are several other ways of organizing the syntax, but somehow you 
have to make the arguments to interaction.plot() explicit.


I was somewhat surprised to find that do.call() does not work with 
positional matching of arguments.  I.e.


by(ipd[,c(time,subjects,values)],ipd[,group],
function(x){do.call(interaction.plot,x)})

does *not* work.  The names of x have to match the names of the 
arguments to interaction.plot().


I'm sure this makes sense  but I don't understand it.

cheers,

Rolf Turner

--
Rolf Turner
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
Home phone: +64-9-480-4619

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


Re: [R] clusterR (fun=aggregate) error number of items to replace is not a multiple of replacement length

2015-04-20 Thread nevil amos
Apoligies.  did not read help properly it states:
Among other functions, it does _not_ work with ... (dis)aggregate

On Mon, Apr 20, 2015 at 4:54 PM, nevil amos nevil.a...@gmail.com wrote:

 I am getting the above  error with clusterR and aggregate:

 works fine without parralell:

 library(raster)
 r-raster(matrix(data = sample(c(1:10,NA),1,replace=T),100,100),xmn=0,
 xmx=1000,ymn=0,ymx=1000)
 beginCluster()

 Parr_agg-clusterR(r,fun=aggregate,args=list(fact=3,fun=modal,expand=TRUE,na.rm=TRUE))
 endCluster()
 agg-aggregate(r,3,fun=modal,na.rm=TRUE)
 plot(agg)


[[alternative HTML version deleted]]

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Boris Steipe
That would be the each argument to rep()...
n - 5
rep(1:n, each=4)
 [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5

Cheers,
B.


On Apr 19, 2015, at 9:44 AM, John Sorkin jsor...@grecc.umaryland.edu wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103
 
 
 I am trying to generate a list of  length 4n which consists of the integers 1 
 to n repeated in groups of four, i.e.
 
 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n
 
 (The spaces in the list are added only for clarity.)
 
 I can generate the list as follows, but the code must be modified for any 
 value n, and the code is UGLY!
 
 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))
 
 Can anyone help me?
 
 Thank you,
 John
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 
 
 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and 
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing) 
 
 
 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:12}}

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread SOUVIK BANDYOPADHYAY
Hi,
You can use the apply group of functions

n-5
k-4

unlist(lapply(1:n,rep, each=k)) # For vector output:
sapply(1:n,rep, each=k) # For a matrix output

Hope this helps
Souvik

On Sun, Apr 19, 2015 at 7:14 PM, John Sorkin jsor...@grecc.umaryland.edu
wrote:

 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103


 I am trying to generate a list of  length 4n which consists of the
 integers 1 to n repeated in groups of four, i.e.

 1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

 (The spaces in the list are added only for clarity.)

  I can generate the list as follows, but the code must be modified for any
 value n, and the code is UGLY!

 c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

 Can anyone help me?

 Thank you,
 John

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Call
 Send SMS
 Add to Skype
 You'll need Skype CreditFree via Skype

 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)




 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:24}}

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


Re: [R] RODBC package not found (in English)

2015-04-20 Thread guillaume chaumet
Dear Xavier,
Perhaps, you should read the faq:
http://cran.r-project.org/doc/FAQ/R-FAQ.html
And also un livre en français sur R* : R pour les débutants *par Emmanuel
Paradis ou *Introduction à R par *Julien Barnier

 install.packages(RODBC)

Un dernier petit mot : Méfiez vous! La patience des membres de la mailing
list R est limitée surtout pour les questions qui ont été posées mille fois
et dont les réponses sont dans le FAQ.

A bon entendeur, Bonne journée

Guillaume


2015-04-20 13:01 GMT+02:00 CHIRIBOGA Xavier xavier.chirib...@unine.ch:

 Dear members,



 What can I do if I get this message: ?



 library(RODBC)
 Error in library(RODBC) : any package called ‘RODBC’ was found





 Thanks in advcance,



 Xavier

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] RODBC package not found (in English)

2015-04-20 Thread Ista Zahn
Install it with

install.packages(RODBC)

Best,
Ista
On Apr 20, 2015 7:02 AM, CHIRIBOGA Xavier xavier.chirib...@unine.ch
wrote:

 Dear members,



 What can I do if I get this message: ?



 library(RODBC)
 Error in library(RODBC) : any package called ‘RODBC’ was found





 Thanks in advcance,



 Xavier

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] high density plots using lattice dotplot()

2015-04-20 Thread Luigi Marongiu
Dear all,
I am trying to plot the results of a PCR experiments that involves 384
individual plots. Admittedly the space for the plots will be tiny, but
I just nedd some icon to have a feeling of the layout of the
experiment and a quick comparison of the plots.
I believe that lattice would be the right tool, but when I tried to
implement i got an error. Specifically the output would be a A4 pdf,
so with about 600 cm2 of drawing space, which gives about 1.5 cm2 for
each plot; removing the labels that might just work.
So I have the y values = 'fluorescence', x 'values' = cycles and 384
'well' data. I implemented to begin with:

xyplot(fluorescence ~ cycles | well,
 ylab=Fluorescence,
 xlab=Cycles,
 main=list(draw = FALSE),
 scales = list(
   x = list(draw = FALSE),
   y = list(draw = FALSE),
   relation=same,
   alternating=TRUE),
 layout = c(24,16),
 par.settings = list(strip.background=list(col=white)),
 pch = .
  )

but the  the individual graphs show only the writing data instead of
the actual plots.
How can I overcome this error?
Thank you
Best regards
Luigi

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


Re: [R-es] Como leer una BD con una estructura inadecuada

2015-04-20 Thread Carlos Ortega
Se me olvidó incluir el detalle de la referencia donde se anunciaba la
disponibilidad de este nuevo paquete:

http://blog.rstudio.org/2015/04/09/readr-0-1-0/

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 20 de abril de 2015, 11:40, Carlos Ortega c...@qualityexcellence.es
escribió:

 Hola Eric,

 No sé si viste mi correo. Pude importar el txt que adjuntaste sin
 problemas con una función del nuevo paquete de Hadley Wickham (readr).

 En este paquete ha incluido una función para leer datos read_table() que
 mejora las prestaciones del read.table() que R trae por defecto. Una de
 las mejoras, además de la velocidad es que dado un conjunto de datos
 tabular a importar, la función primero lee el fichero línea a línea y hace
 una interpretación del contenido para luego ya importarlo con las
 columnas adecuadas.

 Esta función de esta manera simplifica mucho la forma de carga de un
 fichero comparándola con el read.table() que precisaba de múltiples
 parámetros para si uno quería ajustar las columnas a cargar y la velocidad.

 Saludos,
 Carlos.
 www.qualityexcellence.es

 El 19 de abril de 2015, 5:37, eric ericconchamu...@gmail.com escribió:

 Estimado Javier:

 Disculpe mi imprecision al hablar de base de datos en este caso, en
 realidad es un conjunto interesante de datos pero no tiene exactamente
 estandar de BD .. en fin ... este conjunto de datos lo baje directamente de
 la pagina de la FIDE, que es la federacion internacional de ajedrez, en
 http://ratings.fide.com/download.phtml, es decir, estos datos son la BD
 original.

 Los datos se ofrecen en formato .txt, que es como yo los baje (70 MB), y
 en formato XML. que tambien lo baje, pero el archivo pesa alrededor de 180
 megas y se vuelve inmanejable con mi modesto portatil. Ni siquiera es
 posible visualizar los datos. Por esto use el archivo .txt para trate de
 importarlo en R y tuve los problemas que ya señale.

 Pense por un momento en que quiza seria posible reemplazar un conjunto de
 puntos de cualquier largo por un \tab o algo asi, pero al tener casillas
 vacias se pierde el orden de los datos. Es decir, si un dato corresponde a
 la ultima columna y todas las anteriores estan vacias, al final de la
 sustitucion quedara asociado a la primera columna. Al no haber patrones es
 dificil corregir la estructura del archivo de forma automatica y son
 demiados datos para intentar siquiera algo a manos.

 Esa es la situacion mas o menos.

 Alguna idea ??

 Saludos y gracias,

 Eric.







 On 18/04/15 22:45, Javier Marcuzzi wrote:

 Estimado Eric Concha

 Como usted dice, hay un problema, yo encontré inconvenientes al intentar
 importar los datos que usted suministro. Pero se me ocurre una pregunta
 ¿tiene usted acceso a la base de datos original? Porque si tiene acceso
 hay dos posibilidades, el acceso real donde usted puede (depende que DB)
 usar la parte de R para esa base de datos en particular, o si tiene
 acceso pero por medio de otra persona, podría solicitar una consulta sql
 de acuerdo a sus requerimientos y guardar los datos como a usted le
 convenga. Otra posibilidad es preguntar si en lugar de un archivo txt
 puede recibirlo en json, o sql (¿excel?), csv es bueno pero puede ser
 que se presente algún problema (no es tan seguro como los anteriores),
 pensando en que usted use otra base de datos.

 Javier Marcuzzi

 El 18 de abril de 2015, 20:03, eric ericconchamu...@gmail.com
 mailto:ericconchamu...@gmail.com escribió:


 Estimados, tengo el siguiente problema:

 Tengo una BD de 19 columnas y aprox 500 mil filas, la que tiene
 muchas celdas vacias y esta separada con espacios para hacer
 coincidir los datos bajo los encabezados.

 Mi problema es que al tratar de importar a R la BD no se como tratar
 con los espacios vacios cuando se trata de una columna de numeros
 (para el texto puse na.strings = NA) y tampoco se como hacer para
 que al leer cada dato este asociado al encabezado correcto, pues el
 numero de espacios que esta puesto entre cada dato varia de acuerdo
 a la extension en caracteres del dato (hay numeros, nombres, etc).
 Incluso hay encabezados de dos palabras y parece que R los considera
 dos encabezados distintos. Me explico ?

 Como puedo hacer para leer la BD correctamente ? Alguna idea ??

 Adjunto un archivo de muestra.

 Muchas gracias.

 Eric.




 --
 Forest Engineer
 Master in Environmental and Natural Resource Economics
 Ph.D. student in Sciences of Natural Resources at La Frontera
 University
 Member in AguaDeTemu2030, citizen movement for Temuco with green
 city standards for living

 Nota: Las tildes se han omitido para asegurar compatibilidad con
 algunos lectores de correo.

 ___
 R-help-es mailing list
 R-help-es@r-project.org mailto:R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es



 --
 Forest Engineer
 Master in Environmental and 

Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread Jim Lemon
Hi arnaud,
At a guess, it is the two hyphens that are present in those strings. I
think that the function you are using interprets them as subtraction
operators and since the string following the hyphen would produce NA,
the result would be NA.

Jim


On Mon, Apr 20, 2015 at 7:46 PM, arnaud gaboury
arnaud.gabo...@gmail.com wrote:
 On Mon, Apr 20, 2015 at 9:10 AM, arnaud gaboury
 arnaud.gabo...@gmail.com wrote:
 R 3.2.0 on Linux
 

 library(tidyr)

 playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
 Portals Visited 1,038,
 XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed 11,126,
 Links Created 1,744, Control Fields Created 294, Mind Units
 Captured 2,995,484 MUs,
 Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
 XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
 Captured 486,
 Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
 Links Destroyed 3,169,
 Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
 Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
 Max Link Length x Days 276 km-days, Max Time Field Held 4days,
 Largest Field MUs x Days 83,226 MU-days)

 ---
  extract_numeric(playerStats)
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15 NA
4 NA

 
  playerStats[c(22,24)]
 [1] Max Link Length x Days 276 km-days  Largest Field MUs x
 Days 83,226 MU-days
 

 I do not understand why these two vectors return NA when the function
 extract_numeric() works well for others,

 Any wrong settings in my env?

 -
  as.numeric(gsub([^0-9], ,playerStats))
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15276
4  83226
 

 The above command does the job, but I still can not figure out why
 extract_numeric() returns two NA


 Thank you for hints.



 --

 google.com/+arnaudgabourygabx



 --

 google.com/+arnaudgabourygabx

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread John Sorkin
Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103



I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.


1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n


(The spaces in the list are added only for clarity.)


 I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!


c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))


Can anyone help me?


Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) 


Confidentiality Statement:
This email message, including any attachments, is for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
Any unauthorized use, disclosure or distribution is prohibited. If you are not 
the intended recipient, please contact the sender by reply email and destroy 
all copies of the original message. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 using by, Error in tapply(response, list(x.factor, trace.factor), fun) : argument trace.factor is missing, with no default

2015-04-20 Thread John Sorkin


I am receiving an error message from the by function that I don't understand:
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument trace.factor is missing, with no default



My code follows:


 summary(ipd)
 group  valuestime  subjects weaned disp  
 1:55   Min.   :0.   Min.   :0   Min.   :115.0   1:65   2:45  
 2:35   1st Qu.:0.1950   1st Qu.:1   1st Qu.:121.0   2:25   3: 5  
Median :0.3400   Median :2   Median :126.0  4:20  
Mean   :0.3479   Mean   :2   Mean   :127.6  5:20  
3rd Qu.:0.5000   3rd Qu.:3   3rd Qu.:134.0
Max.   :0.7300   Max.   :4   Max.   :144.0
NA's   :48
 by(ipd[,c(time,subjects,values)],ipd[,group],interaction.plot)
Error in tapply(response, list(x.factor, trace.factor), fun) : 
  argument trace.factor is missing, with no default




These are my data.
 ipd
   group values time subjects weaned disp
1  1   0.000  115  12
2  1   0.001  115  12
3  1   0.182  115  12
4  1   0.173  115  12
5  1 NA4  115  12
6  1   0.620  116  12
7  1 NA1  116  12
8  1 NA2  116  12
9  1 NA3  116  12
10 1 NA4  116  12
11 1   0.000  118  12
12 1   0.211  118  12
13 1   0.342  118  12
14 1   0.493  118  12
15 1 NA4  118  12
16 2   0.520  119  24
17 2 NA1  119  24
18 2 NA2  119  24
19 2 NA3  119  24
20 2 NA4  119  24
21 2   0.350  121  23
22 2   0.531  121  23
23 2   0.352  121  23
24 2   0.443  121  23
25 2   0.564  121  23
26 1   0.160  122  15
27 1   0.221  122  15
28 1 NA2  122  15
29 1 NA3  122  15
30 1 NA4  122  15
31 1   0.190  123  25
32 1 NA1  123  25
33 1 NA2  123  25
34 1 NA3  123  25
35 1 NA4  123  25
36 2   0.290  124  14
37 2   0.221  124  14
38 2 NA2  124  14
39 2 NA3  124  14
40 2 NA4  124  14
41 1   0.380  125  14
42 1   0.451  125  14
43 1 NA2  125  14
44 1 NA3  125  14
45 1 NA4  125  14
46 1   0.220  127  12
47 1   0.371  127  12
48 1   0.282  127  12
49 1   0.503  127  12
50 1 NA4  127  12
51 1   0.300  130  12
52 1   0.491  130  12
53 1 NA2  130  12
54 1 NA3  130  12
55 1 NA4  130  12
56 1   0.700  131  12
57 1 NA1  131  12
58 1 NA2  131  12
59 1 NA3  131  12
60 1 NA4  131  12
61 2   0.000  133  12
62 2   0.501  133  12
63 2   0.562  133  12
64 2   0.733  133  12
65 2 NA4  133  12
66 1   0.220  134  12
67 1   0.651  134  12
68 1 NA2  134  12
69 1 NA3  134  12
70 1 NA4  134  12
71 2   0.340  135  12
72 2   0.731  135  12
73 2   0.712  135  12
74 2 NA3  135  12
75 2 NA4  135  12
76 2   0.260  139  25
77 2 NA1  139  25
78 2 NA2  139  25
79 2 NA3  139  25
80 2 NA4  139  25
81 1   0.000  140  15
82 1   0.191  140  15
83 1 NA2  140  15
84 1 NA3  140  15
85 1 NA4  140  15
86 2   0.190  144  24
87 2 NA1  144  24
88 2 NA2  144  24
89 2 NA3  144  24
90 2 NA4  144  24


John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA 

Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread arnaud gaboury
On Mon, Apr 20, 2015 at 9:10 AM, arnaud gaboury
arnaud.gabo...@gmail.com wrote:
 R 3.2.0 on Linux
 

 library(tidyr)

 playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
 Portals Visited 1,038,
 XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed 11,126,
 Links Created 1,744, Control Fields Created 294, Mind Units
 Captured 2,995,484 MUs,
 Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
 XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
 Captured 486,
 Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
 Links Destroyed 3,169,
 Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
 Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
 Max Link Length x Days 276 km-days, Max Time Field Held 4days,
 Largest Field MUs x Days 83,226 MU-days)

 ---
  extract_numeric(playerStats)
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15 NA
4 NA

 
  playerStats[c(22,24)]
 [1] Max Link Length x Days 276 km-days  Largest Field MUs x
 Days 83,226 MU-days
 

 I do not understand why these two vectors return NA when the function
 extract_numeric() works well for others,

 Any wrong settings in my env?

-
 as.numeric(gsub([^0-9], ,playerStats))
 [1] 10 5671448600   1038   15327123
   14268  11126   17442942995484
[10] 75 1897313006364   1204
 486  12481   1240   3169   1394
[19]230240 15276
   4  83226


The above command does the job, but I still can not figure out why
extract_numeric() returns two NA


 Thank you for hints.



 --

 google.com/+arnaudgabourygabx



-- 

google.com/+arnaudgabourygabx

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


Re: [R] generate a list as follows: 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, . . . . ., n, n, n, n

2015-04-20 Thread Michael Dewey



On 19/04/2015 15:34, John Sorkin wrote:

Windows 7 64-bit
R 3.1.3
RStudio 0.98.1103


I am trying to generate a list of  length 4n which consists of the integers 1 
to n repeated in groups of four, i.e.

1,1,1,1,  2,2,2,2,  3,3,3,3, . . . . , n,n,n,n

(The spaces in the list are added only for clarity.)

  I can generate the list as follows, but the code must be modified for any 
value n, and the code is UGLY!

c(rep(1,4), rep(2,4), rep(3,4), . . . ,c(n,4))

That gives a vector not a list?

Does
rep((1:n), each = 4)
do what you want?


Can anyone help me?

Thank you,
John

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


Call
Send SMS
Add to Skype
You'll need Skype CreditFree via Skype

John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)



John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)




John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric 
Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)


Confidentiality Statement:
This email message, including any attachments, is for ...{{dropped:12}}


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] select portion of text file using R

2015-04-20 Thread Luigi Marongiu
Dear all,
I have a flat file (tab delimited) derived from an excel file which is
subdivided in different parts: a first part is reporting metadata,
then there is a first spreadsheet indicated by [ ], then the actual
data and the second spreadsheet with the same format [ ] and then the
data.
How can I import such file using for instance read.table()?
Many thanks
regards
Luigi

Here is a sample of the file:
* Experiment Barcode =
* Experiment Comments =
* Experiment File Name = F:\array 59
* Experiment Name = 2015-04-13 171216
* Experiment Run End Time = 2015-04-13 18:07:57 PM PDT
...
[Amplification Data]
WellCycleTarget NameRnDelta Rn
11Adeno 1-Adeno 10.820-0.051
12Adeno 1-Adeno 10.827-0.042
13Adeno 1-Adeno 10.843-0.025
14Adeno 1-Adeno 10.852-0.015
15Adeno 1-Adeno 10.858-0.008
16Adeno 1-Adeno 10.862-0.002
...
[Results]
WellWell PositionOmitSample NameTarget NameTask
ReporterQuencherRQRQ MinRQ MaxCTCt MeanCt
SDQuantityDelta Ct MeanDelta Ct SDDelta Delta Ct
Automatic Ct ThresholdCt ThresholdAutomatic Baseline
Baseline StartBaseline EndEfficiencyCommentsCustom1
Custom2Custom3Custom4Custom5Custom6NOAMP
EXPFAIL
1A1falseP17Adeno 1-Adeno 1UNKNOWNFAM
NFQ-MGBUndeterminedfalse
 0.200true3441.000N/AN
   Y
2A2falseP17Adeno 40/41 EH-AIQJCT3UNKNOWNFAM
NFQ-MGBUndetermined

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


[R] RODBC did not found

2015-04-20 Thread CHIRIBOGA Xavier
Dear members,



What can I do if I get this message: ?



library(RODBC)
Error in library(RODBC) : aucun package nommé ‘RODBC’ n'est trouvé





Thanks in advcance,



Xavier

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


Re: [R] Smart detection of wrap width?

2015-04-20 Thread MacQueen, Don
At this point, and since we are in an X windows context, I think it might
be easier to use the window manager's features and write a little macro or
something that will send my setwid() command to the active window, then
assign it to a simple keystroke. Then:  resize the window; hit the
keystroke, and you're done. True, it's not fully automatic, but it would
be pretty quick and easy.

Either that or give ESS a try, using the bit that Ista offered. Or maybe
Rstudio?

Peter's got a good start, but I too would be stymied at the last step;
definitely beyond my skill.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/18/15, 1:41 PM, Peter Crowther peter.crowt...@melandra.com wrote:

On Apr 17, 2015 7:37 PM, Paul Domaskis paul.domas...@gmail.com wrote:
 I don't suppose there is a way to have it
 automatically invoked when the window size/positition changes?

Possibly, though it would take a little building.  If you were to
launch R directly when you start the xterm (loosely xterm R rather
than the default) then R would receive a SIGWINCH signal whenever the
xterm window size changes (xterm automatically sends this to its child
process).  R doesn't directly enable handling of the signal, but
there's nothing to stop you loading a dynamic library with a little C
code that set up a handler for SIGWINCH and, when it got one, ran the
equivalent of the stty command to get the new width.  The thing I've
not been able to figure out is how the C code would ever then hand
that to R asynchronously.  Anyone?

Cheers,

- Peter

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Smart detection of wrap width?

2015-04-20 Thread MacQueen, Don
I'm glad it's helpful!

Defining it and then invoking it in ~/.Rprofile would work, but then you
will need to be careful about managing both ./.Rprofile and ~/.Rprofile
files. If you have one of the former, then the latter does not get sourced
at startup (see ?Startup). Of course, you can put source('~/.Rprofile') in
a local ./.Rprofile to take care of that if you want.

But in the long run, it would be a better practice to put personal helper
functions like this in a package and then load it in your .Rprofile
file(s). Most of my ./.Rprofile files have
  require(rmacq)
  setwid()
in them (along with whatever other directory-specific startup actions I
want). The more personal helper functions you have, the more valuable it
will be to put them in a package instead of defining them in ~/.Rprofile.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/17/15, 4:36 PM, Paul Domaskis paul.domas...@gmail.com wrote:

Yes, I found the width option in the help pages, but I was wondering
if there was automatic setting of the wrapping according to the
current window width.

Your function works exactly as I wished.  I'll probably get smarter
with time (I hope) but would it be reasonably good practice to stick
this into ~/.Rprofile?  I don't suppose there is a way to have it
automatically invoked when the window size/positition changes?  (It's
still priceless even without automatic triggering).

On Fri, Apr 17, 2015 at 7:20 PM, MacQueen, Don macque...@llnl.gov
wrote:
 A lot of this depends on what context you are running R in, e.g.,
 Windows console, Mac console, or command line in a unix-alike. Or
 within ESS in emacs. Those are different interfaces supported by, to
 some extent, different people, and are based on the underlying
 capabilities provided by the operating system.

 Have you yet encountered
   options()$width
 ?
 For example,
   options(width=100)
 will cause wrapping at 100, at least for certain kinds of output.

 In an xterm shell running in an X windows context, I frequently use

 setwid - function ()
 {
 if (!interactive())
 return(invisible(NULL))
 scon - pipe(stty -a)
 stty - scan(scon, what = , sep = ;, quiet = T)
 close(scon)
 cstr - stty[grep(columns, stty)]
 options(width = as.numeric(gsub([^0-9], , cstr, ignore.case =
T)))
 paste(width =, options()$width, \n)
 }

 A function I wrote that resets the width option to match the window
 widths, and therefore adjusts the wrapping after I resize a windwo.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] color handling in `barplot' inconsistent betwen `beside=FALSE' and `beside=TRUE'

2015-04-20 Thread j. van den hoff

hi,

consider the following example:

8-
x - matrix(1:6, 3, 2)
layout(1:2)
barplot(x, beside = TRUE, col = 1:6)
barplot(x, beside = FALSE, col = 1:6)
8-

it seems, it is not possible to make `beside=FAlSE' plots behave the same  
as `beside=TRUE' plots (i.e. use unique colors for all bars or bar  
components), or is it? if I do not miss something, I would say the present  
behaviour (as of 3.1.3) is not (or not always, anyway) desirable. rather,  
`beside=FALSE' should use the same color for all bars or bar components as  
`beside=TRUE'.


any opionions on that?

in case someone needs this, the following patch achieves what I would  
expect from `barplot(beside=FALSE, ...)' -- at least w.r.t. colors, if not  
shading ... -- in the first place:


8---
@@ -96,12 +96,12 @@
 if (beside)
 w.m - matrix(w.m, ncol = NC)
 if (plot) {
-dev.hold()
+###dev.hold()
 opar - if (horiz)
 par(xaxs = i, xpd = xpd)
 else par(yaxs = i, xpd = xpd)
 on.exit({
-dev.flush()
+###dev.flush()
 par(opar)
 })
 if (!add) {
@@ -119,10 +119,16 @@
 w.r, horizontal = horiz, angle = angle, density = density,
 col = col, border = border)
 else {
+numelements - length(height[-1,])
+numcols - length(col)
+if (numelements != numcols)
+   col - rep_len(col, ceiling(numelements/numcols))
+col - col[1:numelements]
+attr(col, dim) - dim(height[-1,])
 for (i in 1L:NC) {
 xyrect(height[1L:NR, i] + offset[i], w.l[i],
   height[-1, i] + offset[i], w.r[i], horizontal = horiz,
-  angle = angle, density = density, col = col,
+  angle = angle, density = density, col = col[1:NR, i],
   border = border)
 }
 }
8---

(please note that this is the diff for the representation of the function  
as it appears in `edit(barplot)', rather than as it appears in the R  
source code ...)


@devs: would it be desirable to change the official `barplot' behaviour  
accordingly in the future?



thanks

joerg



--

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


Re: [R] Need online version of R help pages

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 9:43 AM, Paul paul.domas...@gmail.com wrote:

 Acknowledged, Michael.  I appreciate the pointer to the info.

 For at least a short while, however, this is my only access to R, so I
 am using this environment to ramp up on times series and R as much a
 possible.  I think it should suffice for that purpose, and the real
 analysis can occur in a more reliable installation R.  I've managed to
 work the ropes on a better installation, but the solution won't be
 immediate.


​I am not really familiar with the site referenced below. But maybe it
would be helpful to you? It allows you to edit and run R code through a
browser on the _their_ site. It appears to be absolutely free. And has
other languages available as well.

http://www.tutorialspoint.com/execute_r_online.php
​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[alternative HTML version deleted]]

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

Re: [R] Smart detection of wrap width?

2015-04-20 Thread Paul Domaskis
On Mon, Apr 20, 2015 at 10:59 AM, MacQueen, Don macque...@llnl.gov
wrote:
 I'm glad it's helpful!

 Defining it and then invoking it in ~/.Rprofile would work, but then
 you will need to be careful about managing both ./.Rprofile and
 ~/.Rprofile files. If you have one of the former, then the latter
 does not get sourced at startup (see ?Startup). Of course, you can
 put source('~/.Rprofile') in a local ./.Rprofile to take care of
 that if you want.

 But in the long run, it would be a better practice to put personal
 helper functions like this in a package and then load it in your
 .Rprofile file(s). Most of my ./.Rprofile files have

   require(rmacq)
   setwid()

 in them (along with whatever other directory-specific startup
 actions I want). The more personal helper functions you have, the
 more valuable it will be to put them in a package instead of
 defining them in ~/.Rprofile.

Thanks, I'll keep it in mind, Don.  I'm sort of careening at breakneck
speed into time series and R, so I know I'll be rough around the edges
for a while, with the more refined aspects such as sensible
organization of customizations following in the rear.  Not ideal, I
know, but 'tis what it is...

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


Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Marc Schwartz

 On Apr 20, 2015, at 8:59 AM, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
 
 Hello!
 
 Please point me in the right direction.
 I need to match 2 strings, but focusing ONLY on characters, ignoring
 all special characters and punctuation signs, including (), , etc..
 
 For example:
 I want the following to return: TRUE
 
 What a nice day today! - Story of happiness: Part 2. ==
   What a nice day today: Story of happiness (Part 2)
 
 
 -- 
 Thank you!
 Dimitri Liakhovitski


Look at ?agrep:

Vec1 - What a nice day today! - Story of happiness: Part 2.
Vec2 - What a nice day today: Story of happiness (Part 2)”

# Match the words, not the punctuation.
# Not fully tested

 agrep(What a nice day today Story of happiness Part 2, c(Vec1, Vec2))
[1] 1 2

 agrep(What a nice day today Story of happiness Part 2, c(Vec1, Vec2), 
value = TRUE)
[1] What a nice day today! - Story of happiness: Part 2.
[2] What a nice day today: Story of happiness (Part 2)”  


Also, possibly:

  http://cran.r-project.org/web/packages/stringdist


Regards,

Marc Schwartz

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

Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Dimitri Liakhovitski
I think I found a partial answer:

str_replace_all(x, [[:punct:]],  )

On Mon, Apr 20, 2015 at 9:59 AM, Dimitri Liakhovitski
dimitri.liakhovit...@gmail.com wrote:
 Hello!

 Please point me in the right direction.
 I need to match 2 strings, but focusing ONLY on characters, ignoring
 all special characters and punctuation signs, including (), , etc..

 For example:
 I want the following to return: TRUE

 What a nice day today! - Story of happiness: Part 2. ==
What a nice day today: Story of happiness (Part 2)


 --
 Thank you!
 Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

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


Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread John McKown
On Mon, Apr 20, 2015 at 8:59 AM, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 Hello!

 Please point me in the right direction.
 I need to match 2 strings, but focusing ONLY on characters, ignoring
 all special characters and punctuation signs, including (), , etc..

 For example:
 I want the following to return: TRUE

 What a nice day today! - Story of happiness: Part 2. ==
What a nice day today: Story of happiness (Part 2)


 --
 Thank you!
 Dimitri Liakhovitski



​Perhaps a variation on:

 str1-What a nice day today! - Story of happiness: Part 2.
 str2- What a nice day today: Story of happiness (Part 2)
 gsub('[^[:alpha:]]','',str1)==gsub('[^[:alpha:]]','',str2)
[1] TRUE


The gsub() removes all characters which are not alphabetic from each string
and then compares them.​


-- 
If you sent twitter messages while exploring, are you on a textpedition?

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! 
John McKown

[[alternative HTML version deleted]]

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

Re: [R] Need online version of R help pages

2015-04-20 Thread Paul
Acknowledged, Michael.  I appreciate the pointer to the info.

For at least a short while, however, this is my only access to R, so I
am using this environment to ramp up on times series and R as much a
possible.  I think it should suffice for that purpose, and the real
analysis can occur in a more reliable installation R.  I've managed to
work the ropes on a better installation, but the solution won't be
immediate.

Michael Dewey lists at dewey.myzen.co.uk writes:
| I am not sure how helpful this is going to be but Appendix C7 in the
| Installation and Administration manual is pretty bleak about your
| prospects with Cygwin.
|
|On 18/04/2015 02:17, Paul Domaskis wrote:
| With all due respect, Duncan, I can't find the message advising
| against using the Cygwin port.  I did find a message about the
| mishandling of line endings, and I've asked on the cygwin forum (as
| advised).
|
| As I mentioned, I'm in an environment where updates are not
| possible, and I'm clarifying now that this means installations are
| even more impossible, at least not without extensive adminstrative
| delay.  Basically, this is what I have to work with.  If anyone can
| suggest good ideas for the challenges as-is, that would be much
| appreciated.  However, given your posts, I fully understand if the
| answer is no.  On the other hand, simply demanding a solution
| consisting of a course of action which is impossible at
| present...well, it's just impossible.  Having said that, I'll just
| say that I've managed to exort the powers that be to install a
| Windows based version of R, but I have to work with what I
| currently have for at least a week.  I should also mention that
| I've submitted an update to the mailing list on a workaround for
| the R help problem on cygwin.  It might not have propagated to
| recipients yet.
|
| I appreciate the further info on the extent of the bugginess of the
| cygwin port.
|
| On Fri, Apr 17, 2015 at 9:04 PM, Duncan Murdoch
|murdoch.duncan at gmail.com wrote:
|On 16/04/2015 5:02 PM, paul wrote:
| The help for the cygwin port of R is buggy and hides random lines
| of text.
|
| You've already been told not to use the Cygwin port.  It's buggy
| in the help pages, and probably in many other respects as well.
| It doesn't pass the R self-tests.  Don't use it.
|
|   Consquently, I've been relying on Google, but it is often not
|   clear how directly relevant the info is for the specific
|   command that I'm using.  For example, reshape is complicated,
|   and has more than 1 version.
|
| Is there an online version of the help pages?
|
| I tried looking for html versions of the help pages by ferruting
| through the R.home() subtree.  Haven't found them so far.  There
| are package pages in subdirectories package/html/00Index.html,
| but they just contain links to html files that don't reside in my
| R.home() subtree.  There are also subdirectories package/help,
| but they contain pages that I don't recognize (*.rds, *.rdb,
| *.rdx).
|
| Getting desparate here, and realizing how the web is not in any
| way a substituted for locally available help pages that you can
| be confident is right for your installation.

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


Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Duncan Murdoch
On 20/04/2015 9:59 AM, Dimitri Liakhovitski wrote:
 Hello!
 
 Please point me in the right direction.
 I need to match 2 strings, but focusing ONLY on characters, ignoring
 all special characters and punctuation signs, including (), , etc..
 
 For example:
 I want the following to return: TRUE
 
 What a nice day today! - Story of happiness: Part 2. ==
What a nice day today: Story of happiness (Part 2)
 
 

I would transform both strings using gsub(), then compare.

e.g.

clean - function(s)
  gsub([[:punct:][:blank:]], , s)

clean(What a nice day today! - Story of happiness: Part 2.) ==
clean(What a nice day today: Story of happiness (Part 2))

This completely ignores spaces; you might want something more
sophisticated if you consider today and to day to be different, e.g.

clean - function(s) {
  s - gsub([[:punct:]], , s)
  gsub([[:blank:]]+,  , s)
}

which converts multiple blanks into single spaces.

Duncan Murdoch

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


Re: [R] library(xlsx) fails with an error: Error: package ‘rJava’ could not be loaded

2015-04-20 Thread Hadley Wickham
You might want to try readxl instead, as it doesn't have any external
dependencies.
Hadley

On Sat, Apr 18, 2015 at 3:07 PM, John Sorkin
jsor...@grecc.umaryland.edu wrote:
 Windows 7 64-bit
 R 3.1.3
 RStudio 0.98.1103


 I am having difficulty loading and installing the xlsx package. The
 loading occurred without any problem, however the library command
 library(xlsx) produced an error related to rJava. I tried to install
 rJava seperately, re-loaded the xlsx package, and entered the
 library(xlsx) command but received the same error message about rJave.
 Please see terminal messages below. Any suggestion that would allow me
 to load and run xlsx would be appreciated.
 Thank you,
 John


 install.packages(xlsx)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/xlsx_0.5.7.zip'
 Content type 'application/zip' length 400944 bytes (391 KB)
 opened URL
 downloaded 391 KB


 package ‘xlsx’ successfully unpacked and MD5 sums checked


 The downloaded binary packages are in
 C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
 library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package ‘rJava’ could not be loaded
 install.packages(rJava)
 Installing package into ‘C:/Users/John/Documents/R/win-library/3.1’
 (as ‘lib’ is unspecified)
 trying URL
 'http://cran.rstudio.com/bin/windows/contrib/3.1/rJava_0.9-6.zip'
 Content type 'application/zip' length 759396 bytes (741 KB)
 opened URL
 downloaded 741 KB


 package ‘rJava’ successfully unpacked and MD5 sums checked


 The downloaded binary packages are in
 C:\Users\John\AppData\Local\Temp\Rtmp4CO5m7\downloaded_packages
 library(rJava)
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package or namespace load failed for ‘rJava’
 library(xlsx)
 Loading required package: rJava
 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: inDL(x, as.logical(local), as.logical(now), ...)
   error: unable to load shared object
 'C:/Users/John/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
   LoadLibrary failure:  The specified module could not be found.


 Error: package ‘rJava’ could not be loaded


 John David Sorkin M.D., Ph.D.
 Professor of Medicine
 Chief, Biostatistics and Informatics
 University of Maryland School of Medicine Division of Gerontology and
 Geriatric Medicine
 Baltimore VA Medical Center
 10 North Greene Street
 GRECC (BT/18/GR)
 Baltimore, MD 21201-1524
 (Phone) 410-605-7119
 (Fax) 410-605-7913 (Please call phone number above prior to faxing)


 Confidentiality Statement:
 This email message, including any attachments, is for ...{{dropped:17}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Dimitri Liakhovitski
Hello!

Please point me in the right direction.
I need to match 2 strings, but focusing ONLY on characters, ignoring
all special characters and punctuation signs, including (), , etc..

For example:
I want the following to return: TRUE

What a nice day today! - Story of happiness: Part 2. ==
   What a nice day today: Story of happiness (Part 2)


-- 
Thank you!
Dimitri Liakhovitski

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


Re: [R] list server problem?

2015-04-20 Thread Martin Maechler

 Dear all,
 I use Thunderbird 31.6.0 on Mac OS 10.6.8 to download my e-mails.
 Since this morning, Thunderbird downloads several times the same e-mails 
 from the list, some even being from yesterday. It occurs only with 
 e-mails from the R-help and not with my other professional and private 
 e-mails.

 I also checked that it was not a problem with the server on which I get 
 e-mails from the R-help: the problematic e-mails are erased every time 
 from the server but are received several times. So I would say that the 
 R-help server has sent these e-mails several times.

 I am wondering if there is currently an issue with the R-help server. Is 
 someone else having the same problem?

Not having the same problem, but an explanation
from the place where the server runs:

The R mailing list server indeed has had hard times, as it seems
since early Sunday (CEST), and a complete time out for a few
hours during this morning.  The symptoms have been that some e-mails
were badly delayed and --- as you have experienced --- mail
server timeouts do lead to e-mail being sent more than once.
This is the consequence of a safe e-mail server behavior:  If an
e-mail may have been lost, rather send it again.
As some say:  Better error on the safe side.

Martin Maechler
ETH Zurich


 Thanks!
 Ivan

 -- 
 Ivan Calandra, ATER
 University of Reims Champagne-Ardenne
 51100 Reims, France

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


Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Sven E. Templer
Hi Dimitri,

str_replace_all is not in the base libraries, you could use 'gsub' as well,
for example:

a = What a nice day today! - Story of happiness: Part 2.
b = What a nice day today: Story of happiness (Part 2)
sa = gsub([^A-Za-z0-9], , a)
sb = gsub([^A-Za-z0-9], , b)
a==b
# [1] FALSE
sa==sb
# [1] TRUE

Take care of the extra space in a after the '-', so also replace spaces...

Best,
Sven.

On 20 April 2015 at 16:05, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 I think I found a partial answer:

 str_replace_all(x, [[:punct:]],  )

 On Mon, Apr 20, 2015 at 9:59 AM, Dimitri Liakhovitski
 dimitri.liakhovit...@gmail.com wrote:
  Hello!
 
  Please point me in the right direction.
  I need to match 2 strings, but focusing ONLY on characters, ignoring
  all special characters and punctuation signs, including (), , etc..
 
  For example:
  I want the following to return: TRUE
 
  What a nice day today! - Story of happiness: Part 2. ==
 What a nice day today: Story of happiness (Part 2)
 
 
  --
  Thank you!
  Dimitri Liakhovitski



 --
 Dimitri Liakhovitski

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Charles Determan
You can use the [:alnum:] regex class with gsub.

str1 - What a nice day today! - Story of happiness: Part 2.
str2 - What a nice day today: Story of happiness (Part 2)

gsub([^[:alnum:]], , str1) == gsub([^[:alnum:]], , str2)
[1] TRUE

The same can be done with the stringr package if you really are partial to
it.

library(stringr)





On Mon, Apr 20, 2015 at 9:10 AM, Sven E. Templer sven.temp...@gmail.com
wrote:

 Hi Dimitri,

 str_replace_all is not in the base libraries, you could use 'gsub' as well,
 for example:

 a = What a nice day today! - Story of happiness: Part 2.
 b = What a nice day today: Story of happiness (Part 2)
 sa = gsub([^A-Za-z0-9], , a)
 sb = gsub([^A-Za-z0-9], , b)
 a==b
 # [1] FALSE
 sa==sb
 # [1] TRUE

 Take care of the extra space in a after the '-', so also replace spaces...

 Best,
 Sven.

 On 20 April 2015 at 16:05, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:

  I think I found a partial answer:
 
  str_replace_all(x, [[:punct:]],  )
 
  On Mon, Apr 20, 2015 at 9:59 AM, Dimitri Liakhovitski
  dimitri.liakhovit...@gmail.com wrote:
   Hello!
  
   Please point me in the right direction.
   I need to match 2 strings, but focusing ONLY on characters, ignoring
   all special characters and punctuation signs, including (), , etc..
  
   For example:
   I want the following to return: TRUE
  
   What a nice day today! - Story of happiness: Part 2. ==
  What a nice day today: Story of happiness (Part 2)
  
  
   --
   Thank you!
   Dimitri Liakhovitski
 
 
 
  --
  Dimitri Liakhovitski
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Smart detection of wrap width?

2015-04-20 Thread Paul
Paul Domaskis paul.domaskis at gmail.com writes:
 Yes, I found the width option in the help pages, but I was wondering
 if there was automatic setting of the wrapping according to the
 current window width.
 
 Your function works exactly as I wished.  I'll probably get smarter
 with time (I hope) but would it be reasonably good practice to stick
 this into ~/.Rprofile?  I don't suppose there is a way to have it
 automatically invoked when the window size/positition changes?
 (It's still priceless even without automatic triggering).

Ista Zahn istazahn at gmail.com writes:
 For ESS see
 https://github.com/gaborcsardi/dot-emacs/blob/master/.emacs

Thanks, IstaI'm...errI'm a vim user cowers

Peter Crowther peter.crowther at melandra.com writes:
 Possibly, though it would take a little building.  If you were to
 launch R directly when you start the xterm (loosely xterm R rather
 than the default) then R would receive a SIGWINCH signal whenever
 the xterm window size changes (xterm automatically sends this to its
 child process).  R doesn't directly enable handling of the signal,
 but there's nothing to stop you loading a dynamic library with a
 little C code that set up a handler for SIGWINCH and, when it got
 one, ran the equivalent of the stty command to get the new width.
 The thing I've not been able to figure out is how the C code would
 ever then hand that to R asynchronously.  Anyone?

MacQueen, Don macqueen1 at llnl.gov writes:
 At this point, and since we are in an X windows context, I think it
 might be easier to use the window manager's features and write a
 little macro or something that will send my setwid() command to the
 active window, then assign it to a simple keystroke. Then:  resize
 the window; hit the keystroke, and you're done. True, it's not fully
 automatic, but it would be pretty quick and easy.
 
 Either that or give ESS a try, using the bit that Ista offered. Or
 maybe Rstudio?
 
 Peter's got a good start, but I too would be stymied at the last
 step; definitely beyond my skill.

Peter, Don,

Considering that I've been using Matlab, VBA, and Access for the last
decade, I think that venturing down this path might take quite some
time.  I appreciate the ideas, and if I'm ever in the zone with
programming under the hood with X-windows (which I use), I'll refer
back.  Thanks.

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


Re: [R] lag1.plot {astsa} vs. lag.plot {stats}

2015-04-20 Thread Paul
Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov writes:
| Not certain which plot you are looking at, but my guess is the
| answer is contained somewhere here:
| http://www.stat.pitt.edu/stoffer/tsa3/Rissues.htm in particular
| perhaps issues 4-5.

On Apr 20, 2015, Paul Domaskis paul.domaskis at gmail.com wrote:
| Yup, that's it.  What the stats package refers to as lag is
| time-advancement.  I assume that this odd definition is due to the
| fact that we read from left to right, so a time plot that shifts
| right looks like it's racing ahead, even though it is sliding
| backward along the time axis.  Heck, it's even infused in the way we
| refer to advancing in time, which *often* refers to time
| progression, i.e.  moving rightward along the time access.
| 
| Anyway, the point where this wrinkle occurs in the aforementioned
| tutorial is 
| 
|lag.plot(dljj, 9, do.lines=FALSE)  
|lag1.plot(dljj, 9)  # if you have astsa loaded (not shown) 
| 
| The following code shows the correction to the use of lag.plot so
| that it matches lag1.plot:
| 
|# From tutorial
|lag.plot(dljj, 9, do.lines=FALSE)
| 
|# Correction
|deve.new()
|lag.plot(dljj, set.lags=-1:-9, do.lines=FALSE)
| 
|# astsa's implementation matches above Correctoion
|dev.new()
|lag1.plot(dljj, 9)

By the way, the tsa3 issues page that you reference above...it's
indicates the problems with existing time series functions as the
reason for developing corrected functsion in astsa/tsa3.  But the
actual documentation for these corrected functions are extremely
sparse.  Is there another source of documentation that actually
explains the corrections done?

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


Re: [R] Problem with col

2015-04-20 Thread John Kane



 -Original Message-
 From: soniaam...@gmail.com
 Sent: Mon, 20 Apr 2015 18:56:19 +0200
 To: sarah.gos...@gmail.com
 Subject: Re: [R] Problem with col

 --- clip--
 
 When I type data , I obtain all the numeric values and the headears  I
 added (Consommation,Cylindre,Puissance,Poids)

No you probably do not, as Sarah explained.

As a quick example of the issue look at the two data sets below. Just copy and 
paste into your R editor.  Both data sets are in dput() format which is how you 
should supply sample data to R-help.

ddat1  -   structure(list(aa = structure(1:4, .Label = c(a, b, c,
d), class = factor), bb = 1:4), .Names = c(aa, bb), row.names = c(NA,
-4L), class = data.frame)

ddat2 - structure(list(aa = c(a, b, c, d), bb = c(1, 2, 3, 
4)), .Names = c(aa, bb), row.names = c(NA, -4L), class = data.frame)

If yo do
dat1
dat2
they look the same on the screen but if you do str()  they are not the same.
str(dat1) 
str(dat2)

Also try 
ddat1$bb * 5  #works
ddat2$bb * 5 # error!


They look the same on the computer screen but they are quite different.

John Kane
Kingston ON Canada



 
 Thanks
 
 
 
 2015-04-20 18:40 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:
 
 What is the problem? One or more of your columns was read as factor, as
 
 str(data)
 
 would show you. To avoid this, you can add stringsAsFactors=FALSE to
 the read.table command, but if you expect your data to be entirely
 numeric then there's something wrong with it that you need to hunt
 down.
 
 Sarah
 
 On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com
 wrote:
 Dear All,
 
 I have written the following lines:
 
 
 data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
 = FALSE, sep = )
  colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
  result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
 summary(result.model1)
 
 I obtained the following message:
 
 
 Call:
 lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)
 
 Residuals:
 Error in quantile.default(resid) : factors are not allowed
 In addition: warning message:
 In Ops.factor(r, 2) :
   ‘^’ This is not relevant for factors
 
 
 Where is the problem?
 Thank you in advance
 
 --
 Sarah Goslee
 http://www.functionaldiversity.org
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords  protects your account.

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

Re: [R] lag1.plot {astsa} vs. lag.plot {stats}

2015-04-20 Thread Roy Mendelssohn - NOAA Federal
snip
 
 By the way, the tsa3 issues page that you reference above...it's
 indicates the problems with existing time series functions as the
 reason for developing corrected functsion in astsa/tsa3.  But the
 actual documentation for these corrected functions are extremely
 sparse.  Is there another source of documentation that actually
 explains the corrections done?
 
 __

I would suggest contacting the author. astsa is an R package on CRAN, but I 
don’t think the manual discusses the differences.

-Roy


**
The contents of this message do not reflect any position of the U.S. 
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.
From those who have been given much, much will be expected 
the arc of the moral universe is long, but it bends toward justice -MLK Jr.

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

Re: [R] Problem with col

2015-04-20 Thread Sonia Amin
Thank you very much John I understand the problem.

2015-04-20 19:38 GMT+02:00 John Kane jrkrid...@inbox.com:




  -Original Message-
  From: soniaam...@gmail.com
  Sent: Mon, 20 Apr 2015 18:56:19 +0200
  To: sarah.gos...@gmail.com
  Subject: Re: [R] Problem with col

  --- clip--
 
  When I type data , I obtain all the numeric values and the headears  I
  added (Consommation,Cylindre,Puissance,Poids)

 No you probably do not, as Sarah explained.

 As a quick example of the issue look at the two data sets below. Just copy
 and paste into your R editor.  Both data sets are in dput() format which is
 how you should supply sample data to R-help.

 ddat1  -   structure(list(aa = structure(1:4, .Label = c(a, b, c,
 d), class = factor), bb = 1:4), .Names = c(aa, bb), row.names =
 c(NA,
 -4L), class = data.frame)

 ddat2 - structure(list(aa = c(a, b, c, d), bb = c(1, 2, 3,
 4)), .Names = c(aa, bb), row.names = c(NA, -4L), class = data.frame)

 If yo do
 dat1
 dat2
 they look the same on the screen but if you do str()  they are not the
 same.
 str(dat1)
 str(dat2)

 Also try
 ddat1$bb * 5  #works
 ddat2$bb * 5 # error!


 They look the same on the computer screen but they are quite different.

 John Kane
 Kingston ON Canada



 
  Thanks
 
 
 
  2015-04-20 18:40 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:
 
  What is the problem? One or more of your columns was read as factor, as
 
  str(data)
 
  would show you. To avoid this, you can add stringsAsFactors=FALSE to
  the read.table command, but if you expect your data to be entirely
  numeric then there's something wrong with it that you need to hunt
  down.
 
  Sarah
 
  On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com
  wrote:
  Dear All,
 
  I have written the following lines:
 
 
 
 data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
  = FALSE, sep = )
   colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
   result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
  summary(result.model1)
 
  I obtained the following message:
 
 
  Call:
  lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)
 
  Residuals:
  Error in quantile.default(resid) : factors are not allowed
  In addition: warning message:
  In Ops.factor(r, 2) :
‘^’ This is not relevant for factors
 
 
  Where is the problem?
  Thank you in advance
 
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
 
[[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.

 
 Can't remember your password? Do you need a strong and secure password?
 Use Password manager! It stores your passwords  protects your account.
 Check it out at http://mysecurelogon.com/password-manager




[[alternative HTML version deleted]]

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

Re: [R] Problem with col

2015-04-20 Thread Sonia Amin
Thank you very much Sarah

2015-04-20 19:05 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:

 On Mon, Apr 20, 2015 at 12:56 PM, Sonia Amin soniaam...@gmail.com wrote:
  Sorry Sarah  for my basic question: what does a column was read as
 factor
  mean?

 A factor is one of the basic types of data in R, and in statistics
 generally, eg M/F or red/white/blue - a predetermined set of
 categories that may or may not have an order.

 More relevantly, if there's something wrong in your data, a stray
 letter or quote mark for instance, that column is no longer numeric,
 and R will read it as a factor by default, otherwise as character.

 str(data)

 which is NOT the same as just typing data, will show you the classes
 of your columns, among other things.

  When I type data , I obtain all the numeric values and the headears  I
 added
  (Consommation,Cylindre,Puissance,Poids)

 If you just look at data directly, you'll see what look like numbers,
 perhaps, but according to R one or more columns are not actually
 numbers. That's why you need str(data).

 Your problem looks like a lack of basic understanding of how R works.
 Here are a couple of sources that might help you get started:
 http://www.burns-stat.com/documents/tutorials/impatient-r/
 http://cyclismo.org/tutorial/R/


 For more help, you should provide at least the output of str(data) to
 the list, and ideally a reproducible example. Here are some
 suggestions for creating a good reproducible example:

 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

 Sarah

  Thanks
 
 
 
  2015-04-20 18:40 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:
 
  What is the problem? One or more of your columns was read as factor, as
 
  str(data)
 
  would show you. To avoid this, you can add stringsAsFactors=FALSE to
  the read.table command, but if you expect your data to be entirely
  numeric then there's something wrong with it that you need to hunt
  down.
 
  Sarah
 
  On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com
 wrote:
   Dear All,
  
   I have written the following lines:
  
  
  
 data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
   = FALSE, sep = )
colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
   summary(result.model1)
  
   I obtained the following message:
  
  
   Call:
   lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)
  
   Residuals:
   Error in quantile.default(resid) : factors are not allowed
   In addition: warning message:
   In Ops.factor(r, 2) :
 ‘^’ This is not relevant for factors
  
  
   Where is the problem?
   Thank you in advance
  
  --
  Sarah Goslee
  http://www.functionaldiversity.org
 
 


[[alternative HTML version deleted]]

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

Re: [R] Need online version of R help pages

2015-04-20 Thread Henrik Bengtsson
I don't want to rub it in more, but whatever dark forces are upon you,
they'd have a hard time preventing you from installing R to your user
account, which requires minimal privileges(*).

Just wanted to make sure you're aware of your options

/Henrik

(*) The R Windows installer detects and adjusts for this
automatically. The only things I can think of that prevents this
approach is that the computer is completely disconnected from the
world,  users have extremely limited disk space, the user account is
wiped at every login, ... what else?  Also, AFAIK, the only thing you
miss out on is that R won't be added to the Windows Registry meaning
.RData files are not associated with R, but that's a very low price to
pay considered it's a better option than Cygwin.

On Mon, Apr 20, 2015 at 8:24 AM, Paul paul.domas...@gmail.com wrote:
 John McKown john.archie.mckown at gmail.com writes:
On Mon, Apr 20, 2015 at 9:43 AM, Paul Paul.Domaskis at gmail.com
wrote:

 http://www.tutorialspoint.com/execute_r_online.php

 John, I appreciate the pointer.  I wish the post quoted below had
 made it to the mailing list, as I could have saved you the trouble of
 trying to seek a solution on my behalf.  I'm quite happy using vim
 and in fact consider it to be my right hand (even though I don't dive
 under the hood much).  So this post was really about getting around
 the broken cygwin help facility for R rather than editing.  Also,
 at work, we have to keep the work on-site.

 For those unfortunate enough to have no option but to use cygwin's R,
 here is the posting re. a workaround to the broken help facility,
 posted via nabble (which probably explains why it didn't make it to
 the mailing list):

 Sent: April-16-15 5:51 PM
 Subject: Re: Need online version of R help pages

 I was able to get the help info for many of the commands from the
 link for The R Reference Index at
 http://cran.r-project.org/manuals.html.

 However, I found that I could also get help from the R prompt via

help(myHelpTopic,help_type=html)

 To make that work, I needed options(browser=cygstart) in
 ~/.Rprofile.

 Very puzzling to a non-web-developer like myself: The URL for the
 help content is (for example)
 http://127.0.0.1:16086/library/stats/html/reshape.html.  This is a
 loop-back address.  I did *not* see any file named reshape.html in
 subdirectory library/stats/html/reshape.html when I went to
 R.home().

 I thought that perhaps the file was being composed on the fly.
 However, I was under the distinct impression that my account did not
 have the ability to set up servers (and I assume that the page that
 is composed on the fly must be served out by a server).

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with col

2015-04-20 Thread Sonia Amin
Sorry Sarah  for my basic question: what does a column was read as factor
mean?

When I type data , I obtain all the numeric values and the headears  I
added (Consommation,Cylindre,Puissance,Poids)

Thanks



2015-04-20 18:40 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:

 What is the problem? One or more of your columns was read as factor, as

 str(data)

 would show you. To avoid this, you can add stringsAsFactors=FALSE to
 the read.table command, but if you expect your data to be entirely
 numeric then there's something wrong with it that you need to hunt
 down.

 Sarah

 On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com wrote:
  Dear All,
 
  I have written the following lines:
 
 
 data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
  = FALSE, sep = )
   colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
   result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
  summary(result.model1)
 
  I obtained the following message:
 
 
  Call:
  lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)
 
  Residuals:
  Error in quantile.default(resid) : factors are not allowed
  In addition: warning message:
  In Ops.factor(r, 2) :
‘^’ This is not relevant for factors
 
 
  Where is the problem?
  Thank you in advance
 
 --
 Sarah Goslee
 http://www.functionaldiversity.org


[[alternative HTML version deleted]]

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

Re: [R] Need online version of R help pages

2015-04-20 Thread Paul
Henrik Bengtsson henrik.bengtsson at ucsf.edu writes:
 I don't want to rub it in more, but whatever dark forces are upon
 you, they'd have a hard time preventing you from installing R to
 your user account, which requires minimal privileges(*).
 
 Just wanted to make sure you're aware of your options
 
 /Henrik
 
 (*) The R Windows installer detects and adjusts for this
 automatically. The only things I can think of that prevents this
 approach is that the computer is completely disconnected from the
 world,  users have extremely limited disk space, the user account is
 wiped at every login, ... what else?  Also, AFAIK, the only thing
 you miss out on is that R won't be added to the Windows Registry
 meaning .RData files are not associated with R, but that's a very
 low price to pay considered it's a better option than Cygwin.

It's simply not allowed.  However, as I said, this is being worked
out.

It is *very* useful to know that when things work out, it *can* be
installed as non-administrator.  That would be infinitely less
headache.  Thanks.

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


Re: [R] lag1.plot {astsa} vs. lag.plot {stats}

2015-04-20 Thread Paul
On Apr 17, 2015, at 7:30 PM, Paul Domaskis paul.domaskis at
gmail.com wrote:
 I'm following http://www.stat.pitt.edu/stoffer/tsa3/R_toot.htm to
 ramp up on both time series and R.  About 40% of the way down, the
 tutorial uses lag1.plot from astsa and lag.plot from stats.  The
 positioning of the dots look different between the two.  Nothing
 jumps out at me from the help pages that explains why they would be
 different.  Can anyone confirm this difference, and hopefully
 suggest explanations?

Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov writes:
 Not certain which plot you are looking at, but my guess is the
 answer is contained somewhere here:
 http://www.stat.pitt.edu/stoffer/tsa3/Rissues.htm in particular
 perhaps issues 4-5.

Yup, that's it.  What the stats package refers to as lag is
time-advancement.  I assume that this odd definition is due to the
fact that we read from left to right, so a time plot that shifts right
looks like it's racing ahead, even though it is sliding backward along
the time axis.  Heck, it's even infused in the way we refer to
advancing in time, which *often* refers to time progression, i.e.
moving rightward along the time access.

Anyway, the point where this wrinkle occurs in the aforementioned
tutorial is 

   lag.plot(dljj, 9, do.lines=FALSE)  
   lag1.plot(dljj, 9)  # if you have astsa loaded (not shown) 

The following code shows the correction to the use of lag.plot so that
it matches lag1.plot:

   # From tutorial
   lag.plot(dljj, 9, do.lines=FALSE)

   # Correction
   deve.new()
   lag.plot(dljj, set.lags=-1:-9, do.lines=FALSE)

   # astsa's implementation matches above Correctoion
   dev.new()
   lag1.plot(dljj, 9)

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


Re: [R] groupedData HELP!

2015-04-20 Thread peter dalgaard

On 20 Apr 2015, at 17:50 , CHIRIBOGA Xavier xavier.chirib...@unine.ch wrote:

 Dear members,
 
 
 
 what to do when this appears ?
 
 
 
 Error: could not find function groupedData
 
 

This should be a good start:

RSiteSearch(groupedData)


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

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

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Problem with col

2015-04-20 Thread Sonia Amin
Dear All,

I have written the following lines:

 
data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
= FALSE, sep = )
 colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
 result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
summary(result.model1)

I obtained the following message:


Call:
lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)

Residuals:
Error in quantile.default(resid) : factors are not allowed
In addition: warning message:
In Ops.factor(r, 2) :
  ‘^’ This is not relevant for factors


Where is the problem?
Thank you in advance

[[alternative HTML version deleted]]

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

Re: [R] Problem with col

2015-04-20 Thread Sarah Goslee
What is the problem? One or more of your columns was read as factor, as

str(data)

would show you. To avoid this, you can add stringsAsFactors=FALSE to
the read.table command, but if you expect your data to be entirely
numeric then there's something wrong with it that you need to hunt
down.

Sarah

On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com wrote:
 Dear All,

 I have written the following lines:

  
 data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
 = FALSE, sep = )
  colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
  result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
 summary(result.model1)

 I obtained the following message:


 Call:
 lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)

 Residuals:
 Error in quantile.default(resid) : factors are not allowed
 In addition: warning message:
 In Ops.factor(r, 2) :
   ‘^’ This is not relevant for factors


 Where is the problem?
 Thank you in advance

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

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

Re: [R] Problem with col

2015-04-20 Thread Sarah Goslee
On Mon, Apr 20, 2015 at 12:56 PM, Sonia Amin soniaam...@gmail.com wrote:
 Sorry Sarah  for my basic question: what does a column was read as factor
 mean?

A factor is one of the basic types of data in R, and in statistics
generally, eg M/F or red/white/blue - a predetermined set of
categories that may or may not have an order.

More relevantly, if there's something wrong in your data, a stray
letter or quote mark for instance, that column is no longer numeric,
and R will read it as a factor by default, otherwise as character.

str(data)

which is NOT the same as just typing data, will show you the classes
of your columns, among other things.

 When I type data , I obtain all the numeric values and the headears  I added
 (Consommation,Cylindre,Puissance,Poids)

If you just look at data directly, you'll see what look like numbers,
perhaps, but according to R one or more columns are not actually
numbers. That's why you need str(data).

Your problem looks like a lack of basic understanding of how R works.
Here are a couple of sources that might help you get started:
http://www.burns-stat.com/documents/tutorials/impatient-r/
http://cyclismo.org/tutorial/R/


For more help, you should provide at least the output of str(data) to
the list, and ideally a reproducible example. Here are some
suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Sarah

 Thanks



 2015-04-20 18:40 GMT+02:00 Sarah Goslee sarah.gos...@gmail.com:

 What is the problem? One or more of your columns was read as factor, as

 str(data)

 would show you. To avoid this, you can add stringsAsFactors=FALSE to
 the read.table command, but if you expect your data to be entirely
 numeric then there's something wrong with it that you need to hunt
 down.

 Sarah

 On Mon, Apr 20, 2015 at 12:33 PM, Sonia Amin soniaam...@gmail.com wrote:
  Dear All,
 
  I have written the following lines:
 
 
  data-read.table(C:\\Users\\intel\\Documents\\SIIID\\datamultiplereg.txt,header
  = FALSE, sep = )
   colnames(data)-c(Consommation,Cylindre,Puissance,Poids)
   result.model1-lm(Consommation~Cylindre+Puissance+Poids, data=data)
  summary(result.model1)
 
  I obtained the following message:
 
 
  Call:
  lm(formula = Consommation ~ Cylindre + Puissance + Poids, data = data)
 
  Residuals:
  Error in quantile.default(resid) : factors are not allowed
  In addition: warning message:
  In Ops.factor(r, 2) :
‘^’ This is not relevant for factors
 
 
  Where is the problem?
  Thank you in advance
 
 --
 Sarah Goslee
 http://www.functionaldiversity.org



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

Re: [R] color handling in `barplot' inconsistent betwen `beside=FALSE' and `beside=TRUE'

2015-04-20 Thread Marc Schwartz
On Apr 20, 2015, at 10:01 AM, j. van den hoff veedeeh...@googlemail.com wrote:
 
 hi,
 
 consider the following example:
 
 8-
 x - matrix(1:6, 3, 2)
 layout(1:2)
 barplot(x, beside = TRUE, col = 1:6)
 barplot(x, beside = FALSE, col = 1:6)
 8-
 
 it seems, it is not possible to make `beside=FAlSE' plots behave the same as 
 `beside=TRUE' plots (i.e. use unique colors for all bars or bar components), 
 or is it? if I do not miss something, I would say the present behaviour (as 
 of 3.1.3) is not (or not always, anyway) desirable. rather, `beside=FALSE' 
 should use the same color for all bars or bar components as `beside=TRUE'.
 
 any opionions on that?
 
 in case someone needs this, the following patch achieves what I would expect 
 from `barplot(beside=FALSE, ...)' -- at least w.r.t. colors, if not shading 
 ... -- in the first place:
 
 8---
 @@ -96,12 +96,12 @@
 if (beside)
 w.m - matrix(w.m, ncol = NC)
 if (plot) {
 -dev.hold()
 +###dev.hold()
 opar - if (horiz)
 par(xaxs = i, xpd = xpd)
 else par(yaxs = i, xpd = xpd)
 on.exit({
 -dev.flush()
 +###dev.flush()
 par(opar)
 })
 if (!add) {
 @@ -119,10 +119,16 @@
 w.r, horizontal = horiz, angle = angle, density = density,
 col = col, border = border)
 else {
 +numelements - length(height[-1,])
 +numcols - length(col)
 +if (numelements != numcols)
 +   col - rep_len(col, ceiling(numelements/numcols))
 +col - col[1:numelements]
 +attr(col, dim) - dim(height[-1,])
 for (i in 1L:NC) {
 xyrect(height[1L:NR, i] + offset[i], w.l[i],
   height[-1, i] + offset[i], w.r[i], horizontal = horiz,
 -  angle = angle, density = density, col = col,
 +  angle = angle, density = density, col = col[1:NR, i],
   border = border)
 }
 }
 8---
 
 (please note that this is the diff for the representation of the function as 
 it appears in `edit(barplot)', rather than as it appears in the R source code 
 ...)
 
 @devs: would it be desirable to change the official `barplot' behaviour 
 accordingly in the future?
 
 
 thanks
 
 joerg


Hi,

You can go the other way:

  layout(1:2)
  barplot(x, beside = FALSE, col = 1:3)
  barplot(x, beside = TRUE, col = rep(1:3, 2))


You could use the following workaround:

  barplot(cbind(1:3, c(NA, NA, NA)), beside = FALSE, col = 1:3, ylim = c(0, 15))
  barplot(cbind(c(NA, NA, NA), 4:6), beside = FALSE, col = 4:6, add = TRUE)

That essentially plots each stack separately, using the respective NA columns 
to space the two stacks in the plot. In the first call, also setting the y axis 
limits to handle both stacks. In the second call, using ‘add = TRUE’ so that 
the second plot does not overwrite the first.

The use of stacked bar plots is typical when trying to visually compare the 
same categories across groupings, thus the same colors in each stack by 
default. This is not always easy if the differences are subtle, similar to the 
issues with pie charts.

I would not advocate changing the current behavior, as a lot of long standing 
code would break, including functions in packages that are built on top of 
barplot() and expect certain default behaviors.

You can always make a local modification of barplot() for your own use and/or 
consider that there might be a logical CRAN package for graphics extensions 
where it could be included as an add-on function.

Regards,

Marc Schwartz

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

Re: [R] color handling in `barplot' inconsistent betwen `beside=FALSE' and `beside=TRUE'

2015-04-20 Thread j. van den hoff
On Mon, 20 Apr 2015 18:10:10 +0200, Marc Schwartz marc_schwa...@me.com  
wrote:


On Apr 20, 2015, at 10:01 AM, j. van den hoff  
veedeeh...@googlemail.com wrote:


hi,

consider the following example:

8-
x - matrix(1:6, 3, 2)
layout(1:2)
barplot(x, beside = TRUE, col = 1:6)
barplot(x, beside = FALSE, col = 1:6)
8-

it seems, it is not possible to make `beside=FAlSE' plots behave the  
same as `beside=TRUE' plots (i.e. use unique colors for all bars or bar  
components), or is it? if I do not miss something, I would say the  
present behaviour (as of 3.1.3) is not (or not always, anyway)  
desirable. rather, `beside=FALSE' should use the same color for all  
bars or bar components as `beside=TRUE'.


any opionions on that?

in case someone needs this, the following patch achieves what I would  
expect from `barplot(beside=FALSE, ...)' -- at least w.r.t. colors, if  
not shading ... -- in the first place:


8---
@@ -96,12 +96,12 @@
if (beside)
w.m - matrix(w.m, ncol = NC)
if (plot) {
-dev.hold()
+###dev.hold()
opar - if (horiz)
par(xaxs = i, xpd = xpd)
else par(yaxs = i, xpd = xpd)
on.exit({
-dev.flush()
+###dev.flush()
par(opar)
})
if (!add) {
@@ -119,10 +119,16 @@
w.r, horizontal = horiz, angle = angle, density =  
density,

col = col, border = border)
else {
+numelements - length(height[-1,])
+numcols - length(col)
+if (numelements != numcols)
+   col - rep_len(col, ceiling(numelements/numcols))
+col - col[1:numelements]
+attr(col, dim) - dim(height[-1,])
for (i in 1L:NC) {
xyrect(height[1L:NR, i] + offset[i], w.l[i],
  height[-1, i] + offset[i], w.r[i], horizontal = horiz,
-  angle = angle, density = density, col = col,
+  angle = angle, density = density, col = col[1:NR, i],
  border = border)
}
}
8---

(please note that this is the diff for the representation of the  
function as it appears in `edit(barplot)', rather than as it appears in  
the R source code ...)


@devs: would it be desirable to change the official `barplot'  
behaviour accordingly in the future?



thanks

joerg



Hi,


hi,

thanks for responding.


You can go the other way:

  layout(1:2)
  barplot(x, beside = FALSE, col = 1:3)
  barplot(x, beside = TRUE, col = rep(1:3, 2))


well, that would make it consistent but it is not what I want, actually  
...





You could use the following workaround:

  barplot(cbind(1:3, c(NA, NA, NA)), beside = FALSE, col = 1:3, ylim =  
c(0, 15))
  barplot(cbind(c(NA, NA, NA), 4:6), beside = FALSE, col = 4:6, add =  
TRUE)


That essentially plots each stack separately, using the respective NA  
columns to space the two stacks in the plot. In the first call, also  
setting the y axis limits to handle both stacks. In the second call,  
using ‘add = TRUE’ so that the second plot does not overwrite the first.


yes, I see. that indeed would work. however, in my actual use case, I have  
a looong time series with dozens of bars. so it would become quite ugly  
(looping over all the bars subsetting the color vector etc). but yes, one  
could do it this way.




The use of stacked bar plots is typical when trying to visually compare  
the same categories across groupings, thus the same colors in each stack  
by default. This is not always easy if the differences are subtle,  
similar to the issues with pie charts.


I would not advocate changing the current behavior, as a lot of long  
standing code would break, including functions in packages that are  
built on top of barplot() and expect certain default behaviors.


yes, I was expecting this answer and I understand it, of course. on the  
other hand, it would be rather straightforward to add another argument to  
`barplot' to control the behaviour (while defaulting to the present one).  
I would think this would be a good addition: in my use case, e.g. I do  
have such categorized and grouped data and just want to be able to plot  
them after sorting within each group according to value while maintaining   
unique color assignments independent of whether the data are sorted within  
each group or not. and with `beside=FALSE'  this is completely  
straightforward (just resort the color vector together with the data),  
while it fails with `beside=TRUE'.




You can always make a local modification of barplot() for your own use


yes, that's what I did. but I wonder how many people would benefit from  
the ability of easily plotting the same data with the same color vs. data  
correspondence independent of the `beside' setting. but it's for the devs  
to decide...


and/or 

Re: [R] regexpr - ignore all special characters and punctuation in a string

2015-04-20 Thread Dimitri Liakhovitski
Thanks a lot, everybody for excellent suggestions!

On Mon, Apr 20, 2015 at 10:15 AM, Charles Determan
cdeterma...@gmail.com wrote:
 You can use the [:alnum:] regex class with gsub.

 str1 - What a nice day today! - Story of happiness: Part 2.
 str2 - What a nice day today: Story of happiness (Part 2)

 gsub([^[:alnum:]], , str1) == gsub([^[:alnum:]], , str2)
 [1] TRUE

 The same can be done with the stringr package if you really are partial to
 it.

 library(stringr)





 On Mon, Apr 20, 2015 at 9:10 AM, Sven E. Templer sven.temp...@gmail.com
 wrote:

 Hi Dimitri,

 str_replace_all is not in the base libraries, you could use 'gsub' as
 well,
 for example:

 a = What a nice day today! - Story of happiness: Part 2.
 b = What a nice day today: Story of happiness (Part 2)
 sa = gsub([^A-Za-z0-9], , a)
 sb = gsub([^A-Za-z0-9], , b)
 a==b
 # [1] FALSE
 sa==sb
 # [1] TRUE

 Take care of the extra space in a after the '-', so also replace spaces...

 Best,
 Sven.

 On 20 April 2015 at 16:05, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:

  I think I found a partial answer:
 
  str_replace_all(x, [[:punct:]],  )
 
  On Mon, Apr 20, 2015 at 9:59 AM, Dimitri Liakhovitski
  dimitri.liakhovit...@gmail.com wrote:
   Hello!
  
   Please point me in the right direction.
   I need to match 2 strings, but focusing ONLY on characters, ignoring
   all special characters and punctuation signs, including (), , etc..
  
   For example:
   I want the following to return: TRUE
  
   What a nice day today! - Story of happiness: Part 2. ==
  What a nice day today: Story of happiness (Part 2)
  
  
   --
   Thank you!
   Dimitri Liakhovitski
 
 
 
  --
  Dimitri Liakhovitski
 
  __
  R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
  https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





-- 
Dimitri Liakhovitski

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


Re: [R] Need online version of R help pages

2015-04-20 Thread Paul
John McKown john.archie.mckown at gmail.com writes:
On Mon, Apr 20, 2015 at 9:43 AM, Paul Paul.Domaskis at gmail.com
wrote:
 
 http://www.tutorialspoint.com/execute_r_online.php

John, I appreciate the pointer.  I wish the post quoted below had
made it to the mailing list, as I could have saved you the trouble of
trying to seek a solution on my behalf.  I'm quite happy using vim
and in fact consider it to be my right hand (even though I don't dive
under the hood much).  So this post was really about getting around
the broken cygwin help facility for R rather than editing.  Also,
at work, we have to keep the work on-site.

For those unfortunate enough to have no option but to use cygwin's R,
here is the posting re. a workaround to the broken help facility,
posted via nabble (which probably explains why it didn't make it to
the mailing list):

 Sent: April-16-15 5:51 PM
 Subject: Re: Need online version of R help pages
 
 I was able to get the help info for many of the commands from the
 link for The R Reference Index at
 http://cran.r-project.org/manuals.html. 
 
 However, I found that I could also get help from the R prompt via 
 
help(myHelpTopic,help_type=html) 
 
 To make that work, I needed options(browser=cygstart) in
 ~/.Rprofile. 
 
 Very puzzling to a non-web-developer like myself: The URL for the
 help content is (for example)
 http://127.0.0.1:16086/library/stats/html/reshape.html.  This is a
 loop-back address.  I did *not* see any file named reshape.html in
 subdirectory library/stats/html/reshape.html when I went to
 R.home(). 
 
 I thought that perhaps the file was being composed on the fly.
 However, I was under the distinct impression that my account did not
 have the ability to set up servers (and I assume that the page that
 is composed on the fly must be served out by a server).

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] groupedData HELP!

2015-04-20 Thread CHIRIBOGA Xavier
Dear members,



what to do when this appears ?



Error: could not find function groupedData



Thanks a lot,

Xavier

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


Re: [R-es] Integración de R y C#

2015-04-20 Thread Pedro Herrero Petisco
Muchas gracias Javier.
Sí, ya he encontrado el hilo y fuiste tú con este enlace:
http://www.gisandchips.org/2009/09/21/integracion-de-r-en-aplicaciones-de-escritorio-r-rcom-y-c/

La verdad es que en un primer vistazo no he entendido demasiado del link
que has pasado de rdotnet, pero supongo que es porque me falta base de .NET
y C# (además de no haber podido dedicarle mucho tiempo).

Muchas gracias por la información :-)

Un saludo

El 17 de abril de 2015, 17:31, Javier Marcuzzi 
javier.ruben.marcu...@gmail.com escribió:

 Estimado Pedro Herrero Petisco

 Creo que yo puse algo, no recuerdo bien pero debe ser
 https://rdotnet.codeplex.com/

 Javier Rubén Marcuzzi

 El 17 de abril de 2015, 9:20, Pedro Herrero Petisco 
 pedroherreropeti...@gmail.com escribió:

 Hola a todos.

 Se me está plantendo la posibilidad de empezar a aprender C# para hacer
 algunos programillas (nada grande).
 El tema es que el otro día en un mail de esta misma lista alguien (lo
 siento, no recuerdo quien) puso un link a un post en el que se hablaba de
 la integración entre R y C#.

 Por supuesto para llegar a poder hacer esto primero tengo que entender las
 bases de .NET y C#, pero me gustaría saber si alguno lo habéis utilizado y
 hasta que punto es posible ejecutar código de R en C# y que limitaciones
 tiene.

 Como primer punto me imagino que será necesario tener instalado R en el
 mismo ordenador que se vaya a ejecutar el programa creado en C#, pero...
 ¿sería posible crear una aplicación de escritorio que funcione en
 cualquier
 PC simplemente teniendo instalado R?

 Lo mismo estoy preguntando una tontería pero como digo apenas he visto un
 par de manuales pero ya me lo están preguntando en mi entorno.

 Muchas gracias a todo

 [[alternative HTML version deleted]]

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es




[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread William Dunlap
The hyphen without a following digit confuses tidyr::extract_numeric().
E.g.,
extract_numeric(23 ft-lbs)
   Warning message:
   In extract_numeric(23 ft-lbs) : NAs introduced by coercion
   [1] NA
extract_numeric(23 ft*lbs)
   [1] 23
Contact the BugReports address for the package
packageDescription(tidyr)$BugReports
   [1] https://github.com/hadley/tidyr/issues;
or package's maintainer
maintainer(tidyr)
   [1] Hadley Wickham had...@rstudio.com
to report problems in a user-contributed package.



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Apr 20, 2015 at 12:10 AM, arnaud gaboury arnaud.gabo...@gmail.com
wrote:

 R 3.2.0 on Linux
 

 library(tidyr)

 playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
 Portals Visited 1,038,
 XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed 11,126,
 Links Created 1,744, Control Fields Created 294, Mind Units
 Captured 2,995,484 MUs,
 Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
 XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
 Captured 486,
 Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
 Links Destroyed 3,169,
 Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
 Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
 Max Link Length x Days 276 km-days, Max Time Field Held 4days,
 Largest Field MUs x Days 83,226 MU-days)


 ---
  extract_numeric(playerStats)
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15 NA
4 NA


 
  playerStats[c(22,24)]
 [1] Max Link Length x Days 276 km-days  Largest Field MUs x
 Days 83,226 MU-days

 

 I do not understand why these two vectors return NA when the function
 extract_numeric() works well for others,

 Any wrong settings in my env?

 Thank you for hints.



 --

 google.com/+arnaudgabourygabx

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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-es] Como leer una BD con una estructura inadecuada

2015-04-20 Thread Patricio Fuenmayor Viteri
Hola Eric.Le detallo que es lo que yo hago en estos casos.Identificar el tipo 
de archivo, es decir, que separadores de columnas tiene ?, que tipo de datos 
debe tener cada variable?, etc.Si el archivo es muy grande y un editor de texto 
(como Note++) no lo puede abrir por temas de memoria, puede usar un programa 
adecuado para esto. Yo uso glogg (http://glogg.bonnefon.org/) que me ha 
permitido abrir archivos de texto de hasta 3 GbSi no tiene delimitadores, puede 
usar la opci�n de carga, campos de ancho fijo, en donde usted debe dar las 
longitudes de las variables.Si no puede identificar claramente los tipos de 
datos o los valores por defecto, cargue la variable como character, para que 
luego con las funciones adecuadas, pueda transformarla y obtener los tipo de 
valor y variables deseados.Con respecto a los espacios, c�rgelos como le 
explique, y luego transforme a la variable reemplazando los mismos con la 
funcion grepl y si es mas complicado con una expresi�n regular.Los paquetes que 
le pueden ser de ayuda: data.table (funcion fread), readr, stringr.Espero le 
sirva.Saludos. 
--Archivo adjunto de mensaje reenviado--
From: c...@qualityexcellence.es
CC: r-help-es@r-project.org
To: ericconchamu...@gmail.com
Date: Mon, 20 Apr 2015 11:42:03 +0200
Subject: Re: [R-es] Como leer una BD con una estructura inadecuada
 El 18 de abril de 2015, 20:03, eric ericconchamu...@gmail.com
 mailto:ericconchamu...@gmail.com escribi�:


 Estimados, tengo el siguiente problema:

 Tengo una BD de 19 columnas y aprox 500 mil filas, la que tiene
 muchas celdas vacias y esta separada con espacios para hacer
 coincidir los datos bajo los encabezados.

 Mi problema es que al tratar de importar a R la BD no se como tratar
 con los espacios vacios cuando se trata de una columna de numeros
 (para el texto puse na.strings = NA) y tampoco se como hacer para
 que al leer cada dato este asociado al encabezado correcto, pues el
 numero de espacios que esta puesto entre cada dato varia de acuerdo
 a la extension en caracteres del dato (hay numeros, nombres, etc).
 Incluso hay encabezados de dos palabras y parece que R los considera
 dos encabezados distintos. Me explico ?

 Como puedo hacer para leer la BD correctamente ? Alguna idea ??

 Adjunto un archivo de muestra.

 Muchas gracias.

 Eric.




 --
 Forest Engineer
 Master in Environmental and Natural Resource Economics
 Ph.D. student in Sciences of Natural Resources at La Frontera
 University
 Member in AguaDeTemu2030, citizen movement for Temuco with green
 city standards for living

 Nota: Las tildes se han omitido para asegurar compatibilidad con
 algunos lectores de correo.

 ___
 R-help-es mailing list
 R-help-es@r-project.org mailto:R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es



  
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread arnaud gaboury
On Mon, Apr 20, 2015 at 6:09 PM, William Dunlap wdun...@tibco.com wrote:

 The hyphen without a following digit confuses tidyr::extract_numeric().
 E.g.,
 extract_numeric(23 ft-lbs)
Warning message:
In extract_numeric(23 ft-lbs) : NAs introduced by coercion
[1] NA
 extract_numeric(23 ft*lbs)
[1] 23


See[0] for the reason on the minus in the regex. It is not a bug but a wish.
I am honestly very surprised the maintainer decided to go with such a so
simple solution for negative numbers.

[0]https://github.com/hadley/tidyr/issues/20

Contact the BugReports address for the package
 packageDescription(tidyr)$BugReports
[1] https://github.com/hadley/tidyr/issues;
 or package's maintainer
 maintainer(tidyr)
[1] Hadley Wickham had...@rstudio.com
 to report problems in a user-contributed package.



 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com

 On Mon, Apr 20, 2015 at 12:10 AM, arnaud gaboury arnaud.gabo...@gmail.com
  wrote:

 R 3.2.0 on Linux
 

 library(tidyr)

 playerStats - c(LVL 10, 5,671,448 AP l6,000,000 AP, Unique
 Portals Visited 1,038,
 XM Collected 15,327,123 XM, Hacks 14,268, Resonators Deployed
 11,126,
 Links Created 1,744, Control Fields Created 294, Mind Units
 Captured 2,995,484 MUs,
 Longest Link Ever Created 75 km, Largest Control Field 189,731 MUs,
 XM Recharged 3,006,364 XM, Portals Captured 1,204, Unique Portals
 Captured 486,
 Resonators Destroyed 12,481, Portals Neutralized 1,240, Enemy
 Links Destroyed 3,169,
 Enemy Control Fields Destroyed 1,394, Distance Walked 230 km,
 Max Time Portal Held 240 days, Max Time Link Maintained 15 days,
 Max Link Length x Days 276 km-days, Max Time Field Held 4days,
 Largest Field MUs x Days 83,226 MU-days)


 ---
  extract_numeric(playerStats)
  [1] 10 5671448600   1038   15327123
14268  11126   17442942995484
 [10] 75 1897313006364   1204
  486  12481   1240   3169   1394
 [19]230240 15 NA
4 NA


 
  playerStats[c(22,24)]
 [1] Max Link Length x Days 276 km-days  Largest Field MUs x
 Days 83,226 MU-days

 

 I do not understand why these two vectors return NA when the function
 extract_numeric() works well for others,

 Any wrong settings in my env?

 Thank you for hints.



 --

 google.com/+arnaudgabourygabx

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





-- 

google.com/+arnaudgabourygabx
https://plus.google.com/_/notifications/emlink?emr=05814804238976922326emid=CKiv-v6PvboCFcfoQgod6msAAApath=%2F116159236040461325607%2Fop%2Fudt=1383086841306ub=50

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] feature selection

2015-04-20 Thread ismail hakkı sonalcan
Hi,

I want to make feature selection.
Could you help me.

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


Re: [R] R code/package for calculation of Wasserstein distance between two densities

2015-04-20 Thread Dennis Murphy
Hi Ranjan:

Try this:

library(sos)
findFn(Wasserstein)

It appears there are three packages that might be relevant:
HistDAWass, transport and TDA.

HTH,
Dennis

On Sat, Apr 18, 2015 at 8:06 PM, Ranjan Maitra
maitra.mbox.igno...@inbox.com wrote:
 Dear friends,

 Before reinventing the wheel, I was wondering if anyone can point me to code 
 for calculating the Wasserstein distance between two densities. I am 
 particularly interested in mixture densities (in functional form). I know 
 that we have the earthmovers distance in R via the emdist package but it 
 appears to me upon a quick look that this can not handle densities in 
 functional form. So, I was wondering if anyone had any ideas on code for this 
 problem.

 Many thanks and best wishes,
 Ranjan

 
 Can't remember your password? Do you need a strong and secure password?
 Use Password manager! It stores your passwords  protects your account.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] misbehavior with extract_numeric() from tidyr

2015-04-20 Thread Hadley Wickham
On Mon, Apr 20, 2015 at 1:57 PM, arnaud gaboury
arnaud.gabo...@gmail.com wrote:
 On Mon, Apr 20, 2015 at 6:09 PM, William Dunlap wdun...@tibco.com wrote:

 The hyphen without a following digit confuses tidyr::extract_numeric().
 E.g.,
 extract_numeric(23 ft-lbs)
Warning message:
In extract_numeric(23 ft-lbs) : NAs introduced by coercion
[1] NA
 extract_numeric(23 ft*lbs)
[1] 23


 See[0] for the reason on the minus in the regex. It is not a bug but a wish.
 I am honestly very surprised the maintainer decided to go with such a so
 simple solution for negative numbers.

 [0]https://github.com/hadley/tidyr/issues/20

Any heuristic is going to fail in some circumstances. If you want to
be sure it's doing what you want for your use case, write the regular
expression yourself.

Hadley

-- 
http://had.co.nz/

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


Re: [R-es] Integración de R y C#

2015-04-20 Thread Javier Marcuzzi
Estimado Pedro

Hay una cosa buena, o práctica, desde visual studio puede usar nuget, este
instala lo que necesita, ej código fuente de la parte de R y C# es el link
que le envié.

Javier

El 20 de abril de 2015, 12:56, Pedro Herrero Petisco 
pedroherreropeti...@gmail.com escribió:

 Muchas gracias Javier.
 Sí, ya he encontrado el hilo y fuiste tú con este enlace:
 http://www.gisandchips.org/2009/09/21/integracion-de-r-en-aplicaciones-de-escritorio-r-rcom-y-c/

 La verdad es que en un primer vistazo no he entendido demasiado del link
 que has pasado de rdotnet, pero supongo que es porque me falta base de .NET
 y C# (además de no haber podido dedicarle mucho tiempo).

 Muchas gracias por la información :-)

 Un saludo

 El 17 de abril de 2015, 17:31, Javier Marcuzzi 
 javier.ruben.marcu...@gmail.com escribió:

 Estimado Pedro Herrero Petisco

 Creo que yo puse algo, no recuerdo bien pero debe ser
 https://rdotnet.codeplex.com/

 Javier Rubén Marcuzzi

 El 17 de abril de 2015, 9:20, Pedro Herrero Petisco 
 pedroherreropeti...@gmail.com escribió:

 Hola a todos.

 Se me está plantendo la posibilidad de empezar a aprender C# para hacer
 algunos programillas (nada grande).
 El tema es que el otro día en un mail de esta misma lista alguien (lo
 siento, no recuerdo quien) puso un link a un post en el que se hablaba de
 la integración entre R y C#.

 Por supuesto para llegar a poder hacer esto primero tengo que entender
 las
 bases de .NET y C#, pero me gustaría saber si alguno lo habéis utilizado
 y
 hasta que punto es posible ejecutar código de R en C# y que limitaciones
 tiene.

 Como primer punto me imagino que será necesario tener instalado R en el
 mismo ordenador que se vaya a ejecutar el programa creado en C#, pero...
 ¿sería posible crear una aplicación de escritorio que funcione en
 cualquier
 PC simplemente teniendo instalado R?

 Lo mismo estoy preguntando una tontería pero como digo apenas he visto un
 par de manuales pero ya me lo están preguntando en mi entorno.

 Muchas gracias a todo

 [[alternative HTML version deleted]]

 ___
 R-help-es mailing list
 R-help-es@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-help-es





[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] problem with CSV and R

2015-04-20 Thread Nino David Jordan
I get the same error message when I try to edit a data frame on the basis of
a .csv file.



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

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


Re: [R] feature selection

2015-04-20 Thread Charles Determan
Although I am sure many here would be happy to help you your question is
far too vague.  There are many methods for feature selection.  You should
review the literature and see what would work best for you or consult a
statistician.  Once you have selected a method and began an initial attempt
at the R code then this list will be far more helpful to you.  This help
list is meant to help people with their R programming not design their
analysis for them.

Some places to start with R include the very popular 'caret' package.  Max
Kuhn (the author) has a wonderful website with many tutorials.  Here is the
front page for feature selection,
http://topepo.github.io/caret/featureselection.html

I also have developed a package on Bioconductor called 'OmicsMarkeR' which
you can find at
http://bioconductor.org/packages/release/bioc/html/OmicsMarkeR.html that
you may find useful depending upon the data you possess.

Regards,
Charles

On Mon, Apr 20, 2015 at 12:19 PM, ismail hakkı sonalcan 
ismaelhakk...@hotmail.com wrote:

 Hi,

 I want to make feature selection.
 Could you help me.

 Thanks.

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] (no subject)

2015-04-20 Thread Paul
Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov writes:
| By the way, the tsa3 issues page that you reference above...it's
| indicates the problems with existing time series functions as the
| reason for developing corrected functsion in astsa/tsa3.  But the
| actual documentation for these corrected functions are extremely
| sparse.  Is there another source of documentation that actually
| explains the corrections done?
|
| I would suggest contacting the author. astsa is an R package on
| CRAN, but I don’t think the manual discusses the differences.

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

  1   2   >