[R] Question On Regex and DataFrame

Bert Gunter bgunter.4567 at gmail.com
Mon Feb 22 04:02:12 CET 2016


Inline beow.

On Sunday, February 21, 2016, kalyan chakravarty <
kalyanchakravarty456 at gmail.com> wrote:

> Hi,
> I am new to R and learning the basics.so i came to know that data frame can
> store any data type as oppose to matrix which stores only numeric.My
> question is


False. You need to spend more time with a tutorial or two, as your initial
"understanding" is already incorrect. The rstudio.com website has some nice
suggestions for web tutorials, though you can certainly find many just by
searching.

Your questions below are essentially nonsense, because you do not
understand the data frame concept.

Cheers,
Bert

1.)How to replace a particular pattern with new pattern in data frame.I
> tried something like
> x = as.data.frame(gsub(".*LINK.*","NA",file))........but the output is
> really weird it converts every thing in zeros and ones.
>
> what i actually want is DELETE ALL THE RANDOM COLUMS IN DF BASED ON ROW
> VALUE.
>
> file = read.csv("x.csv",header=T,sep=",")#read the file
> file[file == "LINK"] = NA #replaced row pattern with NA
> file[,colSums(is.na(file))==0] #deleting all colums which has na's
>
> This approach pretty much does the thing but i want to get familiar on how
> to use regular expressions over data frame.
> Any suggestions on which function/package/regex to use when dealing with
> DataFrame
>
> Sorry if this is a basic question.
> Thank you
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE and
> more, see
> 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.
>


-- 
Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

	[[alternative HTML version deleted]]



More information about the R-help mailing list