Hello Eric,

Thanks for the reply!  Your answer was correct however the my problem was
not explained correctly, my apologies to everyone.
The issue is that once a list is built from the symbols that were download
a mixed type list is formed, see below.

R> class(tickers$VALE3.SA_sd_log)
[1] "numeric"
R> class(tickers$VALE3.SA)
[1] "xts" "zoo"
R> R>

The VALE3 ticker has another list element as well: VALE3.SA_mean_log.
This happens with a few of the symbols only thus the issue at hand seems to
be removing the list "numeric" type elements.

TIA,

--
André Luiz Tietbohl Ramos, PhD.


Em seg., 29 de dez. de 2025 às 03:18, Eric Berger <[email protected]>
escreveu:

> library(quantmod)
>
> keepohlc <- function(x) {
>     ohlc <- c(".Open",".High",".Low",".Close")
>     iV <- sapply(ohlc, \(s) {grep(s,colnames(x))})
>     x[,iV]
> }
>
> getSymbols("MSFT")
>
> head(MSFT)
>
>            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume
> MSFT.Adjusted
> 2007-01-03     29.91     30.25    29.40      29.86    76935100
> 21.12207
> 2007-01-04     29.70     29.97    29.44      29.81    45774500
> 21.08670
> 2007-01-05     29.63     29.75    29.45      29.64    44607200
> 20.96644
> 2007-01-08     29.65     30.10    29.53      29.93    50220200
> 21.17159
> 2007-01-09     30.00     30.18    29.73      29.96    44636600
> 21.19280
> 2007-01-10     29.80     29.89    29.43      29.66    55017400
> 20.98060
>
> MSFT <- keepohlc(MSFT)
>
> head(MSFT)
>
>            MSFT.Open MSFT.High MSFT.Low MSFT.Close
> 2007-01-03     29.91     30.25    29.40      29.86
> 2007-01-04     29.70     29.97    29.44      29.81
> 2007-01-05     29.63     29.75    29.45      29.64
> 2007-01-08     29.65     30.10    29.53      29.93
> 2007-01-09     30.00     30.18    29.73      29.96
> 2007-01-10     29.80     29.89    29.43      29.66
>
>
> On Sun, Dec 28, 2025 at 11:51 PM Andre Luiz Tietbohl Ramos
> <[email protected]> wrote:
> >
> > Hello,
> >
> > I'm downloading quote data using the getSymbols() function.  It works
> very
> > well but downloads two additional columns for a few symbols,
> > namely _mean_log and _sd_log.
> > Therefore, the traditional 5 column OHLCV data frame has two more columns
> > in some symbols.
> >
> > I move all downloaded symbols to a list in order to ease some required
> > computation.  At the same time, my routine depends on OHLCV data only.
> > Thus, I need to have a new list discarding the additional columns that
> > exist in some symbols on the current list.  The symbols with the "extra"
> > columns must be kept. However their additional columns must be removed.
> >
> > Could anyone suggest a solution to this problem, please?
> >
> > Thanks in advance for any help,
> >
> > --
> > Andre Luiz Tietbohl Ramos, PhD
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [email protected] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to