Forum Replies Created

Viewing 15 posts - 16 through 30 (of 38 total)
  • Author
    Posts
  • in reply to: Counting rows #686
    bryan
    Participant

    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.

    in reply to: Default save location #505
    bryan
    Participant

    You 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")

    in reply to: Large scale file analysis #497
    bryan
    Participant

    You’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?

    in reply to: Dividing tick-data into 5 min intervals #493
    bryan
    Participant

    The 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.

    in reply to: JSON array to dataframe #489
    bryan
    Participant

    vmgmax,

    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

    in reply to: New to R – Need help #485
    bryan
    Participant

    Hi 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

    in reply to: System path separtor #467
    bryan
    Participant

    You 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.

    in reply to: Read exponential numbers from console #463
    bryan
    Participant

    One way to do this is by using parse and eval:

    number <- readline("Enter number: ") number <- eval(parse(text = number))

    in reply to: RE: duplicate ‘row.names’ are not allowed error #457
    bryan
    Participant

    I’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.

    in reply to: Sequential Sum of Squares Code #318
    bryan
    Participant

    Tabby,

    What error(s) are you getting?

    in reply to: Random Number Generator #379
    bryan
    Participant

    I 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, qtukey

    Astrostats at PSU has a good description of how to use them if you need it:

    http://astrostatistics.psu.edu/datasets/R/Random.html

    in reply to: How to display those animation graphic in Web Environment? #367
    bryan
    Participant

    Hi 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?

    in reply to: How to open offline image as an array? #473
    bryan
    Participant

    Hi 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.

    in reply to: New to R coding #447
    bryan
    Participant

    One 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.

    in reply to: Generating random numbers in R #438
    bryan
    Participant

    You 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)

Viewing 15 posts - 16 through 30 (of 38 total)
Scroll to top
Privacy Policy