Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm a student just learning how to use R and thus far I've made a bit of progress. I'm snagging at a question which asks: For what values of i does Y equal 3?
the data set: c(3,5,2,3,5,4,4,2,3,5)
If I understand your question correctly, you want the index, i inside the data set (in this case, a vector) Y such that Y[i]=3?
Then you just need to use the which function. For more information, make sure you try reading the help files, which you can invoke using the command ?which or help(which)
Now, some code:
# Your data
Y <- c(3,5,2,3,5,4,4,2,3,5)
# Find the index where Y is equal to 3
which(Y==3, arr.ind=TRUE)
And welcome to SO. This is a pretty common question for beginners, so next time, make sure you Google or search around for a solution to elementary problems such as these. Have a good day.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 3 years ago.
Improve this question
I am new to data science and I came across this exercise that I can't figure out.
I have a data set containing binary data, which represents win and loss for the team. I wanna find out the probability for the win and loss depending on the result of the previous game.
Something like this.
win loss
prev win ? ?
prev loss ? ?
I am not asking for the code here. Though it would be helpful if you do. I just want to understand how to go about doing it.
You can generate that prop.table by comparing the result to the lagged (previous) result:
library(dplyr)
results <- data.frame(results = rbinom(100,1, 0.5)) %>%
mutate(prev_result = lag(results))
prop.table(table(results$prev_result, results$results))
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 would like to graph this kind of equation, z=x*y. I would like to set intervals like -n< x <-n and so on, to see how z varies in function of x and y at the same time. I also need to check the value of z at given x and y and see where z is at its maximum, for example. Thanks and have all a nice day!
Edit: the equation i am trying to study is z=x * (164+0.25y)
where 0 < x < 2.5 and 0 < x < 700.
P.S. I don't understand the downvotes, I kindly asked for a question in a polite way, providing as many details as I could.
This question may be a little outside of the scope of this site, but in regards to a graphing program:
One of the easiest ways to determine things about graphs is to use Wolfram Alpha a computational knowledge engine. A quick tour on the site and just trying a few things out should get you to where you want to go pretty quickly.
Since you appear new to this site, check out some of the Stack Overflow Basics and be sure to up-vote any help you get or questions you may find helpful.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
This is a borderline question for Stackoverflow, I know, but I am looking for a package. If I can't get an answer here I will transfer to https://stats.stackexchange.com/. I am looking for a R package or a method to create a phase diagram. This means I have e.g. two variables, like air pressure and temperature, and a binary variable (to make it easier) indicating if the substance is liquid or frozen. Below you find a typical example of a phase diagram. I need to estimate the transition borders or something however just in a case with two groups. Every hint is appreciated.
I think about the closet you will get is function diagram in package CHNOSZ. There's a lot to read about in this package and it has some nice vignettes. But, it seems to calculate phase diagrams from first principles or theory. Perhaps if you look at the code for diagram you can figure out a fairly easy way to use your empirical data.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
In R, how do you generate a vector (data) with outliers? Great if the data is "acceptable" normal distributed.
#DWin is right that this depends on what you mean by "outlier". For the record, I use the same definition that he is using, so I would use (have used) something like the code he, and #Ferdinand.kraft, list. Others sometimes mean a datum more extreme than you might typically find. This is tricky to define for a simulation study, but a common definition is a point more than 1.5 times the interquartile range past the 1st (3rd) quartile. Here is a simple way to find that (I'm sure there will be more efficient ways):
flag <- 0
while(flag==0){
X <- rnorm(N)
bp <- boxplot(X, plot=FALSE)
if(length(bp$out)!=0){
flag <- 1
}
}
This really depends on the definition of "outlier";
c(rnorm(100), 100, -100) # an egregious example
plot(density( c( rnorm(90), rnorm(5, 1) ) ) ) # not as egregious
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
For my theory of computation class, we are supposed to do some review/practice problems to work off the rust and make sure we are ready for the course. Some of the problems are induction proofs. I did this at one time, but apparently it has completely escaped me. I've watched a couple tutorials, but still can't do problem 'a'. If anyone can walk me through the first problem I'm pretty sure I could figure out the second one on my own. Any help would be appreciated!
First verify it holds for n = 1.
Then assume it is true for n = x ( the sum of the first x squares ) and then try to compute the sum of the the first x + 1 squares. You know the result for the first x, you just add the last square to that sum. From there it should be easy.
And you posted on the wrong site.