use a XTS inside name of a Variable in r












0














I have more than 300 stocks downloaded with getsymbols() and I have the name of this stocks in a vector, for example:



USA_STOCKS = c("AAL","AAPL","ADBE","ADI","ADP","ADSK","ALGN",
"ALXN","AMAT","AMGN","AMZN","ASML","ATVI","AVGO",
"BIDU","BIIB") # This is just an extract from 300
getSymbols(AAL) # this is just one of the 300 "getsymbols"


With that, I have a XTS object called AAL and a vector USA_TOCKS with all the name of the XTS Objets.



I would like to do:



AAL = na.omit(AAL)


But, instead of use the Object AAL, I want to refer the object using the name inside the vector. Something like this:



USA_STOCKS[1] = na.omit(USA_STOCKS[1])


Obviusly if i did this, I will change only the name of "AAL" inside the vector. But what I want is to refer the object AAL.










share|improve this question
























  • Hi, I just edit the answer. Is it more clear?
    – Alberto Aguilera
    Nov 18 '18 at 9:54
















0














I have more than 300 stocks downloaded with getsymbols() and I have the name of this stocks in a vector, for example:



USA_STOCKS = c("AAL","AAPL","ADBE","ADI","ADP","ADSK","ALGN",
"ALXN","AMAT","AMGN","AMZN","ASML","ATVI","AVGO",
"BIDU","BIIB") # This is just an extract from 300
getSymbols(AAL) # this is just one of the 300 "getsymbols"


With that, I have a XTS object called AAL and a vector USA_TOCKS with all the name of the XTS Objets.



I would like to do:



AAL = na.omit(AAL)


But, instead of use the Object AAL, I want to refer the object using the name inside the vector. Something like this:



USA_STOCKS[1] = na.omit(USA_STOCKS[1])


Obviusly if i did this, I will change only the name of "AAL" inside the vector. But what I want is to refer the object AAL.










share|improve this question
























  • Hi, I just edit the answer. Is it more clear?
    – Alberto Aguilera
    Nov 18 '18 at 9:54














0












0








0







I have more than 300 stocks downloaded with getsymbols() and I have the name of this stocks in a vector, for example:



USA_STOCKS = c("AAL","AAPL","ADBE","ADI","ADP","ADSK","ALGN",
"ALXN","AMAT","AMGN","AMZN","ASML","ATVI","AVGO",
"BIDU","BIIB") # This is just an extract from 300
getSymbols(AAL) # this is just one of the 300 "getsymbols"


With that, I have a XTS object called AAL and a vector USA_TOCKS with all the name of the XTS Objets.



I would like to do:



AAL = na.omit(AAL)


But, instead of use the Object AAL, I want to refer the object using the name inside the vector. Something like this:



USA_STOCKS[1] = na.omit(USA_STOCKS[1])


Obviusly if i did this, I will change only the name of "AAL" inside the vector. But what I want is to refer the object AAL.










share|improve this question















I have more than 300 stocks downloaded with getsymbols() and I have the name of this stocks in a vector, for example:



USA_STOCKS = c("AAL","AAPL","ADBE","ADI","ADP","ADSK","ALGN",
"ALXN","AMAT","AMGN","AMZN","ASML","ATVI","AVGO",
"BIDU","BIIB") # This is just an extract from 300
getSymbols(AAL) # this is just one of the 300 "getsymbols"


With that, I have a XTS object called AAL and a vector USA_TOCKS with all the name of the XTS Objets.



I would like to do:



AAL = na.omit(AAL)


But, instead of use the Object AAL, I want to refer the object using the name inside the vector. Something like this:



USA_STOCKS[1] = na.omit(USA_STOCKS[1])


Obviusly if i did this, I will change only the name of "AAL" inside the vector. But what I want is to refer the object AAL.







r xts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 9:53

























asked Nov 18 '18 at 0:01









Alberto Aguilera

538




538












  • Hi, I just edit the answer. Is it more clear?
    – Alberto Aguilera
    Nov 18 '18 at 9:54


















  • Hi, I just edit the answer. Is it more clear?
    – Alberto Aguilera
    Nov 18 '18 at 9:54
















Hi, I just edit the answer. Is it more clear?
– Alberto Aguilera
Nov 18 '18 at 9:54




Hi, I just edit the answer. Is it more clear?
– Alberto Aguilera
Nov 18 '18 at 9:54












1 Answer
1






active

oldest

votes


















1














Hmm, still a bit unclear, but I think you want to do something like this:



library(quantmod)

USA_STOCKS = c("AAL","AAPL","ADBE")

# Put all requested quotes in big list
stocks_usa <- lapply(USA_STOCKS,
getSymbols,
from = "2018-10-01",
to = "2018-11-01",
auto.assign = F)

# set the names of the list
names(stocks_usa) <- USA_STOCKS

#reference AAL
head(stocks_usa$AAL)

AAL.Open AAL.High AAL.Low AAL.Close AAL.Volume AAL.Adjusted
2018-10-01 41.41 41.75 39.60 39.61 7210700 39.50097
2018-10-02 39.60 39.60 38.40 38.50 7625000 38.39403
2018-10-03 38.70 39.26 38.42 38.80 6370300 38.69320
2018-10-04 38.80 39.01 37.48 37.92 5916500 37.81562
2018-10-05 37.93 38.13 36.21 36.44 9127000 36.33969
2018-10-08 36.44 36.85 35.60 35.90 7879300 35.80119

# more referencing
stocks_usa$AAL <- na.omit(stocks_usa$AAL)





share|improve this answer





















  • This is not exactly what I were looking for but your solution solve my problem! Thanks
    – Alberto Aguilera
    Nov 19 '18 at 9:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53356724%2fuse-a-xts-inside-name-of-a-variable-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Hmm, still a bit unclear, but I think you want to do something like this:



library(quantmod)

USA_STOCKS = c("AAL","AAPL","ADBE")

# Put all requested quotes in big list
stocks_usa <- lapply(USA_STOCKS,
getSymbols,
from = "2018-10-01",
to = "2018-11-01",
auto.assign = F)

# set the names of the list
names(stocks_usa) <- USA_STOCKS

#reference AAL
head(stocks_usa$AAL)

AAL.Open AAL.High AAL.Low AAL.Close AAL.Volume AAL.Adjusted
2018-10-01 41.41 41.75 39.60 39.61 7210700 39.50097
2018-10-02 39.60 39.60 38.40 38.50 7625000 38.39403
2018-10-03 38.70 39.26 38.42 38.80 6370300 38.69320
2018-10-04 38.80 39.01 37.48 37.92 5916500 37.81562
2018-10-05 37.93 38.13 36.21 36.44 9127000 36.33969
2018-10-08 36.44 36.85 35.60 35.90 7879300 35.80119

# more referencing
stocks_usa$AAL <- na.omit(stocks_usa$AAL)





share|improve this answer





















  • This is not exactly what I were looking for but your solution solve my problem! Thanks
    – Alberto Aguilera
    Nov 19 '18 at 9:48
















1














Hmm, still a bit unclear, but I think you want to do something like this:



library(quantmod)

USA_STOCKS = c("AAL","AAPL","ADBE")

# Put all requested quotes in big list
stocks_usa <- lapply(USA_STOCKS,
getSymbols,
from = "2018-10-01",
to = "2018-11-01",
auto.assign = F)

# set the names of the list
names(stocks_usa) <- USA_STOCKS

#reference AAL
head(stocks_usa$AAL)

AAL.Open AAL.High AAL.Low AAL.Close AAL.Volume AAL.Adjusted
2018-10-01 41.41 41.75 39.60 39.61 7210700 39.50097
2018-10-02 39.60 39.60 38.40 38.50 7625000 38.39403
2018-10-03 38.70 39.26 38.42 38.80 6370300 38.69320
2018-10-04 38.80 39.01 37.48 37.92 5916500 37.81562
2018-10-05 37.93 38.13 36.21 36.44 9127000 36.33969
2018-10-08 36.44 36.85 35.60 35.90 7879300 35.80119

# more referencing
stocks_usa$AAL <- na.omit(stocks_usa$AAL)





share|improve this answer





















  • This is not exactly what I were looking for but your solution solve my problem! Thanks
    – Alberto Aguilera
    Nov 19 '18 at 9:48














1












1








1






Hmm, still a bit unclear, but I think you want to do something like this:



library(quantmod)

USA_STOCKS = c("AAL","AAPL","ADBE")

# Put all requested quotes in big list
stocks_usa <- lapply(USA_STOCKS,
getSymbols,
from = "2018-10-01",
to = "2018-11-01",
auto.assign = F)

# set the names of the list
names(stocks_usa) <- USA_STOCKS

#reference AAL
head(stocks_usa$AAL)

AAL.Open AAL.High AAL.Low AAL.Close AAL.Volume AAL.Adjusted
2018-10-01 41.41 41.75 39.60 39.61 7210700 39.50097
2018-10-02 39.60 39.60 38.40 38.50 7625000 38.39403
2018-10-03 38.70 39.26 38.42 38.80 6370300 38.69320
2018-10-04 38.80 39.01 37.48 37.92 5916500 37.81562
2018-10-05 37.93 38.13 36.21 36.44 9127000 36.33969
2018-10-08 36.44 36.85 35.60 35.90 7879300 35.80119

# more referencing
stocks_usa$AAL <- na.omit(stocks_usa$AAL)





share|improve this answer












Hmm, still a bit unclear, but I think you want to do something like this:



library(quantmod)

USA_STOCKS = c("AAL","AAPL","ADBE")

# Put all requested quotes in big list
stocks_usa <- lapply(USA_STOCKS,
getSymbols,
from = "2018-10-01",
to = "2018-11-01",
auto.assign = F)

# set the names of the list
names(stocks_usa) <- USA_STOCKS

#reference AAL
head(stocks_usa$AAL)

AAL.Open AAL.High AAL.Low AAL.Close AAL.Volume AAL.Adjusted
2018-10-01 41.41 41.75 39.60 39.61 7210700 39.50097
2018-10-02 39.60 39.60 38.40 38.50 7625000 38.39403
2018-10-03 38.70 39.26 38.42 38.80 6370300 38.69320
2018-10-04 38.80 39.01 37.48 37.92 5916500 37.81562
2018-10-05 37.93 38.13 36.21 36.44 9127000 36.33969
2018-10-08 36.44 36.85 35.60 35.90 7879300 35.80119

# more referencing
stocks_usa$AAL <- na.omit(stocks_usa$AAL)






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 18 '18 at 10:41









phiver

12.7k92634




12.7k92634












  • This is not exactly what I were looking for but your solution solve my problem! Thanks
    – Alberto Aguilera
    Nov 19 '18 at 9:48


















  • This is not exactly what I were looking for but your solution solve my problem! Thanks
    – Alberto Aguilera
    Nov 19 '18 at 9:48
















This is not exactly what I were looking for but your solution solve my problem! Thanks
– Alberto Aguilera
Nov 19 '18 at 9:48




This is not exactly what I were looking for but your solution solve my problem! Thanks
– Alberto Aguilera
Nov 19 '18 at 9:48


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53356724%2fuse-a-xts-inside-name-of-a-variable-in-r%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?