[R] strsplit

tom wright tom at maladmin.com
Tue Nov 15 13:47:03 CET 2005


Thanks everyone

Using the sqlQuery line
    wave<-sqlQuery(connection,s_sql,as.is=c(TRUE,TRUE,TRUE,TRUE,TRUE))

Then using strsplit(data,'\r') instead of split() seems to give what I
need



On Tue, 2005-15-11 at 17:29 +0000, Prof Brian Ripley wrote:
> On Tue, 15 Nov 2005, Peter Dalgaard wrote:
> 
> > tom wright <tom at maladmin.com> writes:
> >
> >> I'm stuck on what I feel should be a minor problem.
> >> I have a dataseries obtained from a MS Access database that consists of
> >> a series of numbers seperated by carridge returns (\r)
> >> Currently this data is in R as mode numeric???
> >>
> >> I want to separate this into a vector of the componant numbers.
> >> Perhaps a little code will help describe what I've got here!!
> >>
> >> library(rodbc)
> >> s_sql<-'SELECT Data from table where id=1' #only one record returned
> >> oWave<-sqlQuery(oConn,s_sql)
> >>
> >> wave.data<-oWave$data
> >>
> >>> mode(data)
> >> [1] "numeric"
> >>
> >> Any clues will be much appreciated
> >
> > Er, did you mean to say mode(wave.data)?
> >
> > Anyways, you say that you want to obtain a vector of numbers, and you
> > got an object of mode numeric, which means that it is a vector of
> > numbers. So what was the problem in the first place?
> >
> > If you had data with carriage returns inside, then you should have
> > them as mode "character".
> >
> > So there seems to be something that you're not telling us...
> 
> or Access is not telling R.  One possibility is that Access is reporting 
> this field as numeric:  use sqlColumns() to find out.  If so, you need to 
> sort this out in Access.  If not, you can use the as.is argument: see 
> ?sqlGetResults referenced from ?sqlQuery (although I would be surprised if 
> type.convert was getting confused).
>




More information about the R-help mailing list