Luis Felipe Parra
2010-Feb-24 14:36 UTC
[R] Calling Data frame objects with spaces in their names
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]]
Petr PIKAL
2010-Feb-24 15:14 UTC
[R] Odp: Calling Data frame objects with spaces in their names
Hi I do not see any problem?> zetavzorek 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 cError: 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 amnot> being able to. For example if I do EURODOLLAR$ED1.Comdty Date I obtainthe> 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.ComdtyED6.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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Patrick Connolly
2010-Feb-24 19:07 UTC
[R] Calling Data frame objects with spaces in their names
On Wed, 24-Feb-2010 at 09:36AM -0500, Luis Felipe Parra wrote: |> 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" try EURODOLLAR$`ED1.Comdty Date` HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.