[R] Basic structure operations doubt
Santosh Srinivas
santosh.srinivas at gmail.com
Mon Oct 18 04:06:32 CEST 2010
I'm doing these manipulations on the data frame and wondering why does R
have to remember historical data on my operation and not just keep the
needed info.
Probably a basic fundamentals of the way R handles data .. Pls point me to
the manual if possible ..
I have this Index data:
> head(NIFTY_INDX)
Constituents.list.of.S.P.CNX.Nifty X X.1
X.2 X.3
1
2 Company Name Industry Symbol
Series ISIN Code
3
4 ACC Ltd. CEMENT AND CEMENT PRODUCTS ACC
EQ INE012A01025
5 Ambuja Cements Ltd. CEMENT AND CEMENT PRODUCTS AMBUJACEM
EQ INE079A01024
6 Axis Bank Ltd. BANKS AXISBANK
EQ INE238A01026
I Import the section that is relevant to me:
> Indx_Constituents <- NIFTY_INDX[4:NROW(NIFTY_INDX),]
> head(Indx_Constituents)
Constituents.list.of.S.P.CNX.Nifty X
X.1 X.2 X.3
4 ACC Ltd. CEMENT AND CEMENT PRODUCTS
ACC EQ INE012A01025
5 Ambuja Cements Ltd. CEMENT AND CEMENT PRODUCTS
AMBUJACEM EQ INE079A01024
6 Axis Bank Ltd. BANKS
AXISBANK EQ INE238A01026
7 Bajaj Auto Ltd. AUTOMOBILES - 2 AND 3 WHEELERS
BAJAJ-AUTO EQ INE917I01010
8 Bharat Heavy Electricals Ltd. ELECTRICAL EQUIPMENT
BHEL EQ INE257A01018
9 Bharat Petroleum Corporation Ltd. REFINERIES
BPCL EQ INE029A01011
> colNames <- NIFTY_INDX[2,]
> colNames
Constituents.list.of.S.P.CNX.Nifty X X.1 X.2 X.3
2 Company Name Industry Symbol Series ISIN Code
I want to assign the info from colNames[1,] to Indx_Constituents .... I am
unable to do this directly ... I can probably pull out the values and do it
but there should be an easier way
Now when I do this:
> colNames[1,1]
[1] Company Name
52 Levels: ACC Ltd. Ambuja Cements Ltd. Axis Bank Ltd. Bajaj Auto Ltd.
Bharat Heavy Electricals Ltd. Bharat Petroleum Corporation Ltd. Bharti
Airtel Ltd. Cairn India Ltd. Cipla Ltd. Company Name ... Wipro Ltd.
Why does R have to remember the 52 levels?? Why can't it just have the
relevant data stored
What are the alternatives so that I can simply have my needed data in my
data frames?
Thanks for your explanation.
----------------------------------------------------------------------------
--------------------------
Thanks R-Helpers. Yes, this is a silly question and it will not be repeated!
:-)
More information about the R-help
mailing list