how to plot this function in R [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I know that looks like a silly question but how can I plot this function,
|x|+|y|=z
in 2D by R. I know that is a kind of contour plot but don't know how to manage that.

you can use contour and try this small example
X=seq(-1, 1, length.out=10)
Y=seq(-1, 1, length.out=10)
Z=outer(X, Y, FUN= function(x,y) abs(x)+abs(y))
contour(x=X, y=Y, z=Z)

Related

generate all possible k-mers from a vector and also remaining in r [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Suppose we have a vector [1:10] of players, I want to generate all possible roommates for these playes (not combn(10, 2))
Can you help me?
Thank you
You can iterate over combn(with different ks)
x= 1:10
lapply(1:length(x), function(k) combn(x,k))

ggplot plot, plotting by group across two variables [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a data frame with a patient_name, treatment_status[positive, negative], values
variable = treatment_status
So its something like this should work -
ggplot(data = dat_m, aes(variable, value, group=factor(Patient_Name))) +
geom_jitter(aes(color=factor(variable)))
But unfortunately my patient names don't show up across the x-axis. Is there any way to get this going. Much appreciate any help.
Sounds like you need a interaction function. Try this:
ggplot(data = dat_m, aes(x=interaction(Patient_Name,variable), value) +
geom_jitter(aes(color=factor(variable)))

using contour() in R to make shapefiles [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to use the output from contour(), which is just x, y and z data, to make a shapefile of the contour lines for output into ArcMap?
As a matter of fact there is a function for that in package maptools: ContourLines2SLDF converts the output of contourLines into a SpatialLinesDataFrame object.
cl <- contourLines(volcano)
shp <- ContourLines2SLDF(cl)
You can then save it to a file using maptools's writeSpatialShape or rgdal's writeOGR.

how to write simultaneous subscript and superscript in y label legend with R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to write in y label for my plot():
NH4+-N (subscript 4) (superscript +) (mg L-1) (superscript -1)
can you help me?
Thanks in advance!
You can try with bquote
plot(1, ylab=bquote(NH[4]^"+"*N~mgL^-1))
Or as #MrFlick menioned, quote also works here.
plot(1, ylab=quote(NH[4]^"+"*N~mgL^-1))

How to compute RMSE with respect to a 1:1 line in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Does someone know how to compute RMSE with respect to 1:1 line in R? Thanks for your help.
x=1:50 # it's identity line
y=seq(0.5,25,0.5) # it's y=0.5x
plot(x, type='l')
lines(y, col=3)
rmse=sqrt(mean((y-x)^2))

Resources