Forum Replies Created
- AuthorPosts
- bryanParticipant
Fidi,
This is a job for the doBy package; specifically the summaryBy function. The code will be something like:
summaryBy(~disease, data = daten, FUN = length)
Repost if you have any problems.
bryanParticipantYou can change this by setting the working directory in the Rprofile.site file. This is in “your-R-version-directory/etc/”.
On a new line add:
setwd("C:/NewSaveLocation")
bryanParticipantYou’re on the right track, but a couple of questions…
Should the 11 other files be combined before they are compared to x? And will each file in the 12 file set be an x-file at some point?
bryanParticipantThe quantmod package will let you do that and, as an added benefit, it will do it quickly.
The to.period function is what you’ll need. If you have any trouble figuring it out, just post again with the specific error or issue you’re having.
bryanParticipantvmgmax,
I don’t have a direct answer to your question, but this video talks indirectly about combining R and Javascript via JSON. It may give you some answers or ideas.
http://www.youtube.com/watch?v=7x0UdUghANI&hd=1
Bryan
bryanParticipantHi RCinLB,
You’ll want to start by looking at the read.csv function help by typing
>?read.csv
(without the “>”) at the R prompt.
If you have trouble interpreting the help, just post what you’re having difficult with.
Bryan
bryanParticipantYou could write something to do it manually:
path.sep <- function (x) { if (x == "windows") { "\\" } else { "/" } } path.sep(.Platform$OS.type) Which can be extended to fit numerous needs. .Platform$file.sep is related and might be helpful in other cases, but wouldn't help you in this situation.
bryanParticipantOne way to do this is by using parse and eval:
number <- readline("Enter number: ") number <- eval(parse(text = number))
bryanParticipantI’d say you’re correct. It’s hard to tell you the best solution without seeing more of your data; it could also be that you have some unexpected characters in the head of the file. row.names = NULL should allow you to bring in the Date variable. You may also want to use read.csv instead of read.table since you’re bringing in a csv file. It will make the call simpler.
bryanParticipantTabby,
What error(s) are you getting?
bryanParticipantI haven’t seen a comprehensive list, and I would be surprised if one exists given that there are always new packages being released. But here are the functions for generating random numbers from the most common distributions:
rbeta, rbinom, rcauchy, rchisq, rexp, rf, rgamma, rgeom, rhyper,
rlogis, rlnorm, rmultinom, rnbinom, rnorm, rpois, rsignrank, rt,
runif, rweibull, rwilcox, ptukey, qtukeyAstrostats at PSU has a good description of how to use them if you need it:
October 25, 2011 at 5:18 pm in reply to: How to display those animation graphic in Web Environment? #367bryanParticipantHi Louis,
Could you output the image to a .png or .jpeg (see ?png) in a folder that your PHP code has access to and bring it in from there?
bryanParticipantHi diyanah,
Are you using the EBImage package? That should allow you to open images as an array. From the help:
“RGB images are coded in 8 bits per channel, 24 bits per pixel, stored in an R integer array.”
If not, can you tell us what you are using? The relevant portions of your code would also be helpful.
bryanParticipantOne of the most straightforward ways is to create a lagged version of your vector of closing prices and use that in the computation:
x.lag <- c(NA, x[1:(length(x)-1)]) quotient <- x/x.lag
Where 'x' is your vector of prices and your data is sorted by ascending date/time. There are other ways to do this, but this is fairly generalizable code that is easy to change to fit your needs.
bryanParticipantYou can use the sample() function to do what you’re trying to do. E.g.:
sample(50:60, size = 1)
You can also draw draw a larger set of numbers with or without replacement if you want:
sample(50:60, size = 3, replace = T)
One related trick – you can chose numbers at specific intervals by adding the seq() function:
sample(seq(50, 60, by = .5), size = 3, replace = T)
- AuthorPosts