[R] pasteFromExcel

2014-10-20 Thread Dan Murphy
To Users of Excel:

Following advice from Brian and Markus, I created an RMarkdown vignette
that shows an example of how the pasteFromExcel function in the excelRio
package on github could be used by an actuary to transfer a triangle from
Excel to R. See today's post at http://trinostics.blogspot.com/

Unfortunately, if you are located outside the US, the demonstrated
functionality will not work for you because the currency regex implemented
assumes the dollar sign ($) and comma/decimal punctuation of the form
999,999.00.

If anyone is interested in contributing currency regex expressions that
work in your locale, I would be happy to try to incorporate them in the
package. If anyone knows how best to determine the user's locale (might
timezone suffice?), I'd appreciate that help too.

Thanks a lot.

Dan

[[alternative HTML version deleted]]

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


[R] 2 missing observation of LSD analysis in R

2014-10-20 Thread Jomy Jose
How to deal with the analysis of 2 missing observations in case of Latin
square design

[[alternative HTML version deleted]]

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


Re: [R] 2 missing observation of LSD analysis in R

2014-10-20 Thread Frederic Ntirenganya
I guess you can use na.string=1st missing value 
then data[data==second missing value]-NA.


On Mon, Oct 20, 2014 at 9:21 AM, Jomy Jose infoj...@gmail.com wrote:

 How to deal with the analysis of 2 missing observations in case of Latin
 square design

 [[alternative HTML version deleted]]

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




-- 
Frederic Ntirenganya
Maseno University,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

[[alternative HTML version deleted]]

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


[R] format negative numbers

2014-10-20 Thread PIKAL Petr
Dear all.

Before I start fishing in (for me) murky regular expression waters I try to ask 
community about changing format of negative numbers.

For some reason I get a file with negative numbers formatted with negative sign 
at end of number.

something like

0.123-

It is imported as factors and I need to convert it to numbers again. Before 
converting I need to change it to correct format

-0.123

Does anybody know some simple way?

Cheers
Petr



Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] need help for predictive analytics part

2014-10-20 Thread Swapnil Khobragade

Hello sir,

 Actually, I 'm novice to R programming and currently working on prediction 
part for CPU usage log file (attached with mail).
My task is to predict next hour CPU usage by taking Time as response and  
%user%nice   %system   %iowait%steal %idle, either all or one as 
predictor(s).
Please help me out.

I have attached CPU usage log file with mail.
Please find attachment.


Thank You in advance.





Regards,
Swapnil Khobragade
Larsen  Toubro Infotech Ltd.
Bldg. No.56, 1st Floor,
Airoli, Navi Mumbai - 400708.
e-mail ID: swapnil.khobrag...@lntinfotech.com
Tel: @@@(Direct) | +91 9503043368 (M)



The contents of this e-mail and any attachment(s) may contain confidential or 
privileged information for the intended recipient(s). Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail and  
using or disseminating the information,  and must notify the sender and delete 
it from their system. LT Infotech will not accept responsibility or liability 
for the accuracy or completeness of, or the presence of any virus or disabling 
code in this e-mail
Linux 3.2.0-23-generic (cldx-1311-1183) 02/25/14_x86_64_
(2 CPU)

20:47:14CPU %user %nice   %system   %iowait%steal %idle
20:47:15all  5.05  0.00  2.02  0.51  0.00 92.42
20:47:16all  4.02  0.00  2.01  0.00  0.00 93.97
20:47:17all  5.61  0.00  2.55  0.00  0.00 91.84
20:47:18all  3.55  0.00  1.52  0.00  0.00 94.92
20:47:19all  5.58  0.00  2.03  0.00  0.00 92.39
20:47:20all  2.05  0.00  3.08  0.00  0.00 94.87
20:47:21all  3.55  0.00  1.52  0.00  0.00 94.92
20:47:22all  5.64  0.00  2.56  0.00  0.00 91.79
20:47:23all  3.02  0.00  2.51  0.00  0.00 94.47
20:47:24all  3.08  0.00  2.05  0.00  0.00 94.87
20:47:25all  4.06  0.00  2.54  0.00  0.00 93.40
20:47:26all  4.06  0.00  1.52  0.00  0.00 94.42
21:47:12all 13.64  0.00  3.54  0.00  0.00 82.83
21:47:13all  6.19  0.00  2.06  0.00  0.00 91.75
21:47:14all  6.19  0.00  2.58  0.00  0.00 91.24
Average:all  5.71  0.00  2.31  0.41  0.00 91.57
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Dry Spell Problem.

2014-10-20 Thread Frederic Ntirenganya
Dear All,

I want to solve the following problem on a climatic dataset. It contains
Year, Day and Rain as Columns names.

Ex:  head(Samaru56)
  Year Day Rain
1 1928   10
2 1928   20
3 1928   30
4 1928   40
5 1928   50
6 1928   60

The first day from April 01 that gets more than 20 mm on a single day, or
totalled
over 2 consecutive days with the additional condition that there is no 10
day (or longer) dry spell in the next 30 days.

Any help is appreciated. Thanks!!!

Regards,
Frederic.
-- 
Frederic Ntirenganya
Maseno University,
Kenya.
Mobile:(+254)718492836
Email: fr...@aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

[[alternative HTML version deleted]]

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


[R] FW: need help for predictive analytics part

2014-10-20 Thread Swapnil Khobragade


Hello sir,

 Actually, I 'm novice to R programming and currently working on prediction 
part for CPU usage log file (attached with mail).
My task is to predict next hour CPU usage by taking Time as response and  
%user%nice   %system   %iowait%steal %idle, either all or one as 
predictor(s).
Please help me out.

I have attached CPU usage log file with mail.
Please find attachment.


Thank You in advance.

  This code is not working 
#

cpu - read.table(file = D:/Swapnil/Data/cpu.txt, header = FALSE, col.names = 
c(Time,CPU,user,Nice,System,Iowait,Steal,Idle) )
#cpu

user - rep(cpu$user)
Time - c(cpu$Time)
Time

Time - c(cpu$Time)
user - rep(cpu$user)
user

plot(cpu$user, xaxt=n, ylab=USER, xlab=)
axis(1, labels=paste(cpu$user), at=1:11)

cor(user, Time)

fit - lm(Time ~ user)
fit

attributes(fit)

fit$coefficients

residuals(fit)
summary(fit)

plot(fit)


#prdiction part

Time2hr - data.frame(user=2.00)
user2hr -predict(fit, newdata=Time2hr)

user2hr -predict(fit, newdata=Time2hr)
style - c(rep(1,11))
plot(c(Time, user2hr), xaxt=n, ylab=TIME, xlab=, pch=style, col=style)
axis(1, at=1:11,labels=c(paste(cpu$user,sep=Q), 2011Q1, 2011Q2, 2011Q3, 

#


Regards,
Swapnil Khobragade
Larsen  Toubro Infotech Ltd.
Bldg. No.56, 1st Floor,
Airoli, Navi Mumbai - 400708.
e-mail ID: swapnil.khobrag...@lntinfotech.com
Tel: @@@(Direct) | +91 9503043368 (M)



The contents of this e-mail and any attachment(s) may contain confidential or 
privileged information for the intended recipient(s). Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail and  
using or disseminating the information,  and must notify the sender and delete 
it from their system. LT Infotech will not accept responsibility or liability 
for the accuracy or completeness of, or the presence of any virus or disabling 
code in this e-mail
Linux 3.2.0-23-generic (cldx-1311-1183) 02/25/14_x86_64_
(2 CPU)

20:47:14CPU %user %nice   %system   %iowait%steal %idle
20:47:15all  5.05  0.00  2.02  0.51  0.00 92.42
20:47:16all  4.02  0.00  2.01  0.00  0.00 93.97
20:47:17all  5.61  0.00  2.55  0.00  0.00 91.84
20:47:18all  3.55  0.00  1.52  0.00  0.00 94.92
20:47:19all  5.58  0.00  2.03  0.00  0.00 92.39
20:47:20all  2.05  0.00  3.08  0.00  0.00 94.87
20:47:21all  3.55  0.00  1.52  0.00  0.00 94.92
20:47:22all  5.64  0.00  2.56  0.00  0.00 91.79
20:47:23all  3.02  0.00  2.51  0.00  0.00 94.47
20:47:24all  3.08  0.00  2.05  0.00  0.00 94.87
20:47:25all  4.06  0.00  2.54  0.00  0.00 93.40
20:47:26all  4.06  0.00  1.52  0.00  0.00 94.42
21:47:12all 13.64  0.00  3.54  0.00  0.00 82.83
21:47:13all  6.19  0.00  2.06  0.00  0.00 91.75
21:47:14all  6.19  0.00  2.58  0.00  0.00 91.24
Average:all  5.71  0.00  2.31  0.41  0.00 91.57
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] need help for predictive analytics part

2014-10-20 Thread Swapnil Khobragade

Hello sir,

 Actually, I 'm novice to R programming and currently working on prediction 
part for CPU usage log file (attached with mail).
My task is to predict next hour CPU usage by taking Time as response and  
%user%nice   %system   %iowait%steal %idle, either all or one as 
predictor(s).
Please help me out.

I have attached CPU usage log file with mail.
Please find attachment.


Thank You in advance.

  This code is not working 
#

cpu - read.table(file = D:/Swapnil/Data/cpu.txt, header = FALSE, col.names = 
c(Time,CPU,user,Nice,System,Iowait,Steal,Idle) ) #cpu

user - rep(cpu$user)
Time - c(cpu$Time)
Time

Time - c(cpu$Time)
user - rep(cpu$user)
user

plot(cpu$user, xaxt=n, ylab=USER, xlab=) axis(1, labels=paste(cpu$user), 
at=1:11)

cor(user, Time)

fit - lm(Time ~ user)
fit

attributes(fit)

fit$coefficients

residuals(fit)
summary(fit)

plot(fit)


#prdiction part

Time2hr - data.frame(user=2.00)
user2hr -predict(fit, newdata=Time2hr)

user2hr -predict(fit, newdata=Time2hr)
style - c(rep(1,11))
plot(c(Time, user2hr), xaxt=n, ylab=TIME, xlab=, pch=style, col=style) 
axis(1, at=1:11,labels=c(paste(cpu$user,sep=Q), 2011Q1, 2011Q2, 2011Q3,

#


Regards,
Swapnil Khobragade
Larsen  Toubro Infotech Ltd.
Bldg. No.56, 1st Floor,
Airoli, Navi Mumbai - 400708.
e-mail ID: swapnil.khobrag...@lntinfotech.com
Tel: @@@(Direct) | +91 9503043368 (M)

The contents of this e-mail and any attachment(s) may contain confidential or 
privileged information for the intended recipient(s). Unintended recipients are 
prohibited from taking action on the basis of information in this e-mail and  
using or disseminating the information,  and must notify the sender and delete 
it from their system. LT Infotech will not accept responsibility or liability 
for the accuracy or completeness of, or the presence of any virus or disabling 
code in this e-mail
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Dry Spell Problem.

2014-10-20 Thread Pascal Oettli
Hi,

Did you have a look at the dw.spell function from the RMRAINGEN
package? It might be a starting point for you.

Regards,
Pascal

On Mon, Oct 20, 2014 at 4:47 PM, Frederic Ntirenganya ntfr...@gmail.com wrote:
 Dear All,

 I want to solve the following problem on a climatic dataset. It contains
 Year, Day and Rain as Columns names.

 Ex:  head(Samaru56)
   Year Day Rain
 1 1928   10
 2 1928   20
 3 1928   30
 4 1928   40
 5 1928   50
 6 1928   60

 The first day from April 01 that gets more than 20 mm on a single day, or
 totalled
 over 2 consecutive days with the additional condition that there is no 10
 day (or longer) dry spell in the next 30 days.

 Any help is appreciated. Thanks!!!

 Regards,
 Frederic.
 --
 Frederic Ntirenganya
 Maseno University,
 Kenya.
 Mobile:(+254)718492836
 Email: fr...@aims.ac.za
 https://sites.google.com/a/aims.ac.za/fredo/

 [[alternative HTML version deleted]]

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



-- 
Pascal Oettli
Project Scientist
JAMSTEC
Yokohama, Japan

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


Re: [R] distance from fitted line

2014-10-20 Thread eliza botto
Thankyou very much Joachim. Actually I already know the residual() command. I 
only wanted to know that is there a way to account for the fitted lines? its 
more of a criosity rather than a problem. 
:)
Thankyou very much once again.

Eliza

To: eliza_bo...@hotmail.com
Subject: Re: [R] distance from fitted line
From: joachim.audena...@pcsierteelt.be
Date: Mon, 20 Oct 2014 11:11:21 +0200

Hello Eliza,



I'm quite new to R, but I use the residuals
function to calculate the distance from my data points to the fitted line
of my nls (non linear least squares model).



residuals(name of your fitted model)



I would check for a model that fits
your datapoints and then calculate the residuals of the model to your data.
Why do you fit the generalized Extreme Value distribution
to your points in stead
of a regression model?



Met vriendelijke groeten/Kind Regards,



Joachim Audenaert 

onderzoeker gewasbescherming



PCS |
proefcentrum voor sierteelt




Schaessestraat 18, 9070
Destelbergen, Belgi�

T: +32 (0)9 353 94 71 | F: +32 (0)9 353 94 95

E: joachim.audena...@pcsierteelt.be
| W: www.pcsierteelt.be



 KEN JIJ DE
8 BASISPRINCIPES VAN IPM? MEER INFO OP WWW.PCSIERTEELT.BE







From:  
 eliza botto eliza_bo...@hotmail.com

To:  
 r-help@r-project.org
r-help@r-project.org

Date:  
 19/10/2014 22:08

Subject:
   [R] distance
from fitted line

Sent by:
   r-help-boun...@r-project.org









Dear useRs,

I have the following dataset.

 dput(EB)

c(77.724, 76.708, 84.836, 85.09, 118.11, 65.024, 121.412, 63.5, 102.87,
81.3, 108.7, 110.7, 71.9, 42.2, 101, 151.4, 94, 112, 48, 73.4, 76.6, 62.2,
59.4, 114.3, 214.3, 110.5, 46, 84.7, 128.1, 45.2, 109.5, 102.3, 77.5, 61,
97.3, 78, 142, 88.2, 54, 91.4, 54.1, 96, 143.3, 153.7, 101.5, 95.8, 101,
131, 140, 189.4)

I fitted generalized Extreme Value distribution on it by using following
codes

library(nsRFA)

q=EB

lmom=Lmoments(q)

pr = par.GEV (lambda1=lmom[l1], lambda2=lmom[l2],
tau3=lmom[lca])

RP = c(1.01,2, 10, 20, 50, 100, 200, 500)

quant = invF.GEV (1-1/RP, pr$xi, pr$alfa, pr$k)

qs = sort(q)

pp = 1:length(qs)/(length(qs)+1)

RPpp = 1/(1-pp)

plot(RP, quant, type=l, log=x,col=black,ylim=c(0,500),xlim=c(0.1,500))

points(RPpp, qs)

What I want to do now is to calculate the distance of all the points from
the fitted line and ultimately calculating RMSE of the data.

Is there a way of doing it?



Thankyou very much in advance



Eliza  
   
 
 
   
 


[[alternative HTML version deleted]]



__

R-help@r-project.org mailing list

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

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

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







PCS-proeven
leiden tot nieuwe erkenningen in de sierteelt
| Het
PCS op LinkedIn

Disclaimer\ | Please consider the environment before pri...{{dropped:6}}

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

2014-10-20 Thread M Fatemi
Hi;
In the simulation studies we need to save some measure in the output as a
variable to do some calculation on them,  how we can do that?

For example: the p-value , t-value, in t-test  ( t.test( ) )

or

The estimated parameters in some models,(Ex: IRT model: graded response
model) in ltm package:
(see grm model in attachment file)


grm(data, constrained = FALSE, *IRT.param* = TRUE, ...)

*IRT.param:*

bij: difficulty parameter for item i and category j)
ai : discriminant parameter for item i)
thata(k) : ability parameter for person k

Note that this package does not give theta(k) even in output!
How can i load theta parameters?

Thanks in advanse
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] dbHasCompleted() always returns TRUE for POSTGRES Database with RJDBC?

2014-10-20 Thread julian . bothe
Hello Simon, Hello everyone,

I have a problem with retrieving database-queries chunkwise. In my query
(Postgresql-Database,  Postgres-Version 9.1) dbHasCompleted seems to
always return TRUE. 

dbGetQuery works for smaller tables, but not for the whole query, since
then a Heap-Overflow-Error will occur (and a Error:
java.lang.OutOfMemoryError: GC overhead limit exceeded when trying to
set a larger size).

Does anybody else have or had this problem?

 

All the best

Julian

 

 adapted Example from help (?dbHasCompleted ), Works ###

require(RSQLite)
 
con - dbConnect(RSQLite::SQLite(), :memory:)
dbWriteTable(con, mtcars, mtcars)
 
# Fetch all results
res - dbSendQuery(con, SELECT * FROM mtcars WHERE cyl = 4)
dbFetch(res)
dbClearResult(res)
 
# Fetch in chunks
res - dbSendQuery(con, SELECT * FROM mtcars)
dbHasCompleted(res) ## RETURNS FALSE !!!
 
while (!dbHasCompleted(res)) {
  chunk - fetch(res, 10)
  print(nrow(chunk))
}
dbClearResult(res)
dbDisconnect(con)

 

 

## My Code, lamentably not reproducible because of needed
Postgres-Server, not working #

 

# Connect to Postgres-Database 

res2 - dbSendQuery(Postgres_con, 

   select  id from mytable limit 1000;   

)

 

dbHasCompleted(res2) ##RETURNS TRUE!

 

while (!dbHasCompleted(res2)) {

  chunk - fetch(res2, 10 )

  rbind(dk, chunk)

}

 

try({

  dbClearResult(res2)

  rm(chunk,res2)

})


[[alternative HTML version deleted]]

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


Re: [R] format negative numbers

2014-10-20 Thread Rainer Schuermann
Maybe not the most elegant way but at least works:

library( stringr )
x - as.factor( 123.4- )
x - -as.numeric( str_replace( as.character( x ), -,  ) )
x
[1] -123.4



On Monday 20 October 2014 09:03:36 PIKAL Petr wrote:
 Dear all.
 
 Before I start fishing in (for me) murky regular expression waters I try to 
 ask community about changing format of negative numbers.
 
 For some reason I get a file with negative numbers formatted with negative 
 sign at end of number.
 
 something like
 
 0.123-
 
 It is imported as factors and I need to convert it to numbers again. Before 
 converting I need to change it to correct format
 
 -0.123
 
 Does anybody know some simple way?
 
 Cheers
 Petr
.
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] format negative numbers

2014-10-20 Thread Marc Girondot

Is it what you want?

 st - 0.123-
 gsub((.+)(-), \\2\\1, st)
[1] -0.123
 st - 0.123
 gsub((.+)(-), \\2\\1, st)
[1] 0.123

Sincerely
Marc

Le 20/10/2014 09:03, PIKAL Petr a écrit :

Dear all.

Before I start fishing in (for me) murky regular expression waters I try to ask 
community about changing format of negative numbers.

For some reason I get a file with negative numbers formatted with negative sign 
at end of number.

something like

0.123-

It is imported as factors and I need to convert it to numbers again. Before converting I 
need to change it to correct format

-0.123

Does anybody know some simple way?

Cheers
Petr



Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



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


[R] create vector objects by recurrence equation function

2014-10-20 Thread rl

Subscribers,

A spreadsheet contains (what appears to a low aptitude mathematician!) a 
recurrence equation:


cellb1=2cellc1=0.1  celld1=5
cella2=1/(k1*cellb1)cellb2=cellb1+cellc1+celld1 cellc2=cella2*cellb2
celld2=cellb2*k2

where k are constants.

Could someone please direct to a relevant function name in the manual, 
to create a vector (e.g. length 10) for subsequent values that would be 
in equivalent spreadsheet cells cellc3, celld3, cellc4, celld4, etc.?


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


Re: [R] format negative numbers

2014-10-20 Thread PIKAL Petr
Hi

Thanks to all who responded.

My input string is rather clumsy. Actually it can have leading or trailing 
empty space too, it can be mixture of positive and negative numbers.

In the meantime I made small function which just strips of - sign and make 
numbers from factors, find numbers which have - sign and change numbers which 
shall be negative to negative. Not as elegant as your solution but works even 
when there are leading or trailing spaces.

zapor - function(x) {
num-as.numeric(gsub((-), , x))
zap- grep(-, x)
num[zap]- num[zap] * (-1)
num}

 x - as.factor( c(   123.4-,123   ))
 zapor(x)
[1] -123.4  123.0


I just thought that there is some reason for presenting negative numbers with 
minus sign behind the number in finance community and therefore somebody 
already invented clever way how to deal with such numbers.

Cheers
Petr


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Marc Girondot
 Sent: Monday, October 20, 2014 12:53 PM
 To: r-help@r-project.org
 Subject: Re: [R] format negative numbers

 Is it what you want?

   st - 0.123-
   gsub((.+)(-), \\2\\1, st)
 [1] -0.123
   st - 0.123
   gsub((.+)(-), \\2\\1, st)
 [1] 0.123

 Sincerely
 Marc

 Le 20/10/2014 09:03, PIKAL Petr a écrit :
  Dear all.
 
  Before I start fishing in (for me) murky regular expression waters I
 try to ask community about changing format of negative numbers.
 
  For some reason I get a file with negative numbers formatted with
 negative sign at end of number.
 
  something like
 
  0.123-
 
  It is imported as factors and I need to convert it to numbers again.
 Before converting I need to change it to correct format
 
  -0.123
 
  Does anybody know some simple way?
 
  Cheers
  Petr
 
 
  
  Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a
 jsou určeny pouze jeho adresátům.
  Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
 neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho
 kopie vymažte ze svého systému.
  Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento
 email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
  Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou
 modifikacemi či zpožděním přenosu e-mailu.
 
  V případě, že je tento e-mail součástí obchodního jednání:
  - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
 smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
  - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně
 přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky
 ze strany příjemce s dodatkem či odchylkou.
  - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
 výslovným dosažením shody na všech jejích náležitostech.
  - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
 společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně
 zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly
 adresátovi tohoto emailu případně osobě, kterou adresát zastupuje,
 předloženy nebo jejich existence je adresátovi či osobě jím zastoupené
 známá.
 
  This e-mail and any documents attached to it may be confidential and
 are intended only for its intended recipients.
  If you received this e-mail by mistake, please immediately inform its
 sender. Delete the contents of this e-mail with all attachments and its
 copies from your system.
  If you are not the intended recipient of this e-mail, you are not
 authorized to use, disseminate, copy or disclose this e-mail in any
 manner.
  The sender of this e-mail shall not be liable for any possible damage
 caused by modifications of the e-mail or by delay with transfer of the
 email.
 
  In case that this e-mail forms part of business dealings:
  - the sender reserves the right to end negotiations about entering
 into a contract in any time, for any reason, and without stating any
 reasoning.
  - if the e-mail contains an offer, the recipient is entitled to
 immediately accept such offer; The sender of this e-mail (offer)
 excludes any acceptance of the offer on the part of the recipient
 containing any amendment or variation.
  - the sender insists on that the respective contract is concluded
 only upon an express mutual agreement on all its aspects.
  - the sender of this e-mail informs that he/she is not authorized to
 enter into any contracts on behalf of the company except for cases in
 which he/she is expressly authorized to do so in writing, and such
 authorization or power of attorney is submitted to the recipient or the
 person represented by the recipient, or the existence of such
 authorization is known to the recipient of the person represented by
 the recipient.
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
 

Re: [R] how to judge a virable is a integer?

2014-10-20 Thread S Ellison
 It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but 
 deeply,
 when i want to know 1 is an integer,  there seems no easy way to get the
 answer.
 So, is there anyone happen to know it?

First, you are not being as clear as you may think when you say  when i want 
to know 1 is an integer. It isn't. 1L is an integer. 1 is floating point. Do 
you want to know whether something is _stored as_ integer (eg 2L), whether it 
is a floating point number with exactly no nonzero digits after the point (eg 
2.0), or whether it is something which would normally be expected to be integer 
if represented to infinite precision but is not exactly represented because of 
finite machine precision (eg sqrt(2)^2)?

Once you've sorted out which of those you want - I think the last of the three 
- please read the posts you’re replying to. all.equal() was the suggested 
answer and is likely to be the nearest to a reliable answer you will get. 
Almost anything else will at least sometimes fail; for example

sqrt(4.0) == 2L
# [1] TRUE

#But 
sqrt(2)^2 == 2L
#[1] FALSE

#whereas 
all.equal(sqrt(2)^2, 2L)
#[1] TRUE

Thus, all.equal can be used to test for something that would normally be 
considered an integer within machine precision, for example using
nearly.integer - function(x) all.equal(x, round(x))

You may make the comparison closer to a 'within machine precision' comparison  
by amending the tol argument to all.equal, which is documented on the help page 
you were referred to.

S Ellison




***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to judge a virable is a integer?

2014-10-20 Thread S Ellison
 3. all.equal(a, as.integer(a))

Closer, but be aware that all.equal will not always return TRUE or FALSE and - 
more importantly - as.integer truncates towards zero and does NOT generally 
round to the nearest integer.

a - 4 - sqrt(2)^2 #Analytically 2
all.equal(a, as.integer(a))
# [1] Mean relative difference: 0.5
#because
as.integer(a)
# [1] 1

To return FALSE from all.equal, wrap it in something like

if(all.equal(a, round(a))==TRUE) TRUE else FALSE


S


***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] matching genes to a list of gene groups an built binary data frame

2014-10-20 Thread Karim Mezhoud
Dear All,

I have a gene list
Genes - c(ACACA, BAX , BCL2, BID, BAX, MAPK9)

and a list of group of genes

ListGroup - list(group1=c(ACACA ,AHSA1 ,AIMP2, AKR1B1,
AKT1,  AKT1S1), group2=c(ANXA1  ,   AR   , ARID1A ,
ATM ,  BAK1 , BAX  ), group3=c(BCL2  ,BCL2L1  ,
BCL2L11 ,  BECN1 ,BID  , BIRC2))

ListGroup
$group1
[1] ACACA  AHSA1  AIMP2  AKR1B1 AKT1   AKT1S1
$group2
[1] ANXA1  AR ARID1A ATMBAK1   BAX
$group3
[1] BCL2BCL2L1  BCL2L11 BECN1   BID BIRC2

I would like to built a data frame as:

   ACACA   BAX  BCL2  BID  BAX   MAPK9
group11 00  0 0   0
group20 1 0  0 1   0
group30  01   1 0   0

Many thanks,
Karim

[[alternative HTML version deleted]]

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


[R] strange loadings matrix after varimax rotation: PCA with prcomp in R

2014-10-20 Thread David Villegas Ríos
Hello.
I ran a PCA analysis on a dataset with 5 variables and retained two
components. I rotated them and now I want to predict the scores in a new
data set for which the original variables are available.

I normally use the predict.prcomp() function to predict using a prcomp
object. For example..

PC1=predict(data.pca, new.data)[,1]

...will predict the first component in the new dataset.

But how to do it with the rotated components/loadings, since after
varimax() we don't have a prcomp object anymore?

Thanks in advance!

David

[[alternative HTML version deleted]]

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


[R] how to predict scores after varimax rotation (using prcomp() and varimax())?

2014-10-20 Thread David Villegas Ríos
Hello.
I ran a PCA analysis on a dataset with 5 variables and retained two
components. I rotated them and now I want to predict the scores in a new
data set for which the original variables are available.

I normally use the predict.prcomp() function to predict using a prcomp
object. For example..

PC1=predict(data.pca, new.data)[,1]

...will predict the first component in the new dataset.

But how to do it with the rotated components/loadings, since after
varimax() we don't have a prcomp object anymore?

Thanks in advance!

David

[[alternative HTML version deleted]]

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


[R] making a plot

2014-10-20 Thread Enrico Colosimo
Dear all,

I am struggling to make a plot for my survival analysis
class.

This is my script


 labels-c('1','2','3','4','5','6')
 ano-c(2001,2002,2003,2004,2006,2008)
 ranges-c(6,3,4,5,4,2)
 dotchart(ano, labels=labels, xlab='ano',
ylab='Pacientes',pch=20,xlim=c(min(ano),  max(ano+ranges)))
 segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4)

I need to put an asterix (failure) by the end of the three first lines and
a small circle (censoring)
by the end of the last three.

Someone can help me?

Thanks,
Enrico.

[[alternative HTML version deleted]]

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


Re: [R] making a plot

2014-10-20 Thread Andrés Aragón
Enrico,

This may help you:

text(locator(1), *, cex=1.5,adj=0.5

and

text(locator(1), º, cex=1.5,adj=0.5


Draw your plot, then write the code, locate the cursor on your plot, put
the symbols where you want itl and click.

Regards,


Andrés

PS ?locator





2014-10-20 9:46 GMT-05:00 Enrico Colosimo enrico...@gmail.com:

 Dear all,

 I am struggling to make a plot for my survival analysis
 class.

 This is my script


  labels-c('1','2','3','4','5','6')
  ano-c(2001,2002,2003,2004,2006,2008)
  ranges-c(6,3,4,5,4,2)
  dotchart(ano, labels=labels, xlab='ano',
 ylab='Pacientes',pch=20,xlim=c(min(ano),  max(ano+ranges)))
  segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4)

 I need to put an asterix (failure) by the end of the three first lines and
 a small circle (censoring)
 by the end of the last three.

 Someone can help me?

 Thanks,
 Enrico.

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] How to clear R memory in a for loop

2014-10-20 Thread Dimitri Liakhovitski
Dear Rers,

I am trying to run a for-loop in R.
During each iteration I read in an mp3 file and do some basic processing.
If I do what I need to do for each file one by one - it works fine.
But once I start running a loop, it soon runs out of memory and says: can't
allocate a vector of size...
In each iteration of my loop I always overwrite the previously created
object and do gc().

Any hints on how to fight this?

Thanks a lot!

[[alternative HTML version deleted]]

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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread Jeff Newmiller
You don't say what processing you are doing.. the answer to your question is 
very likely there. To communicate effectively on this mailing list, 
self-contained examples are needed. And in order to not corrupt the example you 
will need to post in plain text.
---
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 October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:
Dear Rers,

I am trying to run a for-loop in R.
During each iteration I read in an mp3 file and do some basic
processing.
If I do what I need to do for each file one by one - it works fine.
But once I start running a loop, it soon runs out of memory and says:
can't
allocate a vector of size...
In each iteration of my loop I always overwrite the previously created
object and do gc().

Any hints on how to fight this?

Thanks a lot!

   [[alternative HTML version deleted]]

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

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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread Dimitri Liakhovitski
Jeff,

here is what I do with each file using library(tuneR):

b-readMP3(cairnomount.mp3)
myrange-range(b@left)
write.table(myrange,x myrange.txt,sep=\t)

Would you like me to attach a bunch of large mp3 files?
I don't feel I have the right to clog people's inboxes with large files.

Thanks!



On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us
wrote:

 You don't say what processing you are doing.. the answer to your question
 is very likely there. To communicate effectively on this mailing list,
 self-contained examples are needed. And in order to not corrupt the example
 you will need to post in plain text.
 ---
 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 October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
 Dear Rers,
 
 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic
 processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and says:
 can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously created
 object and do gc().
 
 Any hints on how to fight this?
 
 Thanks a lot!
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Dimitri Liakhovitski

[[alternative HTML version deleted]]

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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread Jeff Newmiller
It is your responsibility (not mine) to simplify your example to the point 
where it is small, self-contained, and reproducible (see the footer of this 
message). In fact, doing so often highlights the issue to you before you share 
it. If any old downloadable mp3 file can be used to reproduce the problem then 
you would not need to share yours. (Note that this list strips off most 
attachments, so links are better anyway.)

I suspect that one file read repeatedly might create the problem... if it 
doesn't, then that would be helpful to know. In any event, your example is 
missing the key element of repetition, so it is not hardly reproducible. The 
extra things you are doing to make it loop are likely to be important here.
---
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 October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:
Jeff,

here is what I do with each file using library(tuneR):

b-readMP3(cairnomount.mp3)
myrange-range(b@left)
write.table(myrange,x myrange.txt,sep=\t)

Would you like me to attach a bunch of large mp3 files?
I don't feel I have the right to clog people's inboxes with large
files.

Thanks!



On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller
jdnew...@dcn.davis.ca.us
wrote:

 You don't say what processing you are doing.. the answer to your
question
 is very likely there. To communicate effectively on this mailing
list,
 self-contained examples are needed. And in order to not corrupt the
example
 you will need to post in plain text.

---
 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 October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
 Dear Rers,
 
 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic
 processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and
says:
 can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously
created
 object and do gc().
 
 Any hints on how to fight this?
 
 Thanks a lot!
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread John McKown
On Mon, Oct 20, 2014 at 10:30 AM, Dimitri Liakhovitski 
dimitri.liakhovit...@gmail.com wrote:

 Dear Rers,

 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and says: can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously created
 object and do gc().

 Any hints on how to fight this?

 Thanks a lot!



​Please don't use HTML for messages.

What occurs to me, from reading the other replies, is that perhaps within
the loop you are causing other objects to be allocated. And that can be
done just by doing a simple assignment, so it may not be obvious. What this
can do is cause what we called a sand bar in the old days. That's where
you allocate a big chunk of memory for an object. Say this take up 1/2 of
your available space. You now create a small object. This object is
_probably_ right next to the large object. You now release the large
object. Your apparent free space is now almost what it was at the
beginning. But when you try to allocate another large object which is, say,
2/3 of the maximum space, you can't because that small object is sitting
right in the middle of our memory space. So you _can_ allocate 2 large
objects which are 1/3 your free space size, but not 1 object which is 2/3
of the free space size. Which can lead to your type of situation.

This is just a SWAG based on some experience in other systems. Most
garbage collection do _not_ do memory consolidation. I don't know about
R.​


-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! 
John McKown

[[alternative HTML version deleted]]

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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread William Dunlap
tuneR::readMP3 may not be allocating (or freeing) memory correctly.  On both
Linux and Windows I get the following (where 'jingle.mp3' is a sample mp3 that
comes with Processing 2.1 which has a quarter million samples in it).  If I do
this as a sequence of top-level expression instead of as a for loop R does not
crash.  Perhaps you should talk with tuneR's maintainer, who could run valgrind
over it.

 library(tuneR)
tuneR = 1.0 has changed its Wave class definition.
Use updateWave(object) to convert Wave objects saved with previous
versions of tuneR.
 b - readMP3(jingle.mp3)
 for(i in 1:100){cat(i,);b - readMP3(jingle.mp3)}
1 2
 *** caught segfault ***
address 0x3a81000, cause 'memory not mapped'

Traceback:
 1: .Call(do_read_mp3, data, package = tuneR)
 2: readMP3(jingle.mp3)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, Oct 20, 2014 at 9:25 AM, Jeff Newmiller
jdnew...@dcn.davis.ca.us wrote:
 It is your responsibility (not mine) to simplify your example to the point 
 where it is small, self-contained, and reproducible (see the footer of this 
 message). In fact, doing so often highlights the issue to you before you 
 share it. If any old downloadable mp3 file can be used to reproduce the 
 problem then you would not need to share yours. (Note that this list strips 
 off most attachments, so links are better anyway.)

 I suspect that one file read repeatedly might create the problem... if it 
 doesn't, then that would be helpful to know. In any event, your example is 
 missing the key element of repetition, so it is not hardly reproducible. The 
 extra things you are doing to make it loop are likely to be important here.
 ---
 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 October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
Jeff,

here is what I do with each file using library(tuneR):

b-readMP3(cairnomount.mp3)
myrange-range(b@left)
write.table(myrange,x myrange.txt,sep=\t)

Would you like me to attach a bunch of large mp3 files?
I don't feel I have the right to clog people's inboxes with large
files.

Thanks!



On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller
jdnew...@dcn.davis.ca.us
wrote:

 You don't say what processing you are doing.. the answer to your
question
 is very likely there. To communicate effectively on this mailing
list,
 self-contained examples are needed. And in order to not corrupt the
example
 you will need to post in plain text.

---
 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 October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
 Dear Rers,
 
 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic
 processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and
says:
 can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously
created
 object and do gc().
 
 Any hints on how to fight this?
 
 Thanks a lot!
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



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

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

Re: [R] pasteFromExcel

2014-10-20 Thread David Winsemius

On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote:

 To Users of Excel:
 
 Following advice from Brian and Markus, I created an RMarkdown vignette
 that shows an example of how the pasteFromExcel function in the excelRio
 package on github could be used by an actuary to transfer a triangle from
 Excel to R. See today's post at http://trinostics.blogspot.com/
 
 Unfortunately, if you are located outside the US, the demonstrated
 functionality will not work for you because the currency regex implemented
 assumes the dollar sign ($) and comma/decimal punctuation of the form
 999,999.00.
 
 If anyone is interested in contributing currency regex expressions that
 work in your locale, I would be happy to try to incorporate them in the
 package. If anyone knows how best to determine the user's locale (might
 timezone suffice?), I'd appreciate that help too.
 

?Sys.getlocale   # perhaps LC_MONETARY

?options   # look for OutDec


   [[alternative HTML version deleted]]



David Winsemius
Alameda, CA, USA

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


Re: [R] format negative numbers

2014-10-20 Thread MacQueen, Don
You could do it with minimal use of regular expressions, along the lines
of this example:

x - c('123','2.31','2.313-', '45-')
is.neg - grepl('-',x)
xn - x
xn[is.neg] - paste0( '-', substring(x[is.neg],1, nchar(x[is.neg])-1))
xn - as.numeric(xn)
   
I made a copy, 'xn', so that original and final can easily be compared,
but it's not necessary to do so.


-Don

-- 
Don MacQueen

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





On 10/20/14, 12:03 AM, PIKAL Petr petr.pi...@precheza.cz wrote:

Dear all.

Before I start fishing in (for me) murky regular expression waters I try
to ask community about changing format of negative numbers.

For some reason I get a file with negative numbers formatted with
negative sign at end of number.

something like

0.123-

It is imported as factors and I need to convert it to numbers again.
Before converting I need to change it to correct format

-0.123

Does anybody know some simple way?

Cheers
Petr



Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou
určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho
kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento
email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi
či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně
přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze
strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně
zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly
adresátovi tohoto emailu případně osobě, kterou adresát zastupuje,
předloženy nebo jejich existence je adresátovi či osobě jím zastoupené
známá.

This e-mail and any documents attached to it may be confidential and are
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its
sender. Delete the contents of this e-mail with all attachments and its
copies from your system.
If you are not the intended recipient of this e-mail, you are not
authorized to use, disseminate, copy or disclose this e-mail in any
manner.
The sender of this e-mail shall not be liable for any possible damage
caused by modifications of the e-mail or by delay with transfer of the
email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to
immediately accept such offer; The sender of this e-mail (offer) excludes
any acceptance of the offer on the part of the recipient containing any
amendment or variation.
- the sender insists on that the respective contract is concluded only
upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to
enter into any contracts on behalf of the company except for cases in
which he/she is expressly authorized to do so in writing, and such
authorization or power of attorney is submitted to the recipient or the
person represented by the recipient, or the existence of such
authorization is known to the recipient of the person represented by the
recipient.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] pasteFromExcel

2014-10-20 Thread Dan Murphy
Nice.
So if someone were to offer a currency regular expression that works
in their locale, I should also ask them to give me the results of
Sys.getlocale(LC_MONETARY)
and
options(OutDec)
and confirm that MS Excel honors that OutDec.
Thank you, David.
-Dan

On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius
dwinsem...@comcast.net wrote:

 On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote:

 To Users of Excel:

 Following advice from Brian and Markus, I created an RMarkdown vignette
 that shows an example of how the pasteFromExcel function in the excelRio
 package on github could be used by an actuary to transfer a triangle from
 Excel to R. See today's post at http://trinostics.blogspot.com/

 Unfortunately, if you are located outside the US, the demonstrated
 functionality will not work for you because the currency regex implemented
 assumes the dollar sign ($) and comma/decimal punctuation of the form
 999,999.00.

 If anyone is interested in contributing currency regex expressions that
 work in your locale, I would be happy to try to incorporate them in the
 package. If anyone knows how best to determine the user's locale (might
 timezone suffice?), I'd appreciate that help too.


 ?Sys.getlocale   # perhaps LC_MONETARY

 ?options   # look for OutDec


   [[alternative HTML version deleted]]



 David Winsemius
 Alameda, CA, USA


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


Re: [R] understanding the no-label concept

2014-10-20 Thread Ista Zahn
On Thu, Oct 16, 2014 at 3:19 PM,  moon...@posteo.org wrote:
 aa - 1:5
 names(aa) - c(Eins, Zwei, Drei, Vier, Fünf)
 aa
 Eins Zwei Drei Vier Fünf
12345
 table(aa)
 1 2 3 4 5
 1 1 1 1 1

 You see? It didn't work.

perhaps you want

table(names(aa))

Or maybe just

aa - - c(Eins, Zwei, Drei, Vier, Fünf)
table(aa)


 aa - c(aa, 1, 2)
 aa
 Eins Zwei Drei Vier Fünf
1234512

This does get more complicated if you want to add things by number.
But why not just


aa - - c(Eins, Zwei, Drei, Vier, Fünf)
aa - c(aa, Eins, Zwei)
table(aa)

?


 This is no solution for my case.

 But...

 bb - matrix(1:12, 3, 4, dimnames=list(letters[1:3], LETTERS[1:4]))

Not really sure what this is meant to demonstrate.

More generally there is no one-to-one mapping between the stata
concept of variable and value labels to concepts in R. First, there is
no equivalent of Stata variable labels. There is ?comment but it
doesn't survive subsetting. The role that value labels play in Stata
are covered variously in R by 1) just using character strings to store
the information that you would typically put in a stata value label,
b) naming your variable, or c) using factors. Personally I usually
find option 1) more convenient.

Best,
Ista


 Nice. But look dam complex for a simple task. I see I have to change a
 lot of the concepts in my mind and my workflows.

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

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


Re: [R] matching genes to a list of gene groups an built binary data frame

2014-10-20 Thread David Winsemius

On Oct 20, 2014, at 6:28 AM, Karim Mezhoud wrote:

 Genes - c(ACACA, BAX , BCL2, BID, BAX, MAPK9)
 
 and a list of group of genes
 
 ListGroup - list(group1=c(ACACA ,AHSA1 ,AIMP2, AKR1B1,
 AKT1,  AKT1S1), group2=c(ANXA1  ,   AR   , ARID1A ,
 ATM ,  BAK1 , BAX  ), group3=c(BCL2  ,BCL2L1  ,
 BCL2L11 ,  BECN1 ,BID  , BIRC2))

Desired:

 I would like to built a data frame as:
 
   ACACA   BAX  BCL2  BID  BAX   MAPK9
 group11 00  0 0   0
 group20 1 0  0 1   0
 group30  01   1 0   0
 


 sapply(Genes, function(x) as.numeric(sapply(ListGroup, '%in%', x=x) ) )
 ACACA BAX BCL2 BID BAX MAPK9
[1,] 1   00   0   0 0
[2,] 0   10   0   1 0
[3,] 0   01   1   0 0

?'%in%'

The x=x asserts that the x value will be used as the first argument to %in% so 
ListGroup items will be used as the table arguments. It's a matrix, so 
as.data.frame would be needed to deliver a dfrm.

-- 
David Winsemius
Alameda, CA, USA

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


Re: [R] making a plot

2014-10-20 Thread David Winsemius

On Oct 20, 2014, at 8:24 AM, Andrés Aragón wrote:

 Enrico,
 
 This may help you:
 
 text(locator(1), *, cex=1.5,adj=0.5
 
 and
 
 text(locator(1), º, cex=1.5,adj=0.5

Why not just use the values of x2 and  y2 that were given to segments:

 text( (ano+ranges)[1:3], 1:3, *, cex=1.5,adj=0.5)
 text( (ano+ranges)[4:6], 4:6 , º, cex=1.5,adj=0.5)

 
 
 Draw your plot, then write the code, locate the cursor on your plot, put
 the symbols where you want itl and click.
 
 Regards,
 
 
 Andrés
 
 PS ?locator
 
 
 2014-10-20 9:46 GMT-05:00 Enrico Colosimo enrico...@gmail.com:
 
 Dear all,
 
 I am struggling to make a plot for my survival analysis
 class.
 
 This is my script
 
 
 labels-c('1','2','3','4','5','6')
 ano-c(2001,2002,2003,2004,2006,2008)
 ranges-c(6,3,4,5,4,2)
 dotchart(ano, labels=labels, xlab='ano',
 ylab='Pacientes',pch=20,xlim=c(min(ano),  max(ano+ranges)))
 segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4)
 
 I need to put an asterix (failure) by the end of the three first lines and
 a small circle (censoring)
 by the end of the last three.
 
 Someone can help me?
 
 Thanks,
 Enrico.
 
[[alternative HTML version deleted]]
 
-- 

David Winsemius
Alameda, CA, USA

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


Re: [R] pasteFromExcel

2014-10-20 Thread David Winsemius

On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote:

 Nice.
 So if someone were to offer a currency regular expression that works
 in their locale, I should also ask them to give me the results of
 Sys.getlocale(LC_MONETARY)
 and
 options(OutDec)
 and confirm that MS Excel honors that OutDec.

I'm not sure we can know what you mean by confirm that MS Excel honors that 
OutDec. The result of options(OutDec) was intended for you to determine what 
character not to remove from a monetary value in an R workspace. If the 
assumption is that all values will be in the same unit and that the user is not 
doing any currency conversions then:

  decsep - options(OutDec)
 rmchar - paste0( [$£€, c(., ,)[!c(., ,) %in% decsep], ] )
 gsub(rmchar, , c($1,000, 1,200, 800))
[1] 1000 1200 800 


 Thank you, David.
 -Dan
 
 On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius
 dwinsem...@comcast.net wrote:
 
 On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote:
 
 To Users of Excel:
 
 Following advice from Brian and Markus, I created an RMarkdown vignette
 that shows an example of how the pasteFromExcel function in the excelRio
 package on github could be used by an actuary to transfer a triangle from
 Excel to R. See today's post at http://trinostics.blogspot.com/
 
 Unfortunately, if you are located outside the US, the demonstrated
 functionality will not work for you because the currency regex implemented
 assumes the dollar sign ($) and comma/decimal punctuation of the form
 999,999.00.
 
 If anyone is interested in contributing currency regex expressions that
 work in your locale, I would be happy to try to incorporate them in the
 package. If anyone knows how best to determine the user's locale (might
 timezone suffice?), I'd appreciate that help too.
 
 
 ?Sys.getlocale   # perhaps LC_MONETARY
 
 ?options   # look for OutDec
 
 
  [[alternative HTML version deleted]]
 
 
 
 David Winsemius
 Alameda, CA, USA
 

David Winsemius
Alameda, CA, USA

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


[R] glmer with multiple random slopes

2014-10-20 Thread David Kikuchi

Hi all,

I'm modeling the probability that a subject attacks or rejects a prey 
item based on its proportion of yellow coloration and size. There are 
two populations of prey, one defended and the other undefended, so 
subjects should reject one type and accept others. Each subject has a 
unique rejection threshold that is a line on a contour plot with 
coloration and size on the x and y axes. I want to estimate the error 
around that line's slope, and believe that I need to estimate two random 
slopes per subject to do so, one in the color dimension and the other in 
the size dimension. The code that I think I should use to do this is: 
glmer(attack ~ prop.color + size + (prop.color + size|subject, family = 
binomial), but I cannot find a reference or example for fitting random 
slopes in different continuous dimensions. I would appreciate any 
pointers in the right direction.


Thanks,
David

In case I've given a poor description of the problem, below is code to 
visualize the rejection threshold, using an optimal decision threshold 
rather than one estimated from the data:


library(mnormt)
library(lattice)

modelms- 31.2
mimicms- 24
sds- 4*4
modelmc- 0.7
mimicmc- 0.4
sdc- 0.15*0.15
xv-seq(0,1,0.01)
yv-seq(10,50,0.1)

ys - matrix(NA,length(xv),length(coeffs[1,]))
for(i in 1:length(xv)) ys[i,] - 
(coeffs[1,]+coeffs[2,]*xv[i])/(coeffs[3,]*-1)


mu - c(modelmc,modelms) #model
sigma - matrix(c(sdc,0,0,sds),2,2)
z1-NULL
for(x in xv){
  f - dmnorm(cbind(x,yv), mu, sigma)
  z1-rbind(z1,f)
}
contour(xv,yv,z1, nlevels = 5,col = blue, lty = solid, lwd = 1.8, 
xlab = proportion yellow, ylab = size)


mu - c(mimicmc,mimicms) #mimic
sigma - matrix(c(sdc,0,0,sds),2,2)
z2-NULL
for(x in xv){
  f - dmnorm(cbind(x,yv), mu, sigma)
  z2-rbind(z2,f)
}
contour(xv,yv,z2, nlevels = 5,add = TRUE,col = red, lty = solid, lwd 
= 1.8)
contour(xv,yv,z2-z1, nlevels = 1,add = TRUE, col = black, lty = 
solid, lwd = 2.5)


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


Re: [R] How to clear R memory in a for loop

2014-10-20 Thread Dimitri Liakhovitski
Thank you, everybody.
Bill - do I interpret your response correctly if I say: we should
check if tuneR is handling .wav files better than mp3 files.

On Mon, Oct 20, 2014 at 12:53 PM, William Dunlap wdun...@tibco.com wrote:
 tuneR::readMP3 may not be allocating (or freeing) memory correctly.  On both
 Linux and Windows I get the following (where 'jingle.mp3' is a sample mp3 that
 comes with Processing 2.1 which has a quarter million samples in it).  If I do
 this as a sequence of top-level expression instead of as a for loop R does not
 crash.  Perhaps you should talk with tuneR's maintainer, who could run 
 valgrind
 over it.

 library(tuneR)
 tuneR = 1.0 has changed its Wave class definition.
 Use updateWave(object) to convert Wave objects saved with previous
 versions of tuneR.
 b - readMP3(jingle.mp3)
 for(i in 1:100){cat(i,);b - readMP3(jingle.mp3)}
 1 2
  *** caught segfault ***
 address 0x3a81000, cause 'memory not mapped'

 Traceback:
  1: .Call(do_read_mp3, data, package = tuneR)
  2: readMP3(jingle.mp3)

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace
 Bill Dunlap
 TIBCO Software
 wdunlap tibco.com


 On Mon, Oct 20, 2014 at 9:25 AM, Jeff Newmiller
 jdnew...@dcn.davis.ca.us wrote:
 It is your responsibility (not mine) to simplify your example to the point 
 where it is small, self-contained, and reproducible (see the footer of this 
 message). In fact, doing so often highlights the issue to you before you 
 share it. If any old downloadable mp3 file can be used to reproduce the 
 problem then you would not need to share yours. (Note that this list strips 
 off most attachments, so links are better anyway.)

 I suspect that one file read repeatedly might create the problem... if it 
 doesn't, then that would be helpful to know. In any event, your example is 
 missing the key element of repetition, so it is not hardly reproducible. The 
 extra things you are doing to make it loop are likely to be important here.
 ---
 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 October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
Jeff,

here is what I do with each file using library(tuneR):

b-readMP3(cairnomount.mp3)
myrange-range(b@left)
write.table(myrange,x myrange.txt,sep=\t)

Would you like me to attach a bunch of large mp3 files?
I don't feel I have the right to clog people's inboxes with large
files.

Thanks!



On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller
jdnew...@dcn.davis.ca.us
wrote:

 You don't say what processing you are doing.. the answer to your
question
 is very likely there. To communicate effectively on this mailing
list,
 self-contained examples are needed. And in order to not corrupt the
example
 you will need to post in plain text.

---
 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 October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski 
 dimitri.liakhovit...@gmail.com wrote:
 Dear Rers,
 
 I am trying to run a for-loop in R.
 During each iteration I read in an mp3 file and do some basic
 processing.
 If I do what I need to do for each file one by one - it works fine.
 But once I start running a loop, it soon runs out of memory and
says:
 can't
 allocate a vector of size...
 In each iteration of my loop I always overwrite the previously
created
 object and do gc().
 
 Any hints on how to fight this?
 
 Thanks a lot!
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



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

Re: [R] distance from fitted line

2014-10-20 Thread Rolf Turner


On 20/10/14 23:00, eliza botto wrote:


Thankyou very much Joachim. Actually I already know the residual()
command. I only wanted to know that is there a way to account for the
fitted lines? its more of a criosity rather than a problem. :)
Thankyou very much once again.


What (on earth!) do you mean by account for the fitted lines?  The 
residuals *are* the (signed, vertical) distances of the observed values 
from the fitted line.


cheers,

Rolf Turner

--
Rolf Turner
Technical Editor ANZJS

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


Re: [R] how to overwrite a Unary operator ?

2014-10-20 Thread Greg Snow
There is currently no way to write your own unary operator in R.  The
only current unary operators are prefix (-, +, !).  It would take some
major changes to the parser to recognize the syntax that you want
(which could also break other things that already work well), and with
the oo and other methods it is not really needed.  You can technically
pass and empty expression to a binary operator:

 `%++%` - function(a,b) a + 1
 x - 5
 x %++% {}
[1] 6

but that does not change the value of the variable (and using `assign`
just creates its own problems).  And syntax like above is more
appropriate for a obfuscated R contest than for anything that you want
to be understood.


There are assignment functions and you could create an object type and
an assignment for such that you might be able to have syntax like:

a - {}

to increment a, but you would need to declare a class for a before
using it and it would probably be even more complicated than needed.

If you really want C like syntax then you could always make an active binding:

 f - local({
+   e - environment()
+   x - 1
+   list(inc = function(v) {
+ if(missing(v)) {
+  e$x - e$x + 1
+ } else {
+ stop('unary inc cannot be assigned to')
+ }
+ x
+   },
+   dec = function(v) {
+ e$x - e$x - 1
+ x
+ } ) } )

 makeActiveBinding(x++, f$inc, .GlobalEnv)
 makeActiveBinding(x--, f$dec, .GlobalEnv)

 `x++`
[1] 2
 `x++`
[1] 3
 `x++`
[1] 4
 `x--`
[1] 3
 `x--`
[1] 2
 `x++`
[1] 3


But it seems simpler to just go with the reference class system at this point.

On Sun, Oct 19, 2014 at 11:17 AM, PO SU rhelpmaill...@163.com wrote:

 It's a good way to use RF OOS, but it's not my needing, actually, i want is 
 there exists a way to write a  %++% form function that can pass one param to 
 it?
 So i can use  1%++%  to get 2 ,a-2 , a%++% to get a-3 .
 It seems that the operator overwrite system in R, must pass two params. Is it 
 true?




 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU



 At 2014-10-18 00:54:40, Greg Snow 538...@gmail.com wrote:
You may be interested in looking at Reference Classes/objects (see
?setRefClass).  This is a form of OO programming that is more similar
to C++ and Java.  You could create a counter object that you could
then increment with syntax like:

x$inc()
x$inc(5)

The first would increment by the default (1), the second would then
increment by 5.



On Fri, Oct 17, 2014 at 2:06 AM, PO SU rhelpmaill...@163.com wrote:

 Tks for your alternative way's details. but like you mentioned in graphics 
 package, i still wonder how to overload an operator which can pass one 
 param like +2 .
 There seems exists some examples for my needing. But i try to find them but 
 without any results.
 can you show me some examples from it?






 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU



 At 2014-10-17 15:16:47, David Winsemius dwinsem...@comcast.net wrote:

On Oct 16, 2014, at 10:36 PM, PO SU wrote:


 Tks for your advice,  let the ++ problem alone, how to write an
 Unary operator ? Is it permitted in R?
 suchasa-2 , a%+2%  will let a  be 4 .

OK, that's just wrong. Oh, OK, just for fun, as it were:

inc - function(x)
{
  eval.parent(substitute(x - x + 1))
}


  inc(10)
Error in 10 - 10 + 1 : invalid (do_set) left-hand side to assignment
  y=10
  inc(y)
  y
[1] 11


 I just want to know it , i won't pollute r with it , because i know
 what is r .  : )

It's certainly permitted. Just look at all the overloadings of the +
operator in graphics packages. Look up the documentation on methods in
R.

Why not just use a well-behaved function, though?

.inc - function(x) x+1
  .inc(10)
[1] 11

Then you won't be tempted to try 10 - .inc(10) because it just
wouldn't make sense.

--
David.

 --

 PO SU
 mail: desolato...@163.com
 Majored in Statistics from SJTU




 At 2014-10-17 13:09:47, Rolf Turner r.tur...@auckland.ac.nz wrote:
 On 17/10/14 17:29, PO SU wrote:

 Dear expeRts,
   Now i want to know how to implement an Unary operator like  i++
 in cpp's  synax form.
   e.g.   2++  will let 2 be 3 ,  a-2 ,a++ ,will let a be 3
 I tried this :
  '%++%'-function(x){
x-x+1
 }
 but it have problem, the biggest one is it seems the function need
 twoparams like a%++%b , how to write a function needing just one
 param?

 TKS !

 Just ***DON'T***.  The ++ operator is useful only for those wish to
 write code which is obscure to the point of incomprehensibility.  It
 makes C and its offspring write only languages.

 If you are going to use R, use R and don't pollute it with such
 abominations.

 cheers,

 Rolf Turner


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

David Winsemius, MD
Alameda, CA, USA

 

Re: [R] distance from fitted line

2014-10-20 Thread eliza botto
Thankyou Turner,
As i said It was out of my curiosity.Thankyou very much for your reply.   :)
Eliza

 Date: Tue, 21 Oct 2014 08:40:39 +1300
 From: r.tur...@auckland.ac.nz
 To: eliza_bo...@hotmail.com
 CC: joachim.audena...@pcsierteelt.be; r-help@r-project.org
 Subject: Re: [R] distance from fitted line
 
 
 On 20/10/14 23:00, eliza botto wrote:
 
  Thankyou very much Joachim. Actually I already know the residual()
  command. I only wanted to know that is there a way to account for the
  fitted lines? its more of a criosity rather than a problem. :)
  Thankyou very much once again.
 
 What (on earth!) do you mean by account for the fitted lines?  The 
 residuals *are* the (signed, vertical) distances of the observed values 
 from the fitted line.
 
 cheers,
 
 Rolf Turner
 
 -- 
 Rolf Turner
 Technical Editor ANZJS
  
[[alternative HTML version deleted]]

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


Re: [R] format negative numbers

2014-10-20 Thread David Winsemius

On Oct 20, 2014, at 4:32 AM, PIKAL Petr wrote:

 Hi
 
 Thanks to all who responded.
 
 My input string is rather clumsy. Actually it can have leading or trailing 
 empty space too, it can be mixture of positive and negative numbers.
 
 In the meantime I made small function which just strips of - sign and make 
 numbers from factors, find numbers which have - sign and change numbers which 
 shall be negative to negative. Not as elegant as your solution but works even 
 when there are leading or trailing spaces.
 
 zapor - function(x) {
 num-as.numeric(gsub((-), , x))

Might want to just use sub() since your method would accept things like 
-100

 zap- grep(-, x)
 num[zap]- num[zap] * (-1)
 num}
 
 x - as.factor( c(   123.4-,123   ))
 zapor(x)
 [1] -123.4  123.0
 

gsub(^(\\s+)([0-9.]+)(-){0,1}(\\s)+$, \\3\\2,
as.factor( c(   123.4-,123   ) ) )
[1] -123.4 123  

Then just `as.numeric`. You method looks more elegant. Depending on the local 
you may get into trouble with variation in decimal markers.


 
 I just thought that there is some reason for presenting negative numbers with 
 minus sign behind the number in finance community and therefore somebody 
 already invented clever way how to deal with such numbers.
 
 Cheers
 Petr
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Marc Girondot
 Sent: Monday, October 20, 2014 12:53 PM
 To: r-help@r-project.org
 Subject: Re: [R] format negative numbers
 
 Is it what you want?
 
 st - 0.123-
 gsub((.+)(-), \\2\\1, st)
 [1] -0.123
 st - 0.123
 gsub((.+)(-), \\2\\1, st)
 [1] 0.123
 
 Sincerely
 Marc
 
 Le 20/10/2014 09:03, PIKAL Petr a écrit :
 Dear all.
 
 Before I start fishing in (for me) murky regular expression waters I
 try to ask community about changing format of negative numbers.
 
 For some reason I get a file with negative numbers formatted with
 negative sign at end of number.
 
 something like
 
 0.123-
 
 It is imported as factors and I need to convert it to numbers again.
 Before converting I need to change it to correct format
 
 -0.123
 
 Does anybody know some simple way?
 
 Cheers
 Petr
 
 
 
 Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a
 

David Winsemius
Alameda, CA, USA

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


Re: [R] making a plot

2014-10-20 Thread Enrico Colosimo
Thanks David and Adrés,

it worked fine.

Enrico.


2014-10-20 15:37 GMT-02:00 David Winsemius dwinsem...@comcast.net:


 On Oct 20, 2014, at 8:24 AM, Andrés Aragón wrote:

  Enrico,
 
  This may help you:
 
  text(locator(1), *, cex=1.5,adj=0.5
 
  and
 
  text(locator(1), º, cex=1.5,adj=0.5

 Why not just use the values of x2 and  y2 that were given to segments:

  text( (ano+ranges)[1:3], 1:3, *, cex=1.5,adj=0.5)
  text( (ano+ranges)[4:6], 4:6 , º, cex=1.5,adj=0.5)

 
 
  Draw your plot, then write the code, locate the cursor on your plot, put
  the symbols where you want itl and click.
 
  Regards,
 
 
  Andrés
 
  PS ?locator
 
 
  2014-10-20 9:46 GMT-05:00 Enrico Colosimo enrico...@gmail.com:
 
  Dear all,
 
  I am struggling to make a plot for my survival analysis
  class.
 
  This is my script
 
 
  labels-c('1','2','3','4','5','6')
  ano-c(2001,2002,2003,2004,2006,2008)
  ranges-c(6,3,4,5,4,2)
  dotchart(ano, labels=labels, xlab='ano',
  ylab='Pacientes',pch=20,xlim=c(min(ano),  max(ano+ranges)))
  segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4)
 
  I need to put an asterix (failure) by the end of the three first lines
 and
  a small circle (censoring)
  by the end of the last three.
 
  Someone can help me?
 
  Thanks,
  Enrico.
 
 [[alternative HTML version deleted]]
 
 --

 David Winsemius
 Alameda, CA, USA



[[alternative HTML version deleted]]

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


Re: [R] pasteFromExcel

2014-10-20 Thread Dan Murphy
Good ideas, David.

1) By confirm that MS Excel honors that OutDec I mean that, in a
location (France? others?) where options(OutDec) is a comma, does MS
Excel format numbers that way when displaying currencies with decimal
places? I have no way of knowing if that is true in all OutDec = ,
locales.

2) I wish it were as simple as just removing unwanted adornments.
The issue is that such adornments must be in their proper places for
the character string to represent a currency value, or a numeric value
for that matter. If I add one more comma to your first element in the
wrong place, it should not translate to a valid numeric, but it does
with your gsub, which would be a bug if that were in pasteFromExcel:
 gsub(rmchar, , c($1,0,00, 1,200, 800))
[1] 1000 1200 800

When I originally looked into this I believed I couldn't be the first
one asking that question .. and I wasn't. There are many hits for
regular expressions that purport to successfully identify well-formed
*US dollar* currency strings. The expression in pasteFromExcel is
based on 
http://stackoverflow.com/questions/354044/what-is-the-best-u-s-currency-regex.

I'm curious if anyone has come across -- and tested -- a similar
regular expression in other places that might have use for
pasteFromExcel.

This is how pasteFromExcel uses its currency regular expression (the
first ugly assignment is what I'm looking for in other locales around
the world -- maybe there's a Regular Expression mailing list out
there):

currencypattern -
^\\$?\\-?([1-9]{1}[0-9]{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\-?\\$?([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\$?\\(([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))\\)$

# Here's a test vector
x - c(1,234.00, 12,34.00, $1,000, (124), $(123), ($123),
  1,000   , NA)

# grep will tell you whether elements of x, trimmed of
beginning/ending whitespace, match the currencypattern
grep(currencypattern, trim(x))
[1] 1 3 4 5 7  # correct answer

*Now* one may remove unwanted characters from the well-formed strings.
And deal with the negatives of course .. and NAs. See how that's
done in excelRio.r in the excelRio package on github:
https://github.com/trinostics/excelRio

Thanks for your interest.


On Mon, Oct 20, 2014 at 10:56 AM, David Winsemius
dwinsem...@comcast.net wrote:

 On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote:

 Nice.
 So if someone were to offer a currency regular expression that works
 in their locale, I should also ask them to give me the results of
 Sys.getlocale(LC_MONETARY)
 and
 options(OutDec)
 and confirm that MS Excel honors that OutDec.

 I'm not sure we can know what you mean by confirm that MS Excel honors that 
 OutDec. The result of options(OutDec) was intended for you to determine 
 what character not to remove from a monetary value in an R workspace. If the 
 assumption is that all values will be in the same unit and that the user is 
 not doing any currency conversions then:

  decsep - options(OutDec)
 rmchar - paste0( [$£€, c(., ,)[!c(., ,) %in% decsep], ] )
 gsub(rmchar, , c($1,000, 1,200, 800))
 [1] 1000 1200 800


 Thank you, David.
 -Dan

 On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius
 dwinsem...@comcast.net wrote:

 On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote:

 To Users of Excel:

 Following advice from Brian and Markus, I created an RMarkdown vignette
 that shows an example of how the pasteFromExcel function in the excelRio
 package on github could be used by an actuary to transfer a triangle from
 Excel to R. See today's post at http://trinostics.blogspot.com/

 Unfortunately, if you are located outside the US, the demonstrated
 functionality will not work for you because the currency regex implemented
 assumes the dollar sign ($) and comma/decimal punctuation of the form
 999,999.00.

 If anyone is interested in contributing currency regex expressions that
 work in your locale, I would be happy to try to incorporate them in the
 package. If anyone knows how best to determine the user's locale (might
 timezone suffice?), I'd appreciate that help too.


 ?Sys.getlocale   # perhaps LC_MONETARY

 ?options   # look for OutDec


  [[alternative HTML version deleted]]



 David Winsemius
 Alameda, CA, USA


 David Winsemius
 Alameda, CA, USA


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


Re: [R] pasteFromExcel

2014-10-20 Thread David Winsemius

On Oct 20, 2014, at 2:34 PM, Dan Murphy wrote:

 Good ideas, David.
 
 1) By confirm that MS Excel honors that OutDec I mean that, in a
 location (France? others?) where options(OutDec) is a comma, does MS
 Excel format numbers that way when displaying currencies with decimal
 places? I have no way of knowing if that is true in all OutDec = ,
 locales.
 
 2) I wish it were as simple as just removing unwanted adornments.
 The issue is that such adornments must be in their proper places for
 the character string to represent a currency value, or a numeric value
 for that matter. If I add one more comma to your first element in the
 wrong place, it should not translate to a valid numeric, but it does
 with your gsub, which would be a bug if that were in pasteFromExcel:
 gsub(rmchar, , c($1,0,00, 1,200, 800))
 [1] 1000 1200 800

If you wanted to restrict the substitutions to only the commas that were 
succeeded by three digits then this succeeds:

gsub((\\,)(\\d{3,3}), \\2, c(1,000,000,000.00) )
[1] 10.00

You should also take a look at formatC which has provisions for output using 
commas.

- 
david.


 
 When I originally looked into this I believed I couldn't be the first
 one asking that question .. and I wasn't. There are many hits for
 regular expressions that purport to successfully identify well-formed
 *US dollar* currency strings. The expression in pasteFromExcel is
 based on 
 http://stackoverflow.com/questions/354044/what-is-the-best-u-s-currency-regex.
 
 I'm curious if anyone has come across -- and tested -- a similar
 regular expression in other places that might have use for
 pasteFromExcel.
 
 This is how pasteFromExcel uses its currency regular expression (the
 first ugly assignment is what I'm looking for in other locales around
 the world -- maybe there's a Regular Expression mailing list out
 there):
 
 currencypattern -
 ^\\$?\\-?([1-9]{1}[0-9]{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\-?\\$?([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\$?\\(([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))\\)$
 
 # Here's a test vector
 x - c(1,234.00, 12,34.00, $1,000, (124), $(123), ($123),
   1,000   , NA)
 
 # grep will tell you whether elements of x, trimmed of
 beginning/ending whitespace, match the currencypattern
 grep(currencypattern, trim(x))
 [1] 1 3 4 5 7  # correct answer
 
 *Now* one may remove unwanted characters from the well-formed strings.
 And deal with the negatives of course .. and NAs. See how that's
 done in excelRio.r in the excelRio package on github:
 https://github.com/trinostics/excelRio
 
 Thanks for your interest.
 
 
 On Mon, Oct 20, 2014 at 10:56 AM, David Winsemius
 dwinsem...@comcast.net wrote:
 
 On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote:
 
 Nice.
 So if someone were to offer a currency regular expression that works
 in their locale, I should also ask them to give me the results of
 Sys.getlocale(LC_MONETARY)
 and
 options(OutDec)
 and confirm that MS Excel honors that OutDec.
 
 I'm not sure we can know what you mean by confirm that MS Excel honors that 
 OutDec. The result of options(OutDec) was intended for you to determine 
 what character not to remove from a monetary value in an R workspace. If the 
 assumption is that all values will be in the same unit and that the user is 
 not doing any currency conversions then:
 
 decsep - options(OutDec)
 rmchar - paste0( [$£€, c(., ,)[!c(., ,) %in% decsep], ] )
 gsub(rmchar, , c($1,000, 1,200, 800))
 [1] 1000 1200 800
 
 
 Thank you, David.
 -Dan
 
 On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius
 dwinsem...@comcast.net wrote:
 
 On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote:
 
 To Users of Excel:
 
 Following advice from Brian and Markus, I created an RMarkdown vignette
 that shows an example of how the pasteFromExcel function in the excelRio
 package on github could be used by an actuary to transfer a triangle from
 Excel to R. See today's post at http://trinostics.blogspot.com/
 
 Unfortunately, if you are located outside the US, the demonstrated
 functionality will not work for you because the currency regex implemented
 assumes the dollar sign ($) and comma/decimal punctuation of the form
 999,999.00.
 
 If anyone is interested in contributing currency regex expressions that
 work in your locale, I would be happy to try to incorporate them in the
 package. If anyone knows how best to determine the user's locale (might
 timezone suffice?), I'd appreciate that help too.
 
 
 ?Sys.getlocale   # perhaps LC_MONETARY
 
 ?options   # look for OutDec
 
 
 [[alternative HTML version deleted]]
 
 
 
 David Winsemius
 Alameda, CA, USA
 
 
 David Winsemius
 Alameda, CA, USA
 

David Winsemius
Alameda, CA, USA

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

Re: [R] Ternary Plots Do Not Display Ellipses in PDF

2014-10-20 Thread Paul Murrell

Hi

I think the problem is that, as David Carlson pointed out, ellipses() 
works by redrawing the plot and adding more to it.


This means that your PDF version has *two pages*, one with the original 
plot, then another with the plot-plus-ellipses.


Paul

On 10/15/14 10:20, Rich Shepard wrote:

   A rather strange situation here and I've not found the source of the
problem.

   The point is to print a ternary plot matrix of compositional data with
ellipses enclosing 95% of the variance in each plot. The ellipses
display on
the monitor, dev = x11cairo (see attached winters-x11cairo.pdf), but not
when
sent directly to a file, dev = pdf (see attached winters-pdf.pdf).

   Here's winters.acomp:

structure(c(0.0667, 0.0612244897959184, 0.0434782608695652,
0.043956043956044, 0.05, 0.0161290322580645, 0.6, 0.571428571428571,
0.623188405797101, 0.593406593406593, 0.433,
0.629032258064516, 0.0667, 0.0612244897959184,
0.101449275362319, 0.0659340659340659, 0.0667,
0.032258064516129, 0.244, 0.26530612244898,
0.217391304347826, 0.263736263736264, 0.367,
0.290322580645161, 0.0222, 0.0408163265306122,
0.0144927536231884, 0.032967032967033, 0.0833,
0.032258064516129), .Dim = c(6L, 5L), .Dimnames = list(
 NULL, c(filter, gather, graze, predate, shred)), class =
acomp)

   And this is the command sequence:


library(compositions)
plot(winters.acomp, main=Winters Creek, cex=0.5)
r - sqrt(qchisq(p=0.95, df=4))
mn - mean(winters.acomp)
vr - var(winters.acomp)
plot(winters.acomp, main=Winters Creek, cex=0.5)
ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE,

 col='red', lwd=2)
# monitor plot window is manually closed.

pdf(winters-pdf.pdf)
plot(winters.acomp, main=Winters Creek, cex=0.5)
ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE,

 col='red', lwd=2)

dev.off()


   What am I not seeing here that causes the different outputs?

Rich


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



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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] Warnings en GLMM (lme4)

2014-10-20 Thread Alex
Hola Javier,
yo me he encontrado con errores similares. Aqu� tienes la respuesta del 
propio Ben Bolker al respecto: 
http://stackoverflow.com/questions/21344555/convergence-error-for-development-version-of-lme4
Como puedes leer, eso podr�a resultar ser un falso positivo y recomienda 
utilizar el siguiente optimizador:

  control=glmerControl(optimizer=bobyqa)

Otra cuesti�n es el reescalado de las variables. Posiblemente tengas 
variables de diferentes �rdenes de magnitud lo que dificulta que 
converja el modelo. Te recomiendo que re-escales tus variables 
(centrarlas y ponerlas todas en el mismo orden de magnitud puede ser una 
buena opci�n).
Con estos peque�os tips yo he conseguido que mi modelo funcione sin 
warnings, espero que sean de ayuda.
Un saludo,
-- 

*Alexandre Alonso Fern�ndez**
*Instituto de Investigaciones Marinas, IIM-CSIC
Departamento de Recursos y Ecolog�a Marina
Grupo de Ecolog�a Pesquera

c/ Eduardo Cabello 6, 36208 Vigo (Pontevedra) ESPA�A
Tel�fono: (+34) 986 23 19 30Ext. 241
Fax: (+34) 986 29 27 62
a...@iim.csic.es http://www.iim.csic.es/pesquerias
http://pesquerias.iim.csic.es http://www.iim.csic.es/pesquerias
https://twitter.com/FisheriesIIM



El 20/10/2014 5:55, Freddy Omar L�pez Quintero escribi�:
 Hola Javier. Talvez peque de obvio, pero tu problema no es exactamente
 del software sino del modelo. El mensaje es claro: casi no es
 identificable. Puedes aumentar el n�mero de iteraciones para ver si
 este modelo espec�fico converge felizmente (no s� si tenga esta opci�n
 la funci�n).

 Lo que yo, externamente, sospecho, es que el modelo tiene muchos
 efectos aleatorios (a�o, nido, hembra, macho) y posiblemente una gran
 cantidad de interacciones. Considera correr un modelo con un
 intercepto aleatorio primero y observa si obtienes warnings por
 convergencia. Eso te dar� ideas del problema.

 �Salud!

 On 10/19/14, javier bueno enciso jbuenoenc...@hotmail.com wrote:
 Hola,
 Soy nuevo manejando R y no tengo mucha experiencia. Estoy intentando modelar
 una funci�n que me relacione el n� de cebas (n� de presas que los padres
 traen a los pollos) con el tama�o de parche de un bosque (factor categ�rico;
 2 niveles= grande y peque�o). Al ser un conteo (n� de cebas) he pensado
 utilizar familia= poisson con link= logar�tmico. He construido un GLMM con:
 N� de cebas (variable respuesta), Duraci�n del video (esfuerzo de muestreo:
 60, 50 y 45 minutos) como una offset en el modelo (transform�ndola
 previamente por el logaritmo). Tama�o de parche, factor explicativo, N� de
 pollos y fecha de puesta covariables. Adem�s he incluido como random el a�o
 de estudio (3 a�os), el ID del nido anidado dentro del ID de cada parche
 (tengo varios parches, grandes y peque�os) y la identidad del padre y de la
 madre tambi�n como r�ndom, puesto que se pueden repetir entre a�os. La
 estructura de mi modelo es la siguiente:
 #paquete(lme4), mi versi�n de R es la 3.1.1.

 m1- glmer(ncebas~offset(LogDur_video)+ Tama�oParche*Ldate*Csize+(1|YEAR) +
 (1|Bosque/nideo)+ (1|Hembra) + (1|Macho), data=Cebas,
 family=poisson(link=log)) #con todas las variables e interacciones posibles
 para que sirva como referencia a la hora de la selecci�n del modelo final.

 El modelo me funciona, sin embargo me aparecen unos warnings que no s� a que
 se deben ni la importancia real en el c�culo de mi modelo. Mi pregunta es si
 alguien en el foro sabe  porqu� aparecen y como solucionarlos. Los warnings
 son:

 Warning messages:
 1: In checkConv(attr(opt, derivs), opt$par, ctrl = control$checkConv,  :
Model failed to converge with max|grad| = 0.00431561 (tol = 0.001,
 component 7)
 2: In checkConv(attr(opt, derivs), opt$par, ctrl = control$checkConv,  :
Model is nearly unidentifiable: very large eigenvalue
   - Rescale variables?;Model is nearly unidentifiable: large eigenvalue
 ratio
   - Rescale variables?
 Muchas gracias, atentamente,
 Javier
  
  [[alternative HTML version deleted]]





https://twitter.com/FisheriesIIM

[[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-es] pregunta (Carlos Ortega)

2014-10-20 Thread Pedro Concejero Cerezo

Hola, muchas gracias, Carlos, por el codigo. Faltaba una 'e' en
ColorBrewer y he puesto alguna cosa mas para ejecutarlo todo seguido, lo
comparto con todos:


# CÓDIGO DE CARLOS ORTEGA CON ALGÚN AÑADIDO PARA EJECUTAR DE UN TIRÓN

#---
library(RColorBrewer)
library(forecast)
library(RCurl)

urlfile -
'https://stat.ethz.ch/pipermail/r-help-es/attachments/20141019/c7698e86/attachment-0001.obj'

datIn - read.csv(urlfile, header=T, as.is=T, sep=,)

# hay una ñ (año) en el nombre del campo mejor llamarlo anio

names(datIn)[3] - anio

summary(datIn)

#Construyo la serie temporal
datEnd - ts(datIn$cantidad, frequency=52, start=2005)

#Defino conjunto de colores
micolores - brewer.pal(length(unique(datIn$anio)),Paired)
#Graficos de las series
seasonplot(datEnd, col=micolores, year.labels=TRUE)
plot(datEnd)
#---



--
*Pedro Concejero
BI  Big Data - Internal Exploitation - Telefónica I+D http://www.tid.es
E-mail: pedro.concejerocer...@telefonica.com
skype: pedro.concejero
twitter @ConcejeroPedro https://twitter.com/ConcejeroPedro
linkedin pedroconcejero http://www.linkedin.com/in/pedroconcejero/es
Entusiasta R, me encontraréis aquí gRupo R madRid
http://madrid.r-es.org/ *



Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede 
contener información privilegiada o confidencial y es para uso exclusivo de la 
persona o entidad de destino. Si no es usted. el destinatario indicado, queda 
notificado de que la lectura, utilización, divulgación y/o copia sin 
autorización puede estar prohibida en virtud de la legislación vigente. Si ha 
recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente 
por esta misma vía y proceda a su destrucción.

The information contained in this transmission is privileged and confidential 
information intended only for the use of the individual or entity named above. 
If the reader of this message is not the intended recipient, you are hereby 
notified that any dissemination, distribution or copying of this communication 
is strictly prohibited. If you have received this transmission in error, do not 
read it. Please immediately reply to the sender that you have received this 
communication in error and then delete it.

Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode 
conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa 
ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica 
notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização 
pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem 
por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e 
proceda a sua destruição

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


Re: [R-es] pregunta (Carlos Ortega)

2014-10-20 Thread jbetancourt
Gracias!!


--
Nunca digas nunca, di mejor: gracias, permiso, disculpe.

Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

[[alternative HTML version deleted]]

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


[R-es] Añadir nuevas filas en un data table

2014-10-20 Thread Francisco Javier
Buenas tardes a todo el mundo, El motivo de que me dirija al foro es que no s� 
c�mo a�adir unas determinadas filas en un data table seg�n el identificador de 
sujeto. Adem�s, quisiera hacerlo sin recurrir a ning�n paquete de R adicional 
del tipo plyr, dplyr, etc. (no s� si esto es posible). EJEMPLO: 
require(data.table) DT - data.table( id = rep(c(1,8,17),c(2,2,1)), start = 
as.Date(rep(c('2005-02-27','2006-07-17','2005-05-30'),c(2,2,1))), dreg = 
as.Date(c('2006-04-20','2007-02-19','2008-01-15','2008-01-29','2006-02-05')), 
valor = rep(c(24,15,32),c(2,2,1)), end = 
as.Date(rep(c('2007-05-15','2008-02-05','2007-12-31'),c(2,2,1))) )id  
start   dreg valorend1:  1 2005-02-27 2006-04-2024 2007-05-152: 
 1 2005-02-27 2007-02-1924 2007-05-153:  8 2006-07-17 2008-01-1515 
2008-02-054:  8 2006-07-17 2008-01-2915 2008-02-055: 17 2005-05-30 
2006-02-0532 2007-12-31 Mi objetivo es crear un nuevo data table tal que en 
cada �id� se a�adan tantas filas como 31�s de diciembre hayan comprendidos 
entre sus respectivas variables start y end: id  start   dreg valor 
   end1:   1 2005-02-27 2005-12-3124 2007-05-152:   1 2005-02-27 
2006-04-2024 2007-05-153:   1 2005-02-27 2006-12-3124 2007-05-154:   1 
2005-02-27 2007-02-1924 2007-05-155:   8 2006-07-17 2006-12-3115 
2008-02-056:   8 2006-07-17 2007-12-3115 2008-02-057:   8 2006-07-17 
2008-01-1515 2008-02-058:   8 2006-07-17 2008-01-2915 2008-02-059:  17 
2005-05-30 2005-12-3132 2007-12-3110: 17 2005-05-30 2006-02-0532 
2007-12-3111: 17 2005-05-30 2006-12-3132 2007-12-31 Los nuevos valores de 
la variable dreg se obtendr�an aproximadamente como:dreg = 
as.Date(paste0(drang[1L]:(drang[2L] - 1), '-12-31')), donde drang me da el 
m�ximo y m�nimo valor de a�o (no s� si con un bucle?) para cada individuo 
(seg�n start y end) . Muchas gracias!  
[[alternative HTML version deleted]]

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


[R-es] Añadir nuevas filas en un data table

2014-10-20 Thread Francisco Javier
Buenas tardes a todo el mundo,

El motivo de que me dirija al foro es que no s�
c�mo a�adir unas determinadas filas en un data table de una forma eficaz y
seg�n el identificador de sujeto. Adem�s, quisiera hacerlo sin tener que
recurrir a ning�n paquete de R adicional del tipo plyr, dplyr, etc. (no s� si
esto es posible). EJEMPLO:

 

require(data.table)

 

DT - data.table(

 id = rep(c(1,8,17),c(2,2,1)),

 start =
as.Date(rep(c('2005-02-27','2006-07-17','2005-05-30'),c(2,2,1))),

 dreg =
as.Date(c('2006-04-20','2007-02-19','2008-01-15','2008-01-29','2006-02-05')),

 valor = rep(c(24,15,32),c(2,2,1)),

 end = as.Date(rep(c('2007-05-15','2008-02-05','2007-12-31'),c(2,2,1)))

 )

 

   id 
start   dreg valorend

1:  1 2005-02-27 2006-04-2024 2007-05-15

2:  1 2005-02-27 2007-02-1924 2007-05-15

3:  8 2006-07-17 2008-01-1515 2008-02-05

4:  8 2006-07-17 2008-01-2915 2008-02-05

5:
17 2005-05-30 2006-02-0532 2007-12-31

 

 

Mi objetivo es crear un Nuevo data table tal que en
cada �id� se a�adan tantas filas como d�as de fin de a�o tengan comprendidos
entre sus respectivas variables start y end:

 

id  start   dreg valorend

1:   1
2005-02-27 2005-12-3124 2007-05-15

2:   1
2005-02-27 2006-04-2024 2007-05-15

3:   1
2005-02-27 2006-12-3124 2007-05-15

4:   1
2005-02-27 2007-02-1924 2007-05-15

5:   8
2006-07-17 2006-12-3115 2008-02-05

6:   8
2006-07-17 2007-12-3115 2008-02-05

7:   8
2006-07-17 2008-01-1515 2008-02-05

8:
  8
2006-07-17 2008-01-2915 2008-02-05

9:
 17 2005-05-30 2005-12-3132 2007-12-31

10:
17 2005-05-30 2006-02-0532 2007-12-31

11:
17 2005-05-30 2006-12-3132 2007-12-31

  
[[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-es] Añadir nuevas filas en un data table

2014-10-20 Thread Francisco Javier
Disculpas a todo el mundo por la calidad del mensaje, no s� que me pasa en el 
ordenador!!
  
[[alternative HTML version deleted]]

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


[R-es] Seleccionar a partir del nombre de la columna

2014-10-20 Thread Juan Carlos Reale
Buenas noches, estoy realizando un curso en linea sobre la ciencia de
datos, en el proyecto a realizar estamos trabajando una data; tengo la
inquietud de conocer la función que me permita seleccionar las columnas
considerando sólo los nombres de éstas. Y no los valores.

Por Ejemplo, si los nombres de las columnas incluyen ciertos caracteres,
debo seleccionarlas.

Saludos,

Juan Carlos
Venezuela

[[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-es] problemas para descargar R

2014-10-20 Thread Ruben Tobalina Ramirez
buenos días,
prueba a bajarte otra copia, a lo mejor se descargo mal.

El 21 de octubre de 2014, 0:50, Beatriz Marin beatriz.ma...@gmail.com
escribió:

 Hola a todos,

 Espero puedan ayudarme, tengo un problema para descargar R.
 Ya lo he descargado anteriormente sin ningún problema, pero he formateado
 mi computadora y ahora que trato de instalarlo nuevamente desde la página
 oficial de R, me arroja el siguiente mensaje:

 *The setup files are corrupted, Please obtain a new copy of the program*.

 La descarga la trato de hacer para Windows 7, también tengo suficiente
 memoria, etc.

 Quiero saber si es un problema desde la pagina de R o es mi computadora la
 necia.

 Muchas gracias de antemano
 Saludos
 Beatriz

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