Re: [R] Package RODBC

2007-03-07 Thread Wolfgang Raffelsberger
Dear Alberto,

please note that special characters (eg a space character) in the Excel 
sheet names mess up the simple way of querying provided by sqlFetch.

If you have a regular case of all sheets like Sheet1:

plan1 - sqlFetch(channel,Sheet1)   # should work


But if you have Sheet 1 ( similar..)  you have to use the command 
sqlQuery(), which means that you have to write a proper SQL query as 2nd 
argument that follows proper SQL syntax (starting with SELECT, 
etc...). If I wanted to combine this with sheet-names already read in 
variables/vectors I concatenate this into a single stringsimilar to your 
2nd code variant ... Of course you could also use grep() to search the 
position of a given sheet-name (the order of the sheets may be different 
that within Excel).

What you get with

plan1[,1]

depends on what you're reading.  In case that the 1st column is read as 
string, this is read by default as factor with n levels.  You can simply 
convert it using as.character() ...

Hope this helps,
Wolfgang

Mendiburu, Felipe (CIP) a écrit :
 Dear Alberto,

 channel - odbcConnectExcel(test.xls)
 name1 - tables[1, TABLE_NAME] # the name1 is Sheet1$
 it must be: 
 name1 - Sheet1
 plan1 - sqlFetch(channel, name1) is ok
 or
 plan1 - sqlFetch(channel, Sheet1)

 Regards,

 Felipe

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Alberto Monteiro
 Sent: Tuesday, March 06, 2007 9:37 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Package RODBC


 I have some questions about the RODBC package.

   library(RODBC)  # required for those who want to repeat these lines

 1st, I noticed that the following sequence does not work:

   channel - odbcConnextExcel(test.xls)
   tables - sqlTables(channel) 
   name1 - tables[1, TABLE_NAME]  # this should be the name
   plan1 - sqlFetch(channel, name1)  # bang!
   odbcClose(channel)

 However, I can circumvent this with:

   channel - odbcConnextExcel(test.xls)
   tables - sqlTables(channel) 
   name1 - tables[1, TABLE_NAME]  # this should be the name
   plan1 - sqlQuery(channel, sprintf(select * from [%s], name1))  # ok
   odbcClose(channel)

 2nd, it seems that only pure strings (which are not links to
 strings) and numerical values are correctly fetched or selected.
 Is this a bug?

 3rd, when do something like plan1[,1] a weird message about Levels
 appear. What is that?

 Alberto Monteiro


   


-- 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégrative
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
[EMAIL PROTECTED]

__
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] path for source()

2007-02-08 Thread Wolfgang Raffelsberger
Hi,
an easy way to address this is to change directory within R before 
calling source() :
setwd(D:/Projects/yourProject)
source(yourCode.R)

Of course you need to know where your .R files are.
Using getwd() you can always check where you are and using dir() you can 
check the files in your directory (which you could combine with grep() 
to search for .R) ..

Wolfgang

[EMAIL PROTECTED] a écrit :
 hello,

 i have a couple of .R files distributed about my file system. i commonly 
 source() these from other files, but i have to include the full file path. 
 this is not always convenient if you move files around. is there a way of 
 setting the search path for source()?

 thanks a lot!

 cheers,
 andrew.

   


-- 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégrative
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
[EMAIL PROTECTED]

__
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 compilation of R on Solaris 10 in x86

2007-01-31 Thread Wolfgang Raffelsberger
Dear List,
we're trying to install R on Solaris10 on a x86 (amd64).

During the installation we pass successfully the ./configure but we get 
an error through the built-in function _isnan which we see existing in 
/lib

When passing the command make we get :

gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 
-I../../src/extra/pcre   -I. -I../../src/include -I../../src/include 
-I/usr/local/include -DHAVE_CONFIG_H -D__NO_MATH_INLINES  -g -O2 -c 
serialize.c -o serialize.o
In file included from ../../src/include/Rinternals.h:921,
 from ../../src/include/Defn.h:72,
 from serialize.c:29:
../../src/include/Rinlinedfuns.h: In function `fmin2_int':
../../src/include/Rinlinedfuns.h:602: warning: implicit declaration of 
function `__builtin_isnan'

[... and ...]
gcc -std=gnu99  -L/usr/local/lib -o R.bin Rmain.o CConverters.o 
CommandLineArgs.o  Rdynload.o Renviron.o RNG.o  apply.o arithmetic.o 
apse.o array.o attrib.o  base.o bind.o builtin.o  character.o coerce.o 
colors.o complex.o connections.o context.o  cov.o cum.o  dcf.o 
datetime.o debug.o deparse.o deriv.o  dotcode.o dounzip.o dstruct.o 
duplicate.o  engine.o envir.o errors.o eval.o  format.o fourier.o  
gevents.o gram.o gram-ex.o graphics.o  identical.o internet.o 
iosupport.o  lapack.o list.o localecharset.o logic.o  main.o mapply.o 
match.o memory.o model.o  names.o  objects.o optim.o optimize.o 
options.o  par.o paste.o pcre.o platform.o  plot.o plot3d.o plotmath.o  
print.o printarray.o printvector.o printutils.o qsort.o  random.o 
regex.o registration.o relop.o rlocale.o  saveload.o scan.o seq.o 
serialize.o size.o sort.o source.o split.o  sprintf.o startup.o 
subassign.o subscript.o subset.o summary.o sysutils.o  unique.o util.o  
version.o vfonts.o xxxpr.o  mkdtemp.o ../unix/libun!
ix.a ../appl/libappl.a ../nmath/libnmath.a -L../../lib -lRblas 
-L/opt/sfw/lib/gcc/i386-pc-solaris2.10/3.4.2 -L/usr/ccs/bin 
-L/opt/sfw/lib -lg2c -lm -lgcc_s  ../extra/zlib/libz.a  
../extra/bzip2/libbz2.a ../extra/pcre/libpcre.a  
../extra/intl/libintl.a  -lreadline -lncurses -lnsl -lsocket -ldl -lm
Undefined   first referenced
 symbol in file
__builtin_isnan arithmetic.o
ld: fatal: Symbol referencing errors. No output written to R.bin
collect2: ld returned 1 exit status


Thank's in advance for all hints how we could overcome this problem,
Wolfgang

 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégrative
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3300 Fax (+33) 388 65 3276
http://www-bio3d-igbmc.u-strasbg.fr/~wraff
[EMAIL PROTECTED]

__
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] RODBC : first line of data from query omitted

2007-01-03 Thread Wolfgang Raffelsberger
Dear List,

when reading MS Excel files in R using package RODBC I encountered the 
problem of having the first line of data getting omitted.

I read the data as :
  library(RODBC)
  channel1 - odbcConnectExcel(myFile.xls)
  sheet1 - sqlQuery(channel1, SELECT * FROM [Cell measures (1)$]) 
 # I use sqlQuery() instead of sqlFetch() since the sheet I want to 
extract is called : Cell measures (1)

The first line of data is missing in the resulting object (sheet1) in 
the case where the corresponding sheet contains a list of data without a 
line serving as header.  And the original first line appears as 
column-name (in the case of strings while any numeric content is 
transformed to incrementing column-names).
The 2nd line from my input appears then as 1st line of data in the 
resulting R-object and, no surprise, the total number of lines is 1 too few.

   sheet1[1:3,1:5]
  D - 5(fld 10)  F2  F3F4  F5
1 D - 5(fld 11) 162 182.110 0.042 184.695
2 D - 5(fld 12) 163 198.154 0.086 201.932
3 D - 5(fld 13) 164 182.403 0.034 182.816

However, the 1st line in the original reads as :
  D - 5(fld 10) 161 182.929 0.045 188.819

Do you have an idea how to formulate the query that I can read the 1st 
line of data ?
Is there some argument like the col.names=FALSE in read.table() ?
Or is there a way to add an additional line unsing the SQL coomand 
INSERT (so that the real data would start in line 2) ?

  sessionInfo()
R version 2.4.0 (2006-10-03)
i386-pc-mingw32

locale:
LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252

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

other attached packages:
   RODBC svIO   R2HTML   svMisc svSocketsvIDE
 1.1-7  0.9-5   1.58  0.9-5  0.9-5  0.9-5


Thank's in advance,
Wolfgang

 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3314 Fax (+33) 388 65 3276
[EMAIL PROTECTED]

__
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] accessing arrays

2007-01-03 Thread Wolfgang Raffelsberger
try this :
x - 
array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26]))

Cheers,
Wolfgang

downunder03 a écrit :
 hi all. how can i adress a array directly. for example i wanna give array 1
 other labels than array 2. How can I overcome this problem?

 ...this doesn't work

 tab - array(1:8, c(2, 2, 2))
 dimnames(tab[,,1]) - list(c(No,Yes), c(No,Yes),c(ARRAY1))
 dimnames(tab[,,2]) - list(c(big,small), c(small,big),c(ARRAY2))



   


 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3314 Fax (+33) 388 65 3276
[EMAIL PROTECTED]

__
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] accessing arrays

2007-01-03 Thread Wolfgang Raffelsberger
Hi Lars,

in a 3-dim array you have 3 axes, day x, y and z (which I named 
xNo/xYes, yNo/yYes and zSmall/zBig)
to assign directly the labels use :

  tab - array(1:8, c(2, 2, 2),dimnames= list(c(xNo,xYes), 
c(yNo,yYes),c(zBig,zSmall)))
  tab
, , zBig

 yNo yYes
xNo13
xYes   24

, , zSmall

 yNo yYes
xNo57
xYes   68

If you wanted to have an array allowing to capture xNo/xYes vs yNo/yYes 
AND zBig,zSmall vs aaBig,aaSmall you need to go one dimension 
higher .. but I'm not sure if this is really what you wanted.

Hope this helps,
Wolfgang

Lars Rohrschneider a écrit :
 Hi Wolfgang,
 thanks for your hint. But I am desperating. I have an 3 dim array of say 
 10matrices where every matrix has to stick an other label. I found no way 
 todirect assign the labels.
 for example 
 tab - array(1:8, c(2, 2, 2))dimnames(tab[,,1]) - list(c(No,Yes), 
 c(No,Yes))dimnames(tab[,,2]) - list(c(big,small), c(small,big))
 should look like this, , 1
 No YesNo   1   3Yes  2   4
 , , 2
 big  smallsmall   5   7big 6   8






 Wolfgang Raffelsberger wrote:  try this : x -  
 array(1:24,dim=c(2,3,4),dimnames=list(letters[1:2],LETTERS[1:3],letters[23:26]))
   Cheers, Wolfgang  downunder03 a écrit : hi all. how can i adress a 
 array directly. for example i wanna give array 1 other labels than array 
 2. How can I overcome this problem? ...this doesn't work tab - 
 array(1:8, c(2, 2, 2)) dimnames(tab[,,1]) - list(c(No,Yes), 
 c(No,Yes),c(ARRAY1)) dimnames(tab[,,2]) - list(c(big,small), 
 c(small,big),c(ARRAY2)) . . . . . . . . . . . . . 
 . . . . . . . . . . . . . . . . . . . . . . .  . . . . .  Wolfgang 
 Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives 
 IGBMC 1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France Tel (+33) 
 388 65 3314 Fax (+33) 388 65 3276 [EMAIL PROTECTED]  
 __ 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/-R--accessing-arrays-tf2913929.html#a8144807Sent from 
 the R help mailing list archive at Nabble.com.
 [EMAIL PROTECTED] mailing 
 listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting 
 guide http://www.R-project.org/posting-guide.htmland provide commented, 
 minimal, self-contained, reproducible code.



   


-- 

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
. . . . .

Wolfgang Raffelsberger, PhD
Laboratoire de BioInformatique et Génomique Intégratives
IGBMC
1 rue Laurent Fries,  67404 Illkirch  Strasbourg,  France
Tel (+33) 388 65 3314 Fax (+33) 388 65 3276
http://www-bio3d-igbmc.u-strasbg.fr/~wraff
[EMAIL PROTECTED]

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