[R] Display data by condition

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Thu Mar 16 19:32:42 CET 2017


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.



More information about the R-help mailing list