[R] strsplit
tom wright
tom at maladmin.com
Tue Nov 15 13:21:50 CET 2005
Peter, Your correct I did mean to say
mode(wave.data)
but mode is still numeric???
I've made some changes so I can show you a trucated value for the data,
please see the following code...
getWave<-function(connection,id=NULL){
if(is.null(id)){
stop('Must supply record#')
}
s_sql1<-'SELECT
Samplerate,Sampleswave,Prestimbaseline,Numberaveraged,LEFT(Data,100) as
wavedata'
s_sql2<-'FROM [Patient Information]'
s_sql3<-paste('WHERE [Record#]=',id,sep='')
s_sql<-paste(s_sql1,s_sql2,s_sql3)
wave<-sqlQuery(connection,s_sql)
return(wave)
}
> owave<-getWave(oConn,89)
> owave$wavedata
[1] 161.1328\r158.6914\r162.3535\r159.9121\r158.6914\r159.9121\r153.8086
\r151.3672\r146.4844\r142.8223\r140.3809\r1
Levels: 161.1328\r158.6914\r162.3535\r159.9121\r158.6914\r159.9121
\r153.8086\r151.3672\r146.4844\r142.8223\r140.3809\r1
> mode(owave$wavedata)
[1] "numeric"
On Tue, 2005-15-11 at 18:03 +0100, 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...
>
More information about the R-help
mailing list