Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I simulate some data with R code and want to plot these data.
scatter plot is no problem with code plot(SX,Quant),
but when I use plot(SX,Quant,type='l'), the result is
I just want the line through every point.
I try different type of plot, also use ggplot2 to try to modification,
but has same result, plz help me to solve this problem.
Sort your data by the x-value of your plot:
F_inverse=function(x) log((exp(1)-1)*x+1)
U = runif(100)
SX = F_inverse(U)
Quant=rank(SX)/100
ord <- order(SX)
SX <- SX[ord]
Quant <- Quant[ord]
plot(SX,Quant, type="l")
Related
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
I have imported a pimadata.csv to R, I have to create a scatter plot matrix for the first 8 columns in the pimadata; also have to find two variables that seem to have positive correlations. I used this line of code to create the plot;
pairs(pimadata[,1:8])
What should I do to show the correction between the variables?
You could use cor()
cor(pimadata[,1:8])
Since you did not provide the contents of pimadata.csv, I use the iris dataset as an example here.
head(iris)
pairs(iris[,1:4])
scatter plot
cors <- cor(iris[,1:4])
correction output
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am beginner in R and i have a simple regression. Now i want to plot the equation of the regression line into the plot. The most easiest way. I already tried to get it done by following some ideas here.
DICE_Quartal<-read.csv("")
attach(DICE_Quartal)
plot(Preise.Fernbusmarkt ~ Auskunftpflichtige.Unternehmen) + abline(cor_preis_unternehmen, col = "red")
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am plotting multiple ROC-curves with ggroc, and would like the axis names to be "True positive rate" and "False positive rate", rather than sens and spec. Is it possible to do this with ggroc?
I have already tried the following which didn't work:
library(pROC)
ROC_curves <- ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), aes(TPR, FPR), legacy.axes=TRUE)
I have also tried this:
ROC_curves <- ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), legacy.axes=TRUE) + scale_x(name="FPR") + scale_y(name="TPR)
ggroc returns a standard ggplot object, so you can change the axis labels and everything exactly as you would for a standard ggplot:
ggroc(list(log=ROC_log, tree=ROC_tree, rf=ROC_rf), legacy.axes=TRUE)
ROC_curves + xlab("FPR") + ylab("TPR")
Note that you are using legacy.axes=TRUE so that you can re-label the axis this way. Make sure to keep this argument, otherwise the labeling would be invalid.
Also you can drop the aes(TPR, FPR) which is silently ignored.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
Okay so I'm making logs of some distance variables
- example;
loghospital=log(hospital_2015_distance, base=exp(1))
Works, i get values that i can run in a regression.
However for my LASSO regression it's better i specify a dataset.
So i want a dataframe of these logs (values).
Or better I want these logs (values) added to my existing dataframe called (data).
Any idea how this can be achieved? And if not, what else i should do to achieve the same?
To add it to your data.frame you can use $:
data$loghospital = log(hospital_2015_distance, base=exp(1))
Also you could use [[ or [ and probably should <- instead of = for assignment:
# Examples:
data[["loghospital"]] <- log(hospital_2015_distance, base=exp(1))
data["loghospital"] <- log(hospital_2015_distance, base=exp(1))
data[, "loghospital"] <- log(hospital_2015_distance, base=exp(1))
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have this data frame made in R :
Technical Junior Entry-Level Product Owner Technical Leader Senior
Professional 2,236 3,581 3,781 3,654 4,454
Communication 2,619 3,333 4,285 4,190 4,952
Innovation 3,625 4,208 4,500 4,000 4,791
And I want to plot something like that in R (I have made this in Excel)
Radar plot made in excel
Please help me to make this graph through R cause I failed making it with ggplot, ggtern, plotrix and other libraries I cannot manage properly.
I did it very easily using fmsb::radarchart(). Note I had to remove the commas first from your data, which I then read in as df. I also had to add rows for the min and max to reproduce your Excel plot.
library(fmsb)
df1 <- data.frame(t(df))
dfminmax <- rbind(rep(max(df1), 3) , rep(min(df1), 3) , df1)
radarchart(dfminmax)
You're going to want to tweak the settings to make it look better. Use ?radarchart to find out all the options.