So I have Transactions as a dataframe and Transactions$Symbol is a column in the frame I simply want to run sub over all elements in that column where the new value replaces the old value this doesn't seem to work Transactions$Symbol = lapply(Transactions$Symbol, function(x) sub('[ -]*','INST',x))> > Transactions$SymbolNULL
Henrique Dallazuanna
2010-Apr-26 13:22 UTC
[R] How use lapply over one column in a dataframe?
Try this: Transactions$Symbol <- gsub('[ -]*','INST',Transactions$Symbol) On Mon, Apr 26, 2010 at 10:14 AM, Robert Nicholson < robert.nicholson@gmail.com> wrote:> So I have Transactions as a dataframe and Transactions$Symbol is a column > in the frame > > I simply want to run sub over all elements in that column where the new > value replaces the old value > > this doesn't seem to work > > Transactions$Symbol = lapply(Transactions$Symbol, function(x) sub('[ > -]*','INST',x)) > > > > Transactions$Symbol > NULL > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Seemingly Similar Threads
- Transform values from one column into column names of new dataframe
- median value dataframe coming from multiple dataframes
- stripping #s in a text file prior to reading into table or dataframe
- Why do data frame column types vary across apply, lapply?
- Convert dataframe to table with counts where column names become row names