[R] Display data by condition

Juan Ceccarelli Arias jfca283 at gmail.com
Thu Mar 16 19:38:28 CET 2017


Thank you both.
The issue was I didn't declare the database as a data frame and I also
forgot the comma...

ene=as.data.frame(data)
attach(ene)
View(ene[ene$fact>5000,])

The code listed did the trick I desired.
Again, thanks I can say the problem is solved.




On Thu, Mar 16, 2017 at 3:32 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

> Presuming "data" is a data frame because you have not provided a minimal
> reproducible example as requested in the Posting Guide... note also that
> "data" is the name of a function in base R, so that is a potentially
> troublesome variable name.
>
>  A data frame is a list of vectors. It can be indexed either as a
> one-dimensional object of length equal to the number of columns, or as a
> two-dimensional object. You are doing the former but giving a logical index
> appropriate for the number of rows in your data frame. Go re-read the
> Introduction to R document section on indexing to figure out where the
> comma goes.
> --
> Sent from my phone. Please excuse my brevity.
>
> On March 16, 2017 8:16:29 AM PDT, Juan Ceccarelli Arias <jfca283 at gmail.com>
> wrote:
> >Hello,
> >I need to show the observations of a data set only if the earn more
> >than
> >$5000 (fact is its name in the date set). I use this:
> >
> >View(data[data$fact>5000])
> >
> >The code above shows nothing. No error or message at all.
> >What am i doing wrong?
> >Thanks for your help and time.
> >
> >       [[alternative HTML version deleted]]
> >
> >______________________________________________
> >R-help at r-project.org 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list