[R] r: RODBC QUESTION

From: Clark Allan <Allan_at_stats.uct.ac.za>
Date: Sat 31 Dec 2005 - 21:08:58 EST


hello all

i have a quick question. i have been using the RODBC library (trying to read Excel data
 into R but i am doing this by using Rexcel. this is probably not the correct forum -
sorry for this).

my code is shown below:

Sub A()

    'start the connection to R
    Call RInterface.StartRServer     

    RInterface.RRun "library(RODBC)"
    RInterface.RRun "A = odbcConnectExcel('c:/TRY.xls')"     

    RInterface.RRun "q1 = sqlFetch(A, 'Sheet1')"     

    RInterface.RRun "odbcClose (A)"

    Worksheets("out").Activate     

    Call RInterface.GetArray("q1", Range("A1"))     

    Call RInterface.StopRServer

End Sub

i have included four examples below. on the left hand side we have the data as it appears
 in Excel and on the right hand side we have the output from the code (outputted to the
 'out' sheet in excel). in the first example the code works while in the other three
exampl0es it does not. ('a' is some character) when i use the commands in r directly everything works correctly (ie missing values are treated as NA - <characters is treated similarly>)

can anyone show me how to solve this!

ANOTHER QUESTION: am i allowed to have numeric and character values in the same column when importing from Excel to R? (seems like i cant)

thanking you in advance!

wishing you all a happy new year (in advance) /
allan

Y	X1	X2		1	6	3
1	6	3		2	6	2
2	6	2		3	5	2
3	5	2				


Y	X1	X2		0		
1	6	3				
2	6	2				
3	a	2				


Y	X1	X2		0		
1	6	3
2	6	2
3	a	2


Y	X1	X2		0
1		3		
2	6	2		
3	5	2

______________________________________________

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 Received on Sat Dec 31 21:21:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:44 EST