[R] I can't do it again on an other PC : R+RMySQL -error loading dll

2007-09-10 Thread Ptit_Bleu

Hello,

Some weeks ago, thanks to you, I managed to install R, to connect to a local
MySQL Database and to launch some queries with a script written with Tinn-R. 
My script is now ok and would like to test it with the real database.
I did the same installation of R, DBI package and RMySQL package I did on my
PC (I wrote everything I did in order to make it easy ...) but when I type
libray(RMySQL), I got an error message (see below).

I tried to copy libmySQL.dll and RMySQL.dll in \system\ (like on my PC), in
\system32\, in \R\bin\ and to change the path. But always the same error
message ...

Has anybody any other solution I can try ?
Thanks in advance,
Ptit Bleu.   


-
R version 2.5.1 (2007-06-27)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.

R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.

Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.

 library()
 .libPaths()
[1] C:/R/library
 library(DBI)
 library(RMySQL)
Error in dyn.load(x, as.logical(local), as.logical(now)) : 
impossible de charger la bibliothèque partagée
'C:/R/library/RMySQL/libs/RMySQL.dll':
  LoadLibrary failure:  L'accès à cet emplacement de la mémoire n'est pas
valide.


Erreur : le chargement du package / espace de noms a échoué pour 'RMySQL'
 

-- 
View this message in context: 
http://www.nabble.com/I-can%27t-do-it-again-on-an-other-PC-%3A-R%2BRMySQL--%3Eerror-loading-dll-tf4414597.html#a12592576
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Shame on me ...

2007-09-03 Thread Ptit_Bleu

I  read again R pour les débutants (for another problem) and I found the
answer to my question.
Sorry .
Have a nice week,
Ptiti Bleu.

Felix Andrews wrote:
 
 x[[1]][4]
 
 On 8/31/07, Ptit_Bleu [EMAIL PROTECTED] wrote:
 Hi,

 I read the posts for 2 hours and ?list and tried many comninations but I
 haven't found the answer to this basic question. So I decided to post my
 question even if it is a silly one ...

 What is the instruction to retrieve, for example, the D of the first
 list
 ?
 Thanks in advance,
 Ptit Bleu.


  x-list(LETTERS[1:5], LETTERS[10:20])
  x
 [[1]]
 [1] A B C D E

 [[2]]
  [1] J K L M N O P Q R S T

 --
 View this message in context:
 http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12422479
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@stat.math.ethz.ch 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.

 
 
 -- 
 Felix Andrews / 安福立
 PhD candidate
 Integrated Catchment Assessment and Management Centre
 The Fenner School of Environment and Society
 The Australian National University (Building 48A), ACT 0200
 Beijing Bag, Locked Bag 40, Kingston ACT 2604
 http://www.neurofractal.org/felix/
 voice:+86_1051404394 (in China)
 mobile:+86_13522529265 (in China)
 mobile:+61_410400963 (in Australia)
 xmpp:[EMAIL PROTECTED]
 3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12457151
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Problem of vocabulary : retrieve element of a list of a list

2007-08-31 Thread Ptit_Bleu

Hi,

I read the posts for 2 hours and ?list and tried many comninations but I
haven't found the answer to this basic question. So I decided to post my
question even if it is a silly one ...

What is the instruction to retrieve, for example, the D of the first list
?
Thanks in advance,
Ptit Bleu.


 x-list(LETTERS[1:5], LETTERS[10:20])
 x
[[1]]
[1] A B C D E

[[2]]
 [1] J K L M N O P Q R S T

-- 
View this message in context: 
http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12422479
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Problem of vocabulary : retrieve element of a list of a list

2007-08-31 Thread Ptit_Bleu

In fact I read R pour les debutants by Emmanuel Paradis but I didn't find
the solution.
Then I looked for on R-Help with no result.

Again I do aplologize for this silly question and I thank you for the
solution (second one).
Ptit Bleu (who won't send others silly questions in the future) 


jiho wrote:
 
 On 2007-August-31  , at 10:17 , Ptit_Bleu wrote:
 
 x-list(LETTERS[1:5], LETTERS[10:20])
 
 not sure to have understood exactly what you meant.
 if you want to search for the D in the list:
   lapply(x,charmatch,D)
 should get you started.
 
 if you just want to know the syntax to extract an element from a list
   x[[1]][4]
 will get you the D. but I a sure you would have found out if you  
 read the manual carefully.
 
 maybe you should read an R introduction and practice on the examples  
 there rather than go straight into your own data. It would take a  
 week at most and is very rewarding in the long term.
 An introduction in english:
   http://cran.r-project.org/doc/manuals/R-intro.pdf
 A nice one in French
   http://www.cran.r-project.org/doc/contrib/Paradis-rdebuts_fr.pdf
 
 Cheers,
 
 JiHO
 ---
 http://jo.irisson.free.fr/
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Problem-of-vocabulary-%3A-retrieve-element-of-a-list-of-a-list-tf4358872.html#a12423052
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Strage result with an append/strptime combination

2007-08-30 Thread Ptit_Bleu

Hi again,

Just a quick post to propose another solution (without chron) :
strptime function on the whole object and not on each namefile. 

 namefile-070707050642.dat
 namefile-append(namefile,namefile)
 namefile-append(namefile,namefile)
 namefile
[1] 070707050642.dat 070707050642.dat 070707050642.dat
070707050642.dat
 jourheure-strptime(namefile,%d%m%y%H%M%S)
 jourheure
[1] 2007-07-07 05:06:42 2007-07-07 05:06:42 2007-07-07 05:06:42
2007-07-07 05:06:42




Gabor Grothendieck wrote:
 
 Try chron:
 
 library(chron)
 namefile - 070707050642.dat#day-month-year-hour-minute-second.dat
 x - chron(substr(namefile, 1, 6), substr(namefile, 7, 12),
 +   format = c(dmy, hms), out.format = c(m/d/y, h:m:s))
 c(x, x)
 [1] (07/07/07 05:06:42) (07/07/07 05:06:42)
 
 See R News 4/1 Help Desk article for more.
 
 


 Hi,

 I keep on trying to write some small scripts in order to learn R but even
 with basic scripts I have problems ...

 I start with the name of a file which is in fact the time the file has
 been
 generated (I cannot change the format). Then I convert namefile with
 strptime. The problem occurs when I add another time from another file
 with
 append. It displays some informations I don't want.

 I found a post about this problem
 (http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but
 I
 don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it
 has
 no effect.

 Do you have some ideas to solve this problem ?
 Thank you for your help.
 Ptit Bleu.

 ---

 namefile-070707050642.dat#day-month-year-hour-minute-second.dat
 jourheure-strptime(namefile,%d%m%y%H%M%S)

  jourheure
 [1] 2007-07-07 05:06:42

 jourheure-append(jourheure,jourheure)
  jourheure
 [1] 2007-07-07 05:06:42 Paris, Madrid (heure d'été) 2007-07-07
 05:06:42
 Paris, Madrid (heure d'été)

 --
 View this message in context:
 http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
 Sent from the R help mailing list archive at Nabble.com.

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

-- 
View this message in context: 
http://www.nabble.com/Strange-result-with-an-append-strptime-combination-tf4347401.html#a12403499
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Strage result with an append/strptime combination

2007-08-29 Thread Ptit_Bleu

Hi,

I keep on trying to write some small scripts in order to learn R but even
with basic scripts I have problems ...

I start with the name of a file which is in fact the time the file has been
generated (I cannot change the format). Then I convert namefile with
strptime. The problem occurs when I add another time from another file with
append. It displays some informations I don't want.

I found a post about this problem
(http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but I
don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it has
no effect.

Do you have some ideas to solve this problem ?
Thank you for your help.
Ptit Bleu.

---

namefile-070707050642.dat#day-month-year-hour-minute-second.dat
jourheure-strptime(namefile,%d%m%y%H%M%S)

 jourheure
[1] 2007-07-07 05:06:42

jourheure-append(jourheure,jourheure)
 jourheure
[1] 2007-07-07 05:06:42 Paris, Madrid (heure d'été) 2007-07-07 05:06:42
Paris, Madrid (heure d'été)

-- 
View this message in context: 
http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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 let the program know the end of a file is reached?

2007-08-29 Thread Ptit_Bleu

Hi Yuchen,

I'm not sure my message will help you but who knows (I'm a newbie : I
discovered R one month ago).

To load data file, I use
donnees-read.table(datafile.dat, quote=\, sep=;, dec=,, skip=18)
and I don't need to tell when to stop. R knows it.

Good luck,
Ptit Bleu.



Yuchen Luo wrote:
 
 Dear collegues.
 I am using scan( )  to read from a table (a csv file).
 I am wondering how to let the program know that the end of the file is
 reached?
 
 Your help will be highly appreciated!
 
 Best Wishes
 Yuchen Luo
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/How-to-let-the-program-know-the-end-of-a-file-is-reached--tf4346243.html#a12386085
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Strage result with an append/strptime combination

2007-08-29 Thread Ptit_Bleu

Thanks Gabor !

It works.
Just one more thing : is there a possibility to remove ( and ) before I
copy the data to a MySQL database.

Again thank you for the tip.
Ptit Bleu.


Gabor Grothendieck wrote:
 
 Try chron:
 
 library(chron)
 namefile - 070707050642.dat#day-month-year-hour-minute-second.dat
 x - chron(substr(namefile, 1, 6), substr(namefile, 7, 12),
 +   format = c(dmy, hms), out.format = c(m/d/y, h:m:s))
 c(x, x)
 [1] (07/07/07 05:06:42) (07/07/07 05:06:42)
 
 See R News 4/1 Help Desk article for more.
 
 
 On 8/29/07, Ptit_Bleu [EMAIL PROTECTED] wrote:

 Hi,

 I keep on trying to write some small scripts in order to learn R but even
 with basic scripts I have problems ...

 I start with the name of a file which is in fact the time the file has
 been
 generated (I cannot change the format). Then I convert namefile with
 strptime. The problem occurs when I add another time from another file
 with
 append. It displays some informations I don't want.

 I found a post about this problem
 (http://www.nabble.com/Error-with-strptime-tf3607942.html#a10081942) but
 I
 don't understand the solution. I tested as.POSIXct or as.POSIX.lt but it
 has
 no effect.

 Do you have some ideas to solve this problem ?
 Thank you for your help.
 Ptit Bleu.

 ---

 namefile-070707050642.dat#day-month-year-hour-minute-second.dat
 jourheure-strptime(namefile,%d%m%y%H%M%S)

  jourheure
 [1] 2007-07-07 05:06:42

 jourheure-append(jourheure,jourheure)
  jourheure
 [1] 2007-07-07 05:06:42 Paris, Madrid (heure d'été) 2007-07-07
 05:06:42
 Paris, Madrid (heure d'été)

 --
 View this message in context:
 http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12385852
 Sent from the R help mailing list archive at Nabble.com.

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

-- 
View this message in context: 
http://www.nabble.com/Strage-result-with-an-append-strptime-combination-tf4347401.html#a12386702
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Strage result with an append/strptime combination

2007-08-29 Thread Ptit_Bleu

In french, I wouls say Chapeau bas. In english, no idea. So I just say
Thanks again.
Ptit Bleu (reading chron reference manual :-).



Try


fmt - function(x) with(month.day.year(x),
sprintf(%02d/%02d/%02d %02d:%02d:%02d, month, day, year,
hours(x), minutes(x), seconds(x)))
fmt(x)


On 8/29/07, Ptit_Bleu [EMAIL PROTECTED] wrote:

 Thanks Gabor !

 It works.
 Just one more thing : is there a possibility to remove ( and ) before
 I
 copy the data to a MySQL database.

 Again thank you for the tip.
 Ptit Bleu.
-- 
View this message in context: 
http://www.nabble.com/Strange-result-with-an-append-strptime-combination-tf4347401.html#a12387275
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Problem with save or/and if (I think but maybe not ...)

2007-08-27 Thread Ptit_Bleu

Hi,

I recently discovered the R program and I thought it could be useful to me.
I have to analyse data saved as .Px file (x between 0 and 8 - .P0 files have
18 lines at the beginning that I have to skip). New files are generated
everyday.

This is my strategy :

In order to analyse the data, I first want to copy the new data in a
database in MySQL (which already contains the previous data).
So the first task is to compare the list of the files in the directory
(object : rfichiers) to the list of the files already saved (object :
tfichiers). The list containing the new files is then given by
nfichiers-setdiff(rfichiers, tfichiers).

It sounds easy ...
... but it doesn't work !!!

Up to now, I'm am able to connect to MySQL and, if the file tfichiers.r
doesn't exist, I can copy data files to the MySQL database.
But if tfichiers.r already exists and there is no new file to save, it
ignores the condition if (nfichiers!=0) and save all the files of the
directory to the database.

Is it a problem with the way I save tfichiers or is it a problem with the
condition if (nfichiers!=0) ?
Could you please give me some advices to correct my script (written with
Tinn-R) ?

I thank you in advance for your help.
Have a nice week,
Ptit Bleu.

PS : Ptit Bleu means something like Full Newbye in french. So thanks to be
patient :-)
PPS : I hope you understand my french english

--


# Connexion a la base de donnees database de MySQL

library(DBI)
library(RMySQL)
drv-dbDriver(MySQL)
con-dbConnect(drv, username=user, password=password, dbname=database,
host=localhost)


# Creation des objets contenant la liste des fichiers (rel pour chemin
relatif)
# - dans le repertoire : objet rfichiers
# - deja traites : objet tfichiers
# - nouveaux depuis la derniere connexion : objet nfichiers
# chemin est le repertoire de stockage des donnees
# RWork est le repertoire de travail de R
# sep='' pour eviter l'ajout d'un espace apres Mydata/

setwd(D:/RWork)
chemin-d:/Mydata/
relrfichiers-dir(chemin, pattern=.P)
rfichiers-paste(chemin,relrfichiers, sep='')

if (file.exists(tfichiers.r))
  {
tfichiers-load(tfichiers.r)
nfichiers-setdiff(rfichiers,tfichiers)
  } else {
nfichiers-rfichiers
  }


# p0fichiers : fichiers avec l'extension .P0 (fichiers contenant des lignes
d'infos à ne pas charger)
# pxfichiers : fichiers avec les extensions P1, ..., P8 (sans infos au
debut)

if (nfichiers!=0)
{
  p0fichiers-nfichiers[grep(.P0, nfichiers)]
  pxfichiers-setdiff(nfichiers, p0fichiers)


# Fusion des colonnes jour et heure pour permettre de tracer des variations
en fonction du temps
# Chaque fichier contenu dans l'objet p0fichiers est chargé, en supprimant
les 18 premieres lignes,
# et on met dans l'objet jourheure la fusion de la colonne jour (V1) et de
la colonne heure (V2)
# L'objet jourheure est recopie dans la premiere colonne de donnees
# On supprime ensuite la deuxieme colonne (contenant les heures) qui est
maintenant superflue
# L'objet donnees est copié dans la base de donnees MySQL Mydata
# Remarque : R comprend le format jour/mois/annee - MySQL : annee/mois/jour
- stockage en CHAR dans MySQL

  for (i in 1:length(p0fichiers))
{
  donnees-read.table(p0fichiers[i], quote=\, sep=;, dec=,,
skip=18)
  jourheure-paste(donnees$V1, donnees$V2, sep= )
  donnees[1]-jourheure
  donnees-donnees[,-2]
#  assignTable(con, Datatable, donnees, append=TRUE) - Ne marche pas
  dbWriteTable(con, Datatable, donnees, append=TRUE)
  rm(donnees, jourheure)
}


# Idem avec les fichiers d'extension .Px en chargant toutes les lignes
(skip=0)
# Amelioration possible : creer une fonction avec en argument p0fichiers ou
pxfichiers

  for (i in 1:length(pxfichiers))
{
  donnees-read.table(pxfichiers[i], quote=\, sep=;, dec=,,
skip=0)
  jourheure-paste(donnees$V1, donnees$V2, sep= )
  donnees[1]-jourheure
  donnees-donnees[,-2]
#   assignTable(con, Datatable, donnees, append=TRUE) - Ne marche pas
  dbWriteTable(con, Datatable, donnees, append=TRUE)
  rm(donnees, jourheure)
}
}

tfichiers-rfichiers 
save(rfichiers, file=tfichiers.r, ascii=TRUE) 
rm(list=ls())  

# Deconnexion à MySQL

dbDisconnect(con)
-- 
View this message in context: 
http://www.nabble.com/Problem-with-save-or-and-if-%28I-think-but-maybe-not-...%29-tf4333945.html#a12343236
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] I again with shorter message and script

2007-08-27 Thread Ptit_Bleu

Hi,

I realized that my first message and the script were (maybe) too long and
difficult to read.
So I tested this shorter one :

- 

setwd(D:/RWork)
chemin-d:/Mydata/
relrfichiers-dir(chemin, pattern=.P)
rfichiers-paste(chemin,relrfichiers, sep='')

tfichiers-rfichiers
save(tfichiers, file=tfichiers.r, ascii=TRUE)

if (file.exists(tfichiers.r))
  {
tfichiers-load(tfichiers.r)
nfichiers-setdiff(rfichiers,tfichiers)
  }



The result is :
nfichiers is equal to rfichiers
and when I ask tfichiers, I obtain ... tfichiers :-(

I read the ?save and saw the warning about the arguments but I have no idea
how to solve this problem which must be a basic one (but do not forget that
I'm a newbye and that I'm french :-)

Thans again for your comments and help,
Ptit Bleu.

-- 
View this message in context: 
http://www.nabble.com/Problem-with-save-or-and-if-%28I-think-but-maybe-not-...%29-tf4333945.html#a12343633
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Problem with save or/and if (I think but maybe not ...)

2007-08-27 Thread Ptit_Bleu

Dear Prof Ripley,

I thank you for your fast answer.
In order to follow your advices :

I deleted all the objects and the tfichiers.r already created.
I changed all the tfichiers.t of the script into tfichiers.rda

Then I launched the script twice.
The first time, as tfichiers.rda didnt' exist, it created one.
During the script, I got this warning :
1: la condition a une longueur  1 et seul le premier élément est utilisé
in: if (nfichiers != 0)
(translate with my words : the condition has a length superior to 1 and only
the first element is used in ...)
Below, you will find the results.

The second launch gave the same results for nfichiers and rfichiers but for
tfichiers I obtained
tfichiers.

Have you some ideas to help me (because I really have none ...)
Again thank you,
Ptit Bleu.

--
FIRST LAUNCH

nfichiers
[1] d:/Mydata/31_07_07.P0   d:/Mydata/31_07_2007.P0
[3] d:/Mydata/31_07_2007.P1 d:/Mydata/31_07_2007.P2
[5] d:/Mydata/31_07_2007.P3

 nfichiers!=0
[1] TRUE TRUE TRUE TRUE TRUE

rfichiers
[1] d:/Mydata/31_07_07.P0   d:/Mydata/31_07_2007.P0
[3] d:/Mydata/31_07_2007.P1 d:/Mydata/31_07_2007.P2
[5] d:/Mydata/31_07_2007.P3

tfichiers
[1] d:/Mydata/31_07_07.P0   d:/Mydata/31_07_2007.P0
[3] d:/Mydata/31_07_2007.P1 d:/Mydata/31_07_2007.P2
[5] d:/Mydata/31_07_2007.P3
--

SECOND LAUNCH
with these changes in order not to change tfichiers.rda
#tfichiers-rfichiers
#save(tfichiers, file=tfichiers.rda)

nfichiers
[1] d:/Mydata/31_07_07.P0   d:/Mydata/31_07_2007.P0
[3] d:/Mydata/31_07_2007.P1 d:/Mydata/31_07_2007.P2
[5] d:/Mydata/31_07_2007.P3

 nfichiers!=0
[1] TRUE TRUE TRUE TRUE TRUE

rfichiers
[1] d:/Mydata/31_07_07.P0   d:/Mydata/31_07_2007.P0
[3] d:/Mydata/31_07_2007.P1 d:/Mydata/31_07_2007.P2
[5] d:/Mydata/31_07_2007.P3

tfichiers
tfichiers

 
-- 
View this message in context: 
http://www.nabble.com/Problem-with-save-or-and-if-%28I-think-but-maybe-not-...%29-tf4333945.html#a12344036
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Problem with save or/and if (I think but maybe not ...)

2007-08-27 Thread Ptit_Bleu

Dera Prof Ripley, 

You wrote :
What did you intend there?  It is not a test of no difference, but a test 
that each element of the difference is not 0, and furthermore if() 
expects a test of length one, not the length of nfichiers.  I suspect you 
intended to test length(nfichiers)  0.

And of course, you were right.
With the condition length(nfichiers)  0, there is no more warning.
And I tested manually length(nfichiers)0 for different cases and it gave
the result I expected.

But still I have a problem with the save and the retrieve of tfichiers.
I keep on looking at help file and testing manually alternative scripts ...

Hoping to read you again,
Ptit Bleu. 

   
-- 
View this message in context: 
http://www.nabble.com/Problem-with-save-or-and-if-%28I-think-but-maybe-not-...%29-tf4333945.html#a12344227
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] [SOLVED] save/load - I finally found (to be honnest : jholtman found)

2007-08-27 Thread Ptit_Bleu

The post of jholtman gave me the solution :
http://www.nabble.com/problems-saving-and-loading-%28PLMset%29-objects-tf4179541.html#a11885136

Like Quin Wills, I was trying to assign tfichiers.rda to tfichiers.
I've just write load(tfichiers.rda) instead of
tfichiers-(tfichiers.rda)
And now it works ... for this part (because if new files are only .P0, there
is a problem when the script try to read .P(not 0) file as there is none.
But this is not so difficult to solve even for me (I think, well, I hope).

Thanks to Prof Ripley and to all people helping people like me (maybe one
day I will also be able to help people).
Have a nice week,
Ptit Bleu.




-- 
View this message in context: 
http://www.nabble.com/Problem-with-save-or-and-if-%28I-think-but-maybe-not-...%29-tf4333945.html#a12345123
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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 write nicely a condition on a loop for (that is, not like I did)

2007-08-27 Thread Ptit_Bleu

Hi again,

This is the follow of my post Problem with save or/and if (I think but
maybe not ...).
In this post, I wrote that I solved my main problem. And it is true.
I also wrote that there was still another problem, which I managed to solve. 

But I think there must be another way to solve it taking advantages of the R
language (which I don't master at all), that is with less if tests.

To sum up :
nfichiers is a list of files (with .P0 or .Px (x0) extension) I have to
copy to a database.
nfichiers can also be 0 if there is no file to copy
p0fichiers is the list of files having the .P0 extension if there are such
files to copy
And p0fichiers can also be 0 if there are only .Px files to copy

So, before doing the for loop, I want to test if p0fichiers really
contains something.
Thanks for your comments and your advices to improve this script.
Ptit Bleu.

-

So here is my solution :

p0fichiers-0 #initialization of
p0fichiers
if (length(nfichiers)0)  # if nfichiers contains
file names
{
  if (length(grep(.P0, nfichiers))0) {p0fichiers-nfichiers[grep(.P0,
nfichiers)]}  #look if there is .P0
  if (p0fichiers[1]0)   # if .P0 has been updated
with the test above
{
for (i in 1:length(p0fichiers))  # do the loop for
{
 donnees-read.table(p0fichiers[i], quote=\, sep=;,
dec=,, skip=18)
 jourheure-paste(donnees$V1, donnees$V2, sep= )
 donnees[1]-jourheure
 donnees-donnees[,-2]
rm(donnees, jourheure)
}
}
}
-- 
View this message in context: 
http://www.nabble.com/how-to-write-nicely-a-condition-on-a-loop-%22for%22-%28that-is%2C-not-like-I-did%29-tf4335310.html#a12347016
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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.