I was looking through some functions and found library(MVN), where I wanted to use the uniPlot function, which is quite neat as it quickly provides summary plots for each column in data frame. I was using :
uniPlot(ready, type="histogram")
But the function was depreciated, I was wondering whether anyone knows anything similar to this function ( plot histograms with overlaying normal curve)?
You can perform this in the current MVN version as following:
mvn(data = iris[1:50,1:3], mvnTest = "royston", univariatePlot =
"histogram")
Related
So, I'm SUPER new with R and frequently find myself getting tripped up by the most basic functions. Right now, I have a data frame of which contains 7 different variables that I want to view the correlation relationships. Most of the posts I've seen online talk about how to use the corr.test function (psych package) if using a dataframe, but I'm not sure how to just specify the variables I'm looking for. I keep getting error codes for the script below (keeping the variable names anonymous):
corr.test(mydatareg$V1, mydatareg$V2, mydatareg$V3, mydatareg$V4, mydatareg$V5, mydatareg$V6, mydatareg$V7, y = NULL, use = "pairwise", method="pearson", adjust="holm", alpha=.05, ci=TRUE, minlength=5)
any help would be greatly appreciated!
I am trying to plot a function in Julia, but keep getting errors. I don't understand what is wrong. The input and output of $\varphi$ is a scalar. I've used x=1530:1545 and still get an error-- can anyone enlighten me? I am very confused.
I am using Julia 0.7.
EDIT:
I got it to work with a slight modification--I changed
x = 1530:1545
added the following two lines
y = t.(x)
plot(x,y)
Why did I have to do this though?
This feature is currently not available in PyPlots.jl, if you would like to have it in the future, your best bet is to file an issue.
However, you can get that functionality via Plots.jl and using PyPlot as a backend.
It would look like this (I'll take a simpler function):
using Plots
pyplot()
start_point = 0
end_point = 10
plot_range = start_point:end_point
plot(sqrt,plot_range) # if you want the function exactly at 0,1,2,3...
plot(plot_range,sqrt) # works the same
plot(sqrt,start_point,end_point) # automatically chooses the interior points
I am looking to automate the process of exploratory data analysis and would like to graph the distribution (using line plots, histograms, density curves, etc.) of all the input variables. As my code stands, I am simply getting 4 blank graphics windows. What am I doing incorrectly? If there is a better approach, I am open to that as well.
mydata <- read.csv("http://www.ats.ucla.edu/stat/data/binary.csv")
for (i in names(mydata)){
qplot(data=mydata,i,geom="bar", fill="admit")
dev.new()
}
This situation looks like one where aes_string would come in handy (along with the addition of print around your call to ggplot). I found this post showing how to use aes_string with ggplot inside a loop.
So it would look something like this:
mydata$admit = factor(mydata$admit)
for(i in names(mydata)) {
print(ggplot(mydata) + geom_bar(aes_string(x = i, fill = "admit")))
}
I'm working in RStudio so have skipped the dev.new part of your code. I found I needed to convert admit to a factor, as well.
I have a question about Reference Classes. My question is in the context of an R package I am developing rCharts. It uses reference classes to create interactive plots from R.
Creating a plot involves a series of calls. Here is an example, where a scatterplot is created at first and then a line plot gets added.
p1 <- rPlot(mpg ~ cyl, data = mtcars, type = 'point')
p1$layer(copy_layer = T, type = 'line')
Now, since a Reference Class is like a closure, I was wondering if it was possible to log the calls made. The idea is that if I can log the sequence of calls made, then I can automagically insert the source code used to create a visualization, along with the html.
I was trying to see if I could make use of sys.function or match.call, but am not getting anywhere. If someone can point me to how I can approach this, it would be much appreciated.
As #hadley stated:
calls <<- c(calls, list(match.call()))
Glad that looks to have worked. Let's get this closed. :)
i am new to programming / R and i have a question that might be very easy.
my function is:
par(mfrow=c(2,2))
plot_QQ=function(x) {for(i in 2:x)
plot(c(data_raw[,Group1[i]]),c(data_raw[,Group1[1]]), xlab=paste("replicate",i), ylab="replicate 1")
abline(lm(c(data_raw[,Group1[i]])c(data_raw[,Group1[1]]))}
group1 is an vector c("","","") to grap specific the data. This function is working, but R does not draw the abline() in all plots. (only in the "last" plot c(data_raw[,Group1[i=x]]),c(data_raw[,Group1[1]]) the line is drawn.
sorry for such an easy question and thx for helping
greetz
In future you should supply some simulated data so that people can run your code, it's unclear what exactly you're trying to do. You don't need the c() functions, and your lm call isn't proper. Also you don't have curly braces around your for loop. Try this.
par(mfrow=c(2,2))
plot_QQ=function(x) {for(i in 2:x){
plot(data_raw[,Group1[i]],data_raw[,Group1[1]], xlab=paste("replicate",i), ylab="replicate 1")
abline(lm(data_raw[,Group1[i]]~data_raw[,Group1[1]])}}