[R] Odp: Calling Data frame objects with spaces in their names

Petr PIKAL petr.pikal at precheza.cz
Wed Feb 24 16:14:36 CET 2010


Hi

I do not see any problem?

> zeta
    vzorek a b c skupina  sio2  p2o5 al2o3 dus   de reten1 reten2
1  179/1/1  7.51    7.34 0.023 0.780 5.812  ne 1.53     NA     NA
2  179/2/1  7.79    7.34 0.011 0.784 5.819  ne 0.89     NA     NA


> zeta[ ,2]
 [1] 7.51 7.79 5.14 6.35 5.82 7.13 5.95 7.27 6.29 7.50 7.30 7.27 6.46 6.95 
6.32
[16] 6.32 6.34

> zeta[,"a b c"]
 [1] 7.51 7.79 5.14 6.35 5.82 7.13 5.95 7.27 6.29 7.50 7.30 7.27 6.46 6.95 
6.32
[16] 6.32 6.34

> zeta$a b c
Error: unexpected symbol in "zeta$a b"

> zeta$"a b c"
 [1] 7.51 7.79 5.14 6.35 5.82 7.13 5.95 7.27 6.29 7.50 7.30 7.27 6.46 6.95 
6.32
[16] 6.32 6.34

Regards
Petr

Maybe you could try to rename your columns. Try to look at 

?abbreviate


r-help-bounces at r-project.org napsal dne 24.02.2010 15:36:01:

> Hello I have the following data frame which I read from an EXCEL file, 
and
> when i try to call one of its columns with a space in their names I am 
not
> being able to. For example if I do EURODOLLAR$ED1.Comdty Date I obtain 
the
> following error:
> Error: inesperado símbolo en "EURODOLLAR$ED1.Comdty Date"
> 
> I have also tried using . or _ instead of the space and have obtained no
> succes. How do I call such an object? Thank You
> 
> Felipe Parra
> 
>  head(EURODOLLAR)
>   ED1.Comdty Date ED1.Comdty ED2.Comdty Date ED2.Comdty ED3.Comdty Date
> ED3.Comdty ED4.Comdty Date ED4.Comdty ED5.Comdty Date ED5.Comdty 
ED6.Comdty
> Date
> 1            Date    PX_LAST            Date    PX_LAST            Date
> PX_LAST            Date    PX_LAST            Date    PX_LAST
> Date
> 2      02/01/2003     98.635      02/01/2003      98.51      02/01/2003
> 98.295      02/01/2003     97.995      02/01/2003      97.64 02/01/2003
> 3      03/01/2003     98.635      03/01/2003     98.525      03/01/2003
> 98.305      03/01/2003         98      03/01/2003      97.64 03/01/2003
> 4      06/01/2003      98.63      06/01/2003     98.515      06/01/2003
> 98.265      06/01/2003      97.95      06/01/2003      97.59 06/01/2003
> 5      07/01/2003     98.635      07/01/2003     98.565      07/01/2003
> 98.35      07/01/2003     98.045      07/01/2003     97.695 07/01/2003
> 6      08/01/2003      98.65      08/01/2003       98.6      08/01/2003
> 98.415      08/01/2003      98.13      08/01/2003      97.77 08/01/2003
>   ED6.Comdty ED7.Comdty Date ED7.Comdty ED8.Comdty Date ED8.Comdty
> ED9.Comdty Date ED9.Comdty ED10.Comdty Date ED10.Comdty
> 1    PX_LAST            Date    PX_LAST            Date
> PX_LAST            Date    PX_LAST             Date     PX_LAST
> 2      97.25      02/01/2003       96.9      02/01/2003      96.61
> 02/01/2003      96.38       02/01/2003      96.155
> 3      97.24      03/01/2003     96.885      03/01/2003     96.585
> 03/01/2003     96.355       03/01/2003      96.135
> 4     97.205      06/01/2003     96.845      06/01/2003      96.55
> 06/01/2003     96.315       06/01/2003      96.095
> 5      97.31      07/01/2003      96.97      07/01/2003     96.675
> 07/01/2003     96.425       07/01/2003        96.2
> 6     97.385      08/01/2003     97.015      08/01/2003     96.715
> 08/01/2003      96.46       08/01/2003       96.23
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list