Q1 is very opaque because you are not even saying what kind of plot you want.
For a regular scatterplot, you have multiple options.
a.) select only the data in the given intervals and plot the data
b.) plot the entire data, but restrict the graph region to the intervals you
are interested in, or
c.) winsorize the data (i.e., set values below the lower cutoff and above
the upper cutoff to the cutoff values
Which one you want to do depends on which one makes the most sense given the
purpose of your analysis
Say:
x<-rnorm(100)
y<-x+rnorm(100)
Then
a.) plot(y~x,data=data.frame(x,y)[x<2&x>-2 , ])
#plots y against x only for xs between -2 and 2
b.) plot(y~x,xlim=c(-2,2))
#plots all y agains x, but restricts the plotting region to -2 to 2 on the
x-axis
c.)
x<-replace(x,x>2,2)
x<-replace(x,x<(-2),-2)
plot(y~x)
#sets all x-values below -2 and above 2 to these cutoffs
Q2: look at the cut() function.
?cut
HTH,
Daniel
Mark D. wrote:>
> Dear R users,
>
> This is most likely very basic question but I am new to R and would really
> appreciate some tips on those two problems.
>
>
> 1) I need to plot variables from a data frame. Because of some few high
> numbers my graph is really strange looking. How could I plot a fraction of
> the samples (like 0.1 (10%), 0.2 up to for example 0.6) on x axis and
> values 'boundaries' (like any value '< 100',?
'101-200' and '> 201') on
> the y axis? This needs to be a simple line plot. The values would come
> from one column.
>
>
> 2) I have a data frame with values and need to subset the rows based on
> the values. I wanted to order them (with increasing values) and divide
> into 3-4 groups. I though about using quantile but I want the group to be
> something like '1-25', '26-50', '51-75',
'75-100'. I could just look for a
> median divide into two and then again (or use quantiles 0.25, 0.5, 0.7 and
> 1 and then get rid of all rows in 0.25 that are in 0.5 etc) but surely
> there must by a faster and simpler way to do that (I need to do this a lot
> on different columns)?
>
> Thanks for your help,
> Mark
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
--
View this message in context:
http://r.789695.n4.nabble.com/Plotting-and-quantiles-tp3739905p3739958.html
Sent from the R help mailing list archive at Nabble.com.