[R] using R to draw over a distribution.
Hi, Suppose I analyze a log to create a histogram: event E1 occurred N1 times event E2 occurred N2 times ... ... for m total events ... event Em occurred Nm times The total number of occurrences is: T = SumNj j=1..m I want to give this histogram to R and ask it to produce T random events such that approximately N1 instances of E1 are drawn, N2 instances of E2 drawn, and so forth. Regards, Shane __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] getting a weighted average from a table
Hi, I have a very simple request (I think). I have a vector/array, > c <- c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) I produce a reverse sorted table/histogram with it, > t = rev(sort(table(c)) > t c 3.3 1.2 5.1 1.3 1.1 1 0 2 2 1 1 1 1 1 I would now like to get the labels "3.3 1.2 5.1 1.3 1.1 1 0" into its own vector and the # of counts "2 2 1 1 1 1 1" so I can calculate weighted averages. So if I can get the labels into a vector l and the counts into a vector n, l <- c(3.3,1.2,5.1,1.3,1.1,1,0); n <- c(2,2,1,1,1,1,1); for(i=0;i<7;i++) total = l[i]*n[i] total = total / sum(n) <- this is the weight average __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] getting a weighted average from a table
Hi, I have a very simple request (I think). I have a vector/array, > c <- c(1.3,1.2,1,3.3,3.3,5.1,1.1,1.2,0) I produce a reverse sorted table/histogram with it, > t = rev(sort(table(c)) > t c 3.3 1.2 5.1 1.3 1.1 1 0 2 2 1 1 1 1 1 I would now like to get the labels "3.3 1.2 5.1 1.3 1.1 1 0" into its own vector and the # of counts "2 2 1 1 1 1 1" so I can calculate weighted averages. So if I can get the labels into a vector l and the counts into a vector n, l <- c(3.3,1.2,5.1,1.3,1.1,1,0); n <- c(2,2,1,1,1,1,1); for(i=0;i<7;i++) total = l[i]*n[i] total = total / sum(n) <- this is the weight average __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] I source an R script. An error is reported. But on what line
> source("C:\\Documents and Settings\\smiller53\\Desktop\\perf.r") Error in eval.with.vis(expr, envir, enclos) : element 1 is empty; the part of the args list of 'c' being evaluated was: perf.r is a long script. how can I determine which line the error occurred on? TIA, SHane __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] default print format for large numbers
Numbers like ``1239178547.653775" is inserted into a vector. I print the vector: > route_9_80_end [1] 1239178522 1239178526 1239178524 1239178524 1239178524 1239178523 1239178524 1239178522 1239178521 1239178565 1239178566 1239178566 [13] 1239178565 1239178566 1239178566 1239178565 1239178566 1239178566 and the decimals are suppressed. While R is wonderful and wonderfully documented, I can only find some quasi relavent information on options(digits) or some such as might apply here. How can I force R to print some part of the decimal i.e. back to 1239178547.653775? TIA, Shane __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sourced plot commands not working
I have source a script running with no errors that ends in these lines: == for (i in 2:3) win.graph() dev.set(2) levelplot(avg ~ procs * size, rrt, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) dev.set(3) levelplot(avg ~ procs * size, ort, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) = The graphics devices windows appear, however, there is no graph and the background of each window is gray indicating no active graph. However, if I copy and paste these commands from the script and enter them into the console, they run fine. why? R 2.8.1 2008-12-22 on windows. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.