[R] read.csv and blank character in object name of my data.frame
arnaud Gaboury
arnaud.gaboury at gmail.com
Fri Apr 30 09:39:47 CEST 2010
Dear group,
Here is my data frame:
position100415 <-
structure(list(DESCRIPTION = structure(1:9, .Label = c(" SUGAR NO.11 Jul/10
",
" SUGAR NO.11 May/10 ", "CORN May/10 ", "COTTON NO.2 Jul/10 ",
"CRUDE OIL miNY May/10 ", "ROBUSTA COFFEE (10) Jul/10 ", "SILVER May/10 ",
"SOYBEANS Jul/10 ", "WHEAT May/10 "), class = "factor"), POSITION = c(3,
-1, 3, 4, 3, 10, 1, 1, 6), SETTLEMENT = c(17.08, 16.85, 363.25,
82.12, 85.51, 1386, 1843.3, 993, 480.25)), .Names = c("DESCRIPTION",
"POSITION", "SETTLEMENT"), row.names = c(NA, 9L), class = "data.frame")
As you can see, I have a blank at the end of each name of objects of list
DESCRIPTION (e.g "COTTON NO.2 Jul/10_",. I need to remove them.
My data frame has been obtained from a .csv file and then a few command
lines.
Here is the first line of my code :
pose=read.csv2("LSCPos100415.csv",sep=",",dec=".",as.is=T,h=T,skip=1)[,c(4,8
,14,15)]
As you can see, the blank already exists (e.g "CORN May/10_"), so it should
come from the Excel file itself.
pose <-
structure(list(DESCRIPTION = c("CORN May/10 ", "CORN May/10 ",
"SOYBEANS Jul/10 ", "WHEAT May/10 ", "WHEAT May/10 ", "WHEAT May/10 ",
"WHEAT May/10 ", "WHEAT May/10 ", "WHEAT May/10 ", "COTTON NO.2 Jul/10 ",
"COTTON NO.2 Jul/10 ", " SUGAR NO.11 Jul/10 ", " SUGAR NO.11 Jul/10 ",
" SUGAR NO.11 Jul/10 ", " SUGAR NO.11 May/10 ", "CRUDE OIL miNY May/10 ",
"CRUDE OIL miNY May/10 ", "ROBUSTA COFFEE (10) Jul/10 ", "ROBUSTA COFFEE
(10) Jul/10 ",
"ROBUSTA COFFEE (10) Jul/10 ", "ROBUSTA COFFEE (10) Jul/10 ",
"ROBUSTA COFFEE (10) Jul/10 ", "ROBUSTA COFFEE (10) Jul/10 ",
"ROBUSTA COFFEE (10) Jul/10 ", "ROBUSTA COFFEE (10) Jul/10 ",
"ROBUSTA COFFEE (10) Jul/10 ", "SILVER May/10 ", "PRM HGH GD ALUMINIUM USD
09/07/10 ",
"PRM HGH GD ALUMINIUM USD 09/07/10 ", "PRIMARY NICKEL USD 04/06/10 ",
"PRIMARY NICKEL USD 04/06/10 ", "PRIMARY NICKEL USD 10/06/10 ",
"PRIMARY NICKEL USD 10/06/10 ", "STANDARD LEAD USD 01/07/10 ",
"STANDARD LEAD USD 01/07/10 ", "STANDARD LEAD USD 01/07/10 ",
"STANDARD LEAD USD 01/07/10 ", "STANDARD LEAD USD 01/07/10 ",
"STANDARD LEAD USD 01/07/10 ", "STANDARD LEAD USD 01/07/10 ",
"STANDARD LEAD USD 06/07/10 ", "STANDARD LEAD USD 19/04/10 ",
"STANDARD LEAD USD 19/04/10 ", "STANDARD LEAD USD 22/06/10 ",
"STANDARD LEAD USD 23/06/10 ", "STANDARD LEAD USD 23/06/10 ",
"STANDARD LEAD USD 23/06/10 ", "STANDARD LEAD USD 25/06/10 ",
"STANDARD LEAD USD 25/06/10 ", "STANDARD LEAD USD 29/06/10 ",
"STANDARD LEAD USD 29/06/10 ", "SPCL HIGH GRADE ZINC USD 06/07/10 ",
"SPCL HIGH GRADE ZINC USD 06/07/10 ", "SPCL HIGH GRADE ZINC USD 06/07/10 ",
"SPCL HIGH GRADE ZINC USD 06/07/10 ", "SPCL HIGH GRADE ZINC USD 06/07/10 ",
"SPCL HIGH GRADE ZINC USD 06/07/10 ", "SPCL HIGH GRADE ZINC USD 06/07/10 ",
"SPCL HIGH GRADE ZINC USD 07/07/10 ", "SPCL HIGH GRADE ZINC USD 07/07/10 ",
"SPCL HIGH GRADE ZINC USD 07/07/10 ", "SPCL HIGH GRADE ZINC USD 08/07/10 ",
"SPCL HIGH GRADE ZINC USD 08/07/10 ", "SPCL HIGH GRADE ZINC USD 08/07/10 ",
"SPCL HIGH GRADE ZINC USD 09/07/10 ", "SPCL HIGH GRADE ZINC USD 09/07/10 ",
"SPCL HIGH GRADE ZINC USD 09/07/10 ", "SPCL HIGH GRADE ZINC USD 09/07/10 ",
"SPCL HIGH GRADE ZINC USD 09/07/10 ", "SPCL HIGH GRADE ZINC USD 13/07/10 ",
"SPCL HIGH GRADE ZINC USD 13/07/10 ", "SPCL HIGH GRADE ZINC USD 14/07/10 ",
"SPCL HIGH GRADE ZINC USD 14/07/10 ", "SPCL HIGH GRADE ZINC USD 14/07/10 ",
"SPCL HIGH GRADE ZINC USD 14/07/10 ", "SPCL HIGH GRADE ZINC USD 15/07/10 ",
"SPCL HIGH GRADE ZINC USD 15/07/10 ", "SPCL HIGH GRADE ZINC USD 15/07/10 ",
"SPCL HIGH GRADE ZINC USD 15/07/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 17/05/10 ", "SPCL HIGH GRADE ZINC USD 17/05/10 ",
"SPCL HIGH GRADE ZINC USD 18/05/10 ", "SPCL HIGH GRADE ZINC USD 18/05/10 ",
"SPCL HIGH GRADE ZINC USD 18/05/10 ", "SPCL HIGH GRADE ZINC USD 18/05/10 ",
"SPCL HIGH GRADE ZINC USD 18/05/10 ", "SPCL HIGH GRADE ZINC USD 19/04/10 ",
"SPCL HIGH GRADE ZINC USD 19/04/10 ", "SPCL HIGH GRADE ZINC USD 19/04/10 ",
"SPCL HIGH GRADE ZINC USD 19/04/10 ", "SPCL HIGH GRADE ZINC USD 19/05/10 ",
"SPCL HIGH GRADE ZINC USD 20/04/10 ", "SPCL HIGH GRADE ZINC USD 20/04/10 ",
"SPCL HIGH GRADE ZINC USD 21/04/10 ", "SPCL HIGH GRADE ZINC USD 21/04/10 ",
"SPCL HIGH GRADE ZINC USD 21/05/10 ", "SPCL HIGH GRADE ZINC USD 21/05/10 ",
"SPCL HIGH GRADE ZINC USD 21/05/10 ", "SPCL HIGH GRADE ZINC USD 21/05/10 ",
"SPCL HIGH GRADE ZINC USD 21/05/10 ", "SPCL HIGH GRADE ZINC USD 21/05/10 ",
"SPCL HIGH GRADE ZINC USD 21/05/10 ", "SPCL HIGH GRADE ZINC USD 22/04/10 ",
"SPCL HIGH GRADE ZINC USD 22/04/10 ", "SPCL HIGH GRADE ZINC USD 22/04/10 ",
"SPCL HIGH GRADE ZINC USD 22/04/10 ", "SPCL HIGH GRADE ZINC USD 22/06/10 ",
"SPCL HIGH GRADE ZINC USD 22/06/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/05/10 ", "SPCL HIGH GRADE ZINC USD 24/05/10 ",
"SPCL HIGH GRADE ZINC USD 24/06/10 ", "SPCL HIGH GRADE ZINC USD 24/06/10 ",
"SPCL HIGH GRADE ZINC USD 25/05/10 ", "SPCL HIGH GRADE ZINC USD 25/05/10 ",
"SPCL HIGH GRADE ZINC USD 25/05/10 ", "SPCL HIGH GRADE ZINC USD 25/06/10 ",
"SPCL HIGH GRADE ZINC USD 25/06/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 ",
"SPCL HIGH GRADE ZINC USD 26/04/10 ", "SPCL HIGH GRADE ZINC USD 26/04/10 "
), CREATED.DATE = c("14/04/2010", "14/04/2010", "14/04/2010",
"08/04/2010", "08/04/2010", "12/04/2010", "14/04/2010", "14/04/2010",
"14/04/2010", "15/04/2010", "15/04/2010", "15/04/2010", "15/04/2010",
"15/04/2010", "15/04/2010", "12/04/2010", "15/04/2010", "15/04/2010",
"15/04/2010", "15/04/2010", "15/04/2010", "15/04/2010", "15/04/2010",
"15/04/2010", "15/04/2010", "15/04/2010", "15/04/2010", "09/04/2010",
"09/04/2010", "04/03/2010", "05/03/2010", "10/03/2010", "10/03/2010",
"01/04/2010", "01/04/2010", "01/04/2010", "01/04/2010", "01/04/2010",
"01/04/2010", "01/04/2010", "06/04/2010", "18/01/2010", "25/01/2010",
"22/03/2010", "23/03/2010", "23/03/2010", "23/03/2010", "25/03/2010",
"26/03/2010", "29/03/2010", "29/03/2010", "06/04/2010", "06/04/2010",
"06/04/2010", "06/04/2010", "06/04/2010", "06/04/2010", "06/04/2010",
"07/04/2010", "07/04/2010", "07/04/2010", "08/04/2010", "08/04/2010",
"08/04/2010", "09/04/2010", "09/04/2010", "09/04/2010", "09/04/2010",
"09/04/2010", "13/04/2010", "13/04/2010", "14/04/2010", "14/04/2010",
"14/04/2010", "14/04/2010", "15/04/2010", "15/04/2010", "15/04/2010",
"15/04/2010", "16/02/2010", "16/02/2010", "16/02/2010", "16/02/2010",
"16/02/2010", "16/02/2010", "16/02/2010", "17/02/2010", "17/02/2010",
"17/02/2010", "17/02/2010", "17/02/2010", "17/02/2010", "17/02/2010",
"17/02/2010", "18/02/2010", "18/02/2010", "18/02/2010", "18/02/2010",
"18/02/2010", "18/01/2010", "18/01/2010", "18/01/2010", "25/01/2010",
"19/02/2010", "20/01/2010", "20/01/2010", "21/01/2010", "21/01/2010",
"22/02/2010", "22/02/2010", "22/02/2010", "22/02/2010", "22/02/2010",
"22/02/2010", "22/02/2010", "22/01/2010", "22/01/2010", "25/01/2010",
"25/01/2010", "22/03/2010", "22/03/2010", "23/02/2010", "23/02/2010",
"23/02/2010", "23/02/2010", "23/02/2010", "23/02/2010", "23/02/2010",
"24/02/2010", "24/02/2010", "24/02/2010", "24/02/2010", "24/02/2010",
"24/02/2010", "24/02/2010", "24/02/2010", "24/02/2010", "24/02/2010",
"24/02/2010", "24/02/2010", "24/03/2010", "24/03/2010", "25/02/2010",
"25/02/2010", "25/02/2010", "25/03/2010", "26/03/2010", "25/01/2010",
"25/01/2010", "25/01/2010", "25/01/2010", "25/01/2010", "25/01/2010",
"26/01/2010", "26/01/2010", "26/01/2010", "26/01/2010", "26/01/2010",
"26/01/2010", "26/01/2010"), QUANITY = c(1, 2, 1, 1, 1, 1, 1,
1, 1, 2, 2, 1, 1, 1, -1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
-1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1,
-1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1,
-1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, -1, -2, 2,
-2, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 2, -1, -1, -1, -1,
-1, -1, 1, 1, 2, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1,
-1, -1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1,
-1, -1, 1, 1, 1, 1, -1, 1, -1, 2, -1, 1, 1, 2, -1, -1, -1, -1,
2, -2, -1, 1, 2, -1, 2, -1), CLOSING.PRICE = c("363.2500", "363.2500",
"993.0000", "480.2500", "480.2500", "480.2500", "480.2500", "480.2500",
"480.2500", "82.1200", "82.1200", "17.0800", "17.0800", "17.0800",
"16.8500", "85.5100", "85.5100", "1,386.0000", "1,386.0000",
"1,386.0000", "1,386.0000", "1,386.0000", "1,386.0000", "1,386.0000",
"1,386.0000", "1,386.0000", "1,843.3000", "2,469.9300", "2,469.9300",
"27,196.8600", "27,196.8600", "27,201.6800", "27,201.6800", "2,337.1000",
"2,337.1000", "2,337.1000", "2,337.1000", "2,337.1000", "2,337.1000",
"2,337.1000", "2,338.1400", "2,315.7500", "2,315.7500", "2,335.2400",
"2,335.4500", "2,335.4500", "2,335.4500", "2,335.8600", "2,335.8600",
"2,336.6900", "2,336.6900", "2,505.9700", "2,505.9700", "2,505.9700",
"2,505.9700", "2,505.9700", "2,505.9700", "2,505.9700", "2,506.3100",
"2,506.3100", "2,506.3100", "2,506.6500", "2,506.6500", "2,506.6500",
"2,506.9800", "2,506.9800", "2,506.9800", "2,506.9800", "2,506.9800",
"2,508.3300", "2,508.3300", "2,508.6600", "2,508.6600", "2,508.6600",
"2,508.6600", "2,509.0000", "2,509.0000", "2,509.0000", "2,509.0000",
"2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600",
"2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600",
"2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600", "2,487.9600",
"2,488.3600", "2,488.3600", "2,488.3600", "2,488.3600", "2,488.3600",
"2,476.7500", "2,476.7500", "2,476.7500", "2,476.7500", "2,488.7500",
"2,477.2500", "2,477.2500", "2,477.7500", "2,477.7500", "2,489.4400",
"2,489.4400", "2,489.4400", "2,489.4400", "2,489.4400", "2,489.4400",
"2,489.4400", "2,478.1400", "2,478.1400", "2,478.1400", "2,478.1400",
"2,501.2700", "2,501.2700", "2,490.4700", "2,490.4700", "2,490.4700",
"2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700",
"2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700",
"2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700", "2,490.4700",
"2,490.4700", "2,501.9400", "2,501.9400", "2,490.8100", "2,490.8100",
"2,490.8100", "2,502.2800", "2,502.2800", "2,479.7100", "2,479.7100",
"2,479.7100", "2,479.7100", "2,479.7100", "2,479.7100", "2,479.7100",
"2,479.7100", "2,479.7100", "2,479.7100", "2,479.7100", "2,479.7100",
"2,479.7100")), .Names = c("DESCRIPTION", "CREATED.DATE", "QUANITY",
"CLOSING.PRICE"), class = "data.frame", row.names = c(NA, -160L
))
As I can't change anything on the Excel side, how can I remove these blanks
on the R side??
TY for help.
More information about the R-help
mailing list