Re: [R] sub function problem

2014-03-04 Thread Philippe Grosjean
Hi,

Despite OS is not provided, we can guess it is Windows, since Tinn-R works only 
on Windows. The error message is quite clear, I think: R must start a socket 
server in order for Tinn-R to communicate with it. Did you look at 
?startSocketServer in the svSocket package? Then, you would have a clue of what 
it is.

Now, why is your communication between Tinn-R and R broken once you have 
crashed R (or for some reasons, R did not close completely and a zombie R 
process remains in memory)? Simply because the zombie process has still the 
corresponding socket open, and you cannot start another R process and create a 
server on the same port. You have to kill the zombie first! In Linux, people 
are used to that kind of situation, but many Windows users have difficulties to 
deal with this. See for instance here:
http://www.techrepublic.com/blog/windows-and-office/quick-tip-kill-rogue-processes-with-taskkill-in-microsoft-windows/3585/

Best,

Philippe Grosjean


On 04 Mar 2014, at 08:33, PIKAL Petr petr.pi...@precheza.cz wrote:

 Hi
 
 I also used Tinn-R but an old version 1.18.5.6 and did not experience such 
 error. Maybe you could try to use plain Notepad for your code just to check 
 if it is Tinn-R issue.
 
 I have no idea what the error means. However for anybody to have sensible 
 answer you definitelly need to reveal your OS, R version, Tinn-R version and 
 code which leads to such error.
 
 Regards
 Petr
 
 -Original Message-
 From: Massimiliano Tripoli [mailto:mtrip...@istat.it]
 Sent: Monday, March 03, 2014 5:39 PM
 To: PIKAL Petr
 Cc: r-help@r-project.org
 Subject: Re: [R] sub function problem
 
 Hi Petr,
 thanks for your response.
 You're right. I counted incorrectly the numbers of spaces at the
 beginning of the sub function directly called as you can see at the
 end.
 If the string has a length more than 10 it works correctly returning
 the same string of input except if there are some spaces at the
 beginning, that correctly it reduces to one as it expected.
 But what about the error 10061 that I usually encountered ? In this
 case I used Tinn-R (I know it's not a Tinn-R forum sorry). Is it
 correlated with it.
 
 Thanks
 
 
 
 - Messaggio originale -
 Da: PIKAL Petr petr.pi...@precheza.cz
 A: Massimiliano Tripoli mtrip...@istat.it, r-help@r-project.org
 Inviato: Lunedì, 3 marzo 2014 10:36:02
 Oggetto: RE: [R] sub function problem
 
 Hi
 
 Everything works for me as expected. Nothing happens R starts as usual.
 
 You can shorten your function
 
 corregge2 - function(stringa){
 nc - nchar(stringa)
 stringa - sub(^ , , stringa)
 stringa - sub( +$, , stringa)
 if (nc 9) stringa - NA
 if (nc == 9) stringa - paste(0,stringa,sep=) if (nc == 10) stringa
 - paste(00,stringa,sep=) stringa }
 
 What if your string has length more than 10?
 
 Regards
 Petr
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Massimiliano Tripoli
 Sent: Friday, February 28, 2014 5:44 PM
 To: r-help@r-project.org
 Subject: [R] sub function problem
 
 
 Dear all,
 
 I write a R function that it should handles strings like removing
 spaces at the beginning or returning NA according an IF condition.
 Here you are the code:
 
 corregge.CF - function(stringa){
 nc - nchar(stringa)
 stringa - sub(^ , , stringa)
 stringa - sub( +$, , stringa) if (nc == 1) stringa - NA if
 (nc == 2) stringa - NA if (nc == 3) stringa - NA if (nc == 4)
 stringa - NA if (nc == 5) stringa - NA if (nc == 6) stringa - NA
 if
 (nc == 7) stringa - NA if (nc == 8) stringa - NA if (nc == 9)
 stringa - paste(0,stringa,sep=) if (nc == 10) stringa -
 paste(00,stringa,sep=)
stringa
 }
 
 I had this result:
 
 corregge.CF - function(stringa){
 + nc - nchar(stringa)
 +  stringa - sub(^ , , stringa)
 +  stringa - sub( +$, , stringa) if (nc == 1) stringa - NA
 + if (nc == 2) stringa - NA if (nc == 3) stringa - NA if (nc == 4)
 + stringa - NA if (nc == 5) stringa - NA if (nc == 6) stringa - NA
 + if (nc == 7) stringa - NA if (nc == 8) stringa - NA if (nc == 9)
 + stringa - paste(0,stringa,sep=) if (nc == 10) stringa -
 + paste(00,stringa,sep=)
 + stringa
 + }
 corregge.CF ( fsfhsfh)
 [1] NA
 nchar( fsfhsfh)
 [1] 8
 sub(^  , ,   fghaghf)
 [1] fghaghf
 
 
 And restarting R I had this message:
 
 Error:10061
 R is not in server mode.
 Please, start R and/or run the startSocket Server function available
 in svSocket package!
 
 Anyone could help me,
 Thanks in advance
 
 
 
 --
 Massimiliano Tripoli
 Collaboratore T.E.R. scado il 31/12/2014 ISTAT - DCCN - Direzione
 Centrale della Contabilità Nazionale U.O. Conti trimestrali delle
 amministrazioni pubbliche e conti della sanità - FIP/E Via Depretis,
 74/B 00184 Roma Tel. 06.4673.3132
 E-mail: mtrip...@istat.it
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http

Re: [R] sub function problem

2014-03-03 Thread PIKAL Petr
Hi

Everything works for me as expected. Nothing happens R starts as usual.

You can shorten your function

corregge2 - function(stringa){
nc - nchar(stringa)
 stringa - sub(^ , , stringa)
 stringa - sub( +$, , stringa)
if (nc 9) stringa - NA
if (nc == 9) stringa - paste(0,stringa,sep=)
if (nc == 10) stringa - paste(00,stringa,sep=)
stringa
}

What if your string has length more than 10?

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Massimiliano Tripoli
 Sent: Friday, February 28, 2014 5:44 PM
 To: r-help@r-project.org
 Subject: [R] sub function problem


 Dear all,

 I write a R function that it should handles strings like removing
 spaces at the beginning or
 returning NA according an IF condition. Here you are the code:

 corregge.CF - function(stringa){
 nc - nchar(stringa)
  stringa - sub(^ , , stringa)
  stringa - sub( +$, , stringa)
 if (nc == 1) stringa - NA
 if (nc == 2) stringa - NA
 if (nc == 3) stringa - NA
 if (nc == 4) stringa - NA
 if (nc == 5) stringa - NA
 if (nc == 6) stringa - NA
 if (nc == 7) stringa - NA
 if (nc == 8) stringa - NA
 if (nc == 9) stringa - paste(0,stringa,sep=)
 if (nc == 10) stringa - paste(00,stringa,sep=)
 stringa
 }

 I had this result:

  corregge.CF - function(stringa){
 + nc - nchar(stringa)
 +  stringa - sub(^ , , stringa)
 +  stringa - sub( +$, , stringa)
 + if (nc == 1) stringa - NA
 + if (nc == 2) stringa - NA
 + if (nc == 3) stringa - NA
 + if (nc == 4) stringa - NA
 + if (nc == 5) stringa - NA
 + if (nc == 6) stringa - NA
 + if (nc == 7) stringa - NA
 + if (nc == 8) stringa - NA
 + if (nc == 9) stringa - paste(0,stringa,sep=)
 + if (nc == 10) stringa - paste(00,stringa,sep=)
 + stringa
 + }
  corregge.CF ( fsfhsfh)
 [1] NA
  nchar( fsfhsfh)
 [1] 8
   sub(^  , ,   fghaghf)
 [1] fghaghf
 

 And restarting R I had this message:

 Error:10061
 R is not in server mode.
 Please, start R and/or run the startSocket Server function
 available in svSocket package!

 Anyone could help me,
 Thanks in advance



 --
 Massimiliano Tripoli
 Collaboratore T.E.R. scado il 31/12/2014
 ISTAT - DCCN - Direzione Centrale della Contabilità Nazionale
 U.O. Conti trimestrali delle amministrazioni pubbliche e conti della
 sanità - FIP/E
 Via Depretis, 74/B 00184 Roma
 Tel. 06.4673.3132
 E-mail: mtrip...@istat.it

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


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) 

Re: [R] sub function problem

2014-03-03 Thread Massimiliano Tripoli
Hi Petr,
thanks for your response.
You're right. I counted incorrectly the numbers of spaces at the beginning of 
the sub function directly called as you can see at the end.
If the string has a length more than 10 it works correctly returning the same 
string of input except if there are some spaces at the
beginning, that correctly it reduces to one as it expected.
But what about the error 10061 that I usually encountered ? In this case I used 
Tinn-R (I know it's not a Tinn-R forum sorry). Is it correlated with it.

Thanks



- Messaggio originale -
Da: PIKAL Petr petr.pi...@precheza.cz
A: Massimiliano Tripoli mtrip...@istat.it, r-help@r-project.org
Inviato: Lunedì, 3 marzo 2014 10:36:02
Oggetto: RE: [R] sub function problem

Hi

Everything works for me as expected. Nothing happens R starts as usual.

You can shorten your function

corregge2 - function(stringa){
nc - nchar(stringa)
 stringa - sub(^ , , stringa)
 stringa - sub( +$, , stringa)
if (nc 9) stringa - NA
if (nc == 9) stringa - paste(0,stringa,sep=)
if (nc == 10) stringa - paste(00,stringa,sep=)
stringa
}

What if your string has length more than 10?

Regards
Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Massimiliano Tripoli
 Sent: Friday, February 28, 2014 5:44 PM
 To: r-help@r-project.org
 Subject: [R] sub function problem


 Dear all,

 I write a R function that it should handles strings like removing
 spaces at the beginning or
 returning NA according an IF condition. Here you are the code:

 corregge.CF - function(stringa){
 nc - nchar(stringa)
  stringa - sub(^ , , stringa)
  stringa - sub( +$, , stringa)
 if (nc == 1) stringa - NA
 if (nc == 2) stringa - NA
 if (nc == 3) stringa - NA
 if (nc == 4) stringa - NA
 if (nc == 5) stringa - NA
 if (nc == 6) stringa - NA
 if (nc == 7) stringa - NA
 if (nc == 8) stringa - NA
 if (nc == 9) stringa - paste(0,stringa,sep=)
 if (nc == 10) stringa - paste(00,stringa,sep=)
 stringa
 }

 I had this result:

  corregge.CF - function(stringa){
 + nc - nchar(stringa)
 +  stringa - sub(^ , , stringa)
 +  stringa - sub( +$, , stringa)
 + if (nc == 1) stringa - NA
 + if (nc == 2) stringa - NA
 + if (nc == 3) stringa - NA
 + if (nc == 4) stringa - NA
 + if (nc == 5) stringa - NA
 + if (nc == 6) stringa - NA
 + if (nc == 7) stringa - NA
 + if (nc == 8) stringa - NA
 + if (nc == 9) stringa - paste(0,stringa,sep=)
 + if (nc == 10) stringa - paste(00,stringa,sep=)
 + stringa
 + }
  corregge.CF ( fsfhsfh)
 [1] NA
  nchar( fsfhsfh)
 [1] 8
   sub(^  , ,   fghaghf)
 [1] fghaghf
 

 And restarting R I had this message:

 Error:10061
 R is not in server mode.
 Please, start R and/or run the startSocket Server function
 available in svSocket package!

 Anyone could help me,
 Thanks in advance



 --
 Massimiliano Tripoli
 Collaboratore T.E.R. scado il 31/12/2014
 ISTAT - DCCN - Direzione Centrale della Contabilità Nazionale
 U.O. Conti trimestrali delle amministrazioni pubbliche e conti della
 sanità - FIP/E
 Via Depretis, 74/B 00184 Roma
 Tel. 06.4673.3132
 E-mail: mtrip...@istat.it

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


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

Re: [R] sub function problem

2014-03-03 Thread PIKAL Petr
Hi

I also used Tinn-R but an old version 1.18.5.6 and did not experience such 
error. Maybe you could try to use plain Notepad for your code just to check if 
it is Tinn-R issue.

I have no idea what the error means. However for anybody to have sensible 
answer you definitelly need to reveal your OS, R version, Tinn-R version and 
code which leads to such error.

Regards
Petr

 -Original Message-
 From: Massimiliano Tripoli [mailto:mtrip...@istat.it]
 Sent: Monday, March 03, 2014 5:39 PM
 To: PIKAL Petr
 Cc: r-help@r-project.org
 Subject: Re: [R] sub function problem

 Hi Petr,
 thanks for your response.
 You're right. I counted incorrectly the numbers of spaces at the
 beginning of the sub function directly called as you can see at the
 end.
 If the string has a length more than 10 it works correctly returning
 the same string of input except if there are some spaces at the
 beginning, that correctly it reduces to one as it expected.
 But what about the error 10061 that I usually encountered ? In this
 case I used Tinn-R (I know it's not a Tinn-R forum sorry). Is it
 correlated with it.

 Thanks



 - Messaggio originale -
 Da: PIKAL Petr petr.pi...@precheza.cz
 A: Massimiliano Tripoli mtrip...@istat.it, r-help@r-project.org
 Inviato: Lunedì, 3 marzo 2014 10:36:02
 Oggetto: RE: [R] sub function problem

 Hi

 Everything works for me as expected. Nothing happens R starts as usual.

 You can shorten your function

 corregge2 - function(stringa){
 nc - nchar(stringa)
  stringa - sub(^ , , stringa)
  stringa - sub( +$, , stringa)
 if (nc 9) stringa - NA
 if (nc == 9) stringa - paste(0,stringa,sep=) if (nc == 10) stringa
 - paste(00,stringa,sep=) stringa }

 What if your string has length more than 10?

 Regards
 Petr

  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Massimiliano Tripoli
  Sent: Friday, February 28, 2014 5:44 PM
  To: r-help@r-project.org
  Subject: [R] sub function problem
 
 
  Dear all,
 
  I write a R function that it should handles strings like removing
  spaces at the beginning or returning NA according an IF condition.
  Here you are the code:
 
  corregge.CF - function(stringa){
  nc - nchar(stringa)
   stringa - sub(^ , , stringa)
   stringa - sub( +$, , stringa) if (nc == 1) stringa - NA if
  (nc == 2) stringa - NA if (nc == 3) stringa - NA if (nc == 4)
  stringa - NA if (nc == 5) stringa - NA if (nc == 6) stringa - NA
 if
  (nc == 7) stringa - NA if (nc == 8) stringa - NA if (nc == 9)
  stringa - paste(0,stringa,sep=) if (nc == 10) stringa -
  paste(00,stringa,sep=)
  stringa
  }
 
  I had this result:
 
   corregge.CF - function(stringa){
  + nc - nchar(stringa)
  +  stringa - sub(^ , , stringa)
  +  stringa - sub( +$, , stringa) if (nc == 1) stringa - NA
  + if (nc == 2) stringa - NA if (nc == 3) stringa - NA if (nc == 4)
  + stringa - NA if (nc == 5) stringa - NA if (nc == 6) stringa - NA
  + if (nc == 7) stringa - NA if (nc == 8) stringa - NA if (nc == 9)
  + stringa - paste(0,stringa,sep=) if (nc == 10) stringa -
  + paste(00,stringa,sep=)
  + stringa
  + }
   corregge.CF ( fsfhsfh)
  [1] NA
   nchar( fsfhsfh)
  [1] 8
sub(^  , ,   fghaghf)
  [1] fghaghf
  
 
  And restarting R I had this message:
 
  Error:10061
  R is not in server mode.
  Please, start R and/or run the startSocket Server function available
  in svSocket package!
 
  Anyone could help me,
  Thanks in advance
 
 
 
  --
  Massimiliano Tripoli
  Collaboratore T.E.R. scado il 31/12/2014 ISTAT - DCCN - Direzione
  Centrale della Contabilità Nazionale U.O. Conti trimestrali delle
  amministrazioni pubbliche e conti della sanità - FIP/E Via Depretis,
  74/B 00184 Roma Tel. 06.4673.3132
  E-mail: mtrip...@istat.it
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-
  guide.html and provide commented, minimal, self-contained,
  reproducible code.

 
 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