[R] data frame is killing me! help

bbslover dluthm at yeah.net
Sat Oct 24 09:50:59 CEST 2009


I have try it, past can add to wanted letter, but can not past the colume
names. May be I should learn it hard.

Don MacQueen wrote:
> 
> At 4:57 AM -0700 10/23/09, bbslover wrote:
>>Steve Lianoglou-6 wrote:
>>>
>>>  Hi,
>>>
>>>  On Oct 22, 2009, at 2:35 PM, bbslover wrote:
>>>
>>>>  Usage
>>>>  data(gasoline)
>>>>  Format
>>>>  A data frame with 60 observations on the following 2 variables.
>>>>  octane
>>>>  a numeric vector. The octane number.
>>>>  NIR
>>>>  a matrix with 401 columns. The NIR spectrum
>>>>
>>>>  and I see the gasoline data to see below
>>>>  NIR.1686 nm NIR.1688 nm NIR.1690 nm NIR.1692 nm NIR.1694 nm NIR.1696 
>>>>  nm
>>>>  NIR.1698 nm NIR.1700 nm
>>>>  1 1.242645 1.250789 1.246626 1.250985 1.264189 1.244678 1.245913 
>>>>  1.221135
>>>>  2 1.189116 1.223242 1.253306 1.282889 1.215065 1.225211 1.227985 
>>>>  1.198851
>>>>  3 1.198287 1.237383 1.260979 1.276677 1.218871 1.223132 1.230321 
>>>>  1.208742
>>>>  4 1.201066 1.233299 1.262966 1.272709 1.211068 1.215044 1.232655 
>>>>  1.206696
>>>>  5 1.259616 1.273713 1.296524 1.299507 1.226448 1.230718 1.232864 
>>>>  1.202926
>>>>  6 1.24109 1.262138 1.288401 1.291118 1.229769 1.227615 1.22763 
>>>>  1.207576
>>>>  7 1.245143 1.265648 1.274731 1.292441 1.218317 1.218147 1.222273 
>>>>  1.200446
>>>>  8 1.222581 1.245782 1.26002 1.290305 1.221264 1.220265 1.227947 
>>>>  1.188174
>>>>  9 1.234969 1.251559 1.272416 1.287405 1.211995 1.213263 1.215883 
>>>>  1.196102
>>>>
>>>>  look at this NIR.1686 nm NIR.1688 nm NIR.1690 nm NIR.1692 nm NIR.
>>>>  1694 nm
>>>>  NIR.1696 nm NIR.1698 nm NIR.1700 nm
>>>>
>>>>  how can I add letters NIR to my variable, because my 600 
>>>>  independents never
>>>>  have NIR as the prefix. however, it is needed to model the plsr.   for
>>>>  example aa=plsr(y~NIR, data=data ,....), the prefix NIR is 
>>>>  necessary, how
>>  >> can I do with it?
> 
> Perhaps using paste(). Maybe something like:
> 
>     paste('NIR', 1:600,sep=''.)
> or
>     paste('NIR', seq(1686,1700,2),sep='.')
> 
>>  >
>>>  I'm not really sue that I'm getting you, but if your problem is that 
>>>  the column names of your data.frame don't match the variable names 
>>>  you'd like to use in your formula, just change the colnames of your 
>>>  data.frame to match your formula.
>>>
>>>  BTW - I have no idea where to get this gasoline data set, so I'm just 
>>>  imagining:
>>>
>>>  eg.
>>>  colnames(gasoline) <- c('put', 'the', 'variable', 'names', 'that', 
>>>  'you', 'want', 'here')
>>>
>>>  -steve
>>>
>>>  --
>>>  Steve Lianoglou
>>>  Graduate Student: Computational Systems Biology
>>>     |  Memorial Sloan-Kettering Cancer Center
>>>     |  Weill Medical College of Cornell University
>>>  Contact Info: http://*cbio.mskcc.org/~lianos/contact
>>>
>>>  ______________________________________________
>>>  R-help at r-project.org 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.
>>>
>>>
>>
>>thanks for you. but the numbers of indenpendence are so many, it is not
easy
>>to identify them one by one,  is there some better way?
>>
>>
>>--
>>View this message in context: 
>>http://*www.*nabble.com/data-frame-is-killing-me%21-help-tp26015079p26024985.html
>>Sent from the R help mailing list archive at Nabble.com.
>>
>>______________________________________________
>>R-help at r-project.org 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.
> 
> 
> -- 
> ---------------------------------
> Don MacQueen
> Lawrence Livermore National Laboratory
> Livermore, CA, USA
> 925-423-1062
> macq at llnl.gov
> 
> ______________________________________________
> R-help at r-project.org 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/data-frame-is-killing-me%21-help-tp26015079p26036875.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list