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
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
can anyone explain to me the tsSmooth function in R?
I would like to use it to obtain a univariate time series with a linear trend
Please note that on your code:
x<-rt(n=30,df=3, ncp=10)
y<-rt(n=20,df=3,ncp=20)
myseries<-c(x,y)
tsSmooth<-c(x,y)
newseries<-tsSmooth
you didn't apply the tsSmooth() function to your data. You simply created a vector named tsSmooth and another vector named newseries
tsSmooth() function uses a specific data input and doesn't provide much explanation.
There is this discussion that might help https://stats.stackexchange.com/questions/125946/generate-a-time-series-comprising-seasonal-trend-and-remainder-components-in-r
In addition, you could generate a simple trend using moving average. But I am not sure if it has all the statistical features you are looking for.
library("TTR")
plot.ts(myseries)
trendSMA <- SMA(myseries)
plot.ts(trendSMA)
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 pass a data frame to a function as an argument. And then inside the function, I want to work on different combinations of columns for graphical presentation. Basically, I want to do graphical presentation on different data files. I want that, I pass the data file as an argument and then get the graphs. How can I do this in R.
You are not giving us much info but here is a very basic starting point:
library(ggplot2) # if you don't have this library run install.packages('ggplot2')
myAmazingFunction <- function(myDF) {
ggplot(myDF,aes(X,Y))+geom_line()
}
df <-data.frame(X=1:30, Y=runif(30), Z=1.3*runif(30))
myAmazingFunction(df)
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 have data that contains 14 columns of predictors and 1 column of solution variable(y).
I wanted to know if there are any inbuilt functions to normalize and denormalize data in R.
Thank you.
normDataWithin of package {Rmisc} can be used: http://www.inside-r.org/packages/cran/Rmisc/docs/normDataWithin
Else following methods can be used:
(variable-mean)/sd . Following code can be used for a data.frame:
mydata$myNormalizedVar<-(mydata$myvar-mean(mydata$myvar))/sd(myvar)
log (log10), log2, and square root (sqrt)
Normal quantile normalization or normal quantile transformation. Try:
quantNorm = function(x){qnorm(rank(x,ties.method = "average")/(length(x)+1))}
hist(quantNorm(1:10000),100)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I work with the Silhouette Plot from R Package 'Cluster' and want to relabel the statistics shown on the righthand side of the plot (e.g., clusters should be denoted by 'c' instead of 'j').
Can anyone please provide me the underlying R Code so that I can adjust the labeling? Or are there further plot parameters that allow for adjustments?
Thank you very much for your help.
Florian
Find all methods for "silhouette" class:
> methods(class = "silhouette")
[1] plot.silhouette* summary.silhouette*
Non-visible functions are asterisked
To get code:
getAnywhere(plot.silhouette)
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 have a glm model and use the following script:
prob=predict(myglm,type=("response"))
If i export this prob vector i get 1 column with all the probabilities.
prob=predict(myglm,type=("terms"))
This will provide me the terms for each observation in my data set.
My question is how can I export the data set with the
response probability column added to the end of the file?
Thanks is advance!
Is all you want to add a column with the predicted probability to the dataframe used to build the model? If so you do it this way:
mydata$prob <- predict(myglm, type = "response")
Please read An Introduction to R to learn the basics of the R language, it is the standard tutorial.