Re: [R] two dimensional integration

2013-02-17 Thread Berend Hasselman
On 16-02-2013, at 18:01, julia cafnik julia.caf...@gmail.com wrote: Dear R-users, I'm wondering how to calculate this double integral in R: int_a^b int_c^y g(x, y) dx dy where g(x,y) = exp(- alpha (y - x)) * b A very similar question was asked about nine years ago:

Re: [R] two dimensional integration

2013-02-17 Thread julia cafnik
thank for your help. already solved it. Cheers, J. On Sun, Feb 17, 2013 at 9:41 AM, Berend Hasselman b...@xs4all.nl wrote: On 16-02-2013, at 18:01, julia cafnik julia.caf...@gmail.com wrote: Dear R-users, I'm wondering how to calculate this double integral in R: int_a^b int_c^y

Re: [R] two dimensional integration

2013-02-17 Thread Berend Hasselman
On 17-02-2013, at 10:01, julia cafnik julia.caf...@gmail.com wrote: thank for your help. already solved it. Show us how. So that others looking for answers to similar problems in future can find an answer. Berend __ R-help@r-project.org mailing

Re: [R] two dimensional integration

2013-02-17 Thread julia cafnik
This function is separable. If calculating by hand with bounds a -0 and b - 1 i got the result: theta / kappa * ( 1 + exp( - kappa) / kappa - 1 / kappa) by putting theta - 0.1 kappa -0.3 in the above result I got 0.04535 I implemented it in R this way: integrate(function(y) { sapply(y,

[R] Multidimensional correlation matrix question

2013-02-17 Thread Tanushree Tunstall
Hello, I previously sent this message which was stripped off due to HTML mail. Sorry! Thanks. Hello All, I am new to the list. I have been learning to use R recently and its been great to see so much help available. However I must admit, I have stumbled upon a problem with correlation matrices

[R] Getting WinBUGS Leuk example to work from R using R2winBUGS

2013-02-17 Thread Andy Cox
I am trying to learn to use winBUGS from R, I have experience with R. I have managed to successfully run a simple example from R with no problems. I have been trying to run the Leuk: Survival from winBUGS examples Volume 1. I have managed to run this from winBUGS GUI with no problems. My problem

[R] Extracting Numeric Columns from Data Fram

2013-02-17 Thread Henrik Pärn
Dear Barry, I saw that you received several nice answers on how to 'pull out' numeric columns. You also wrote that an alternative could be to 'just operate only on' numerics. Here is one possibility: library(plyr) # some dummy data df - data.frame(nonnum1 = letters[1:5], num1 = 1:5, nonnum2

Re: [R] reading data

2013-02-17 Thread arun
HI Vera, No problem.  I am cc:ing to r-help. A.K. From: Vera Costa veracosta...@gmail.com To: arun smartpink...@yahoo.com Sent: Sunday, February 17, 2013 5:44 AM Subject: Re: reading data Hi. Thank you. It works now:-) And yes, I use windows. Thank you

Re: [R] list of matrices -- array

2013-02-17 Thread Tony Plate
abind() (from package 'abind') can take a list of arrays as its first argument, so in general, no need for do.call() with abind(). As another poster pointed out, simplify2array() can also be used; while abind() gives more options regarding which dimension is created and how dimension names

Re: [R] positioning a light source within a rgl-plot

2013-02-17 Thread Alexander Senger
Am 27.01.2013 16:48, schrieb Duncan Murdoch: On 13-01-27 10:37 AM, Alexander Senger wrote: Hello useRs, I would like to draw a 3D-surface using rgl with a point-like light-source within the scene, that is with finite distance of the light-source to the surface to be lit. The rgl package

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Benjamin Tyner
Thanks Jim -- I had considered this approach; is there any way to hide such arguments from users? Jim Lemon wrote: On 02/17/2013 12:55 PM, Benjamin Tyner wrote: Given a function that calls itself, what's the best way to detect the entry point? The best I came up with is: IsEntryPoint -

Re: [R] Multidimensional correlation matrix question

2013-02-17 Thread Bert Gunter
Have you read An Introduction to R (ships with R) or made any other minimal effort with a beginning R tutorial to learn the language? Have you read the posting guide or any other previous posts to learn how to post coherently -- a small, reproducible example would be helpful, for instance. It

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Bert Gunter
Make the flag an attribute of the function? Unless the user looks at the attributes, it will be invisible. (Not sure this does what you want, but maybe it's useful.) -- Bert On Sun, Feb 17, 2013 at 7:03 AM, Benjamin Tyner bty...@gmail.com wrote: Thanks Jim -- I had considered this approach;

Re: [R] Multidimensional correlation matrix question

2013-02-17 Thread John Kane
https://github.com/hadley/devtools/wiki/Reproducibility John Kane Kingston ON Canada -Original Message- From: t...@gurukuli.co.uk Sent: Sun, 17 Feb 2013 07:50:17 + To: r-help@r-project.org Subject: [R] Multidimensional correlation matrix question Hello, I previously sent

[R] What value to put in range when I make kriging interpolation?

2013-02-17 Thread DIMITRIS KARAKOSTIS
Hi, I am trying to make an automatic kriging interpolation algorithm.When I use the fit.variogram function what would it be a good startingvalue for the range? ThanksDimitris [[alternative HTML version deleted]]

[R] Hyperparameters in ARIMA models with dlm package

2013-02-17 Thread Juan Manuel Becerra
Hi, i'm beginner in Bayesian methods, I'm reading the documentation about dlm package and kalman filters, I'm looking for a example of transformation of ARIMA in a state space equivalent to use the dlm package and calcualte the hyperparameters. Someone can help me about it?. If it's possible with

[R] How to do a backward calculation for each record in a dataset

2013-02-17 Thread Prakasit Singkateera
Hi Experts, I have a dataset of 3 columns: customer.name product cost John Toothpaste 30 Mike Toothpaste 45 Peter Toothpaste 40 And I have a function of cost whereby cost = 3.40 + (1.20 * no.of.orders^2) I want to do a backward calculation for each records

[R] How to findout the name of a dataframe

2013-02-17 Thread Frans Marcelissen
Let'say we have a dataframe mydata with column v1. If mydata$v1 is passed to a function, is there way, then, to extract the name of the dataframe? What I now do is passing the name of the dataframe to the funcion, so passing two parameters. Maybe with mydata$v1 it is not possible, but with

Re: [R] Select components of a list

2013-02-17 Thread arun
Sorry, I just noticed that in the first line of the solution 'l' got stripped off, it should be read as 'lapply` instead of 'apply`. lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$p.table[2,]))[[1]] #1st list component Thanks, A.K.

[R] calculate classification error in test data set if training data set is not the same length

2013-02-17 Thread Melanie Zoelck
Dear R-Help Members, I have built a classification function using a baseline data set, that contains the group variable and have used it to classify the test data set. I am now trying to get the classification table for the training and test data set and classification success using:

Re: [R] Select components of a list

2013-02-17 Thread arun
Hi Gustav, Just change `summary(x)$coef` to `summary(x)$p.table` I am pasting the code from the attachment. library(gamair)  library(mgcv) data(chicago)  library(splines)   chicago$date-seq(from=as.Date(1987-01-01), to=as.Date(2000-12-31),length=5114)   chicago$trend-seq(dim(chicago)[1]) 

[R] nested random factor using lme produces errors

2013-02-17 Thread melswed
Hi, I am running a mixed-effect model with a nested-random effect. I am interested in gut parasites in moose. I has three different type of treatment that I applied to moose which are from different families. My response variable is gut parasites and the factors are moose families which is nested

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-17 Thread John Kane
This sounds a bit too much like homework. And in any case https://github.com/hadley/devtools/wiki/Reproducibility John Kane Kingston ON Canada -Original Message- From: asltjoey.rs...@gmail.com Sent: Sun, 17 Feb 2013 20:10:13 +0700 To: r-help@r-project.org Subject: [R] How to do

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-17 Thread arun
Hi, I am  not sure I understand it correctly. dat1-read.table(text= customer.name    product    cost John    Toothpaste    30 Mike    Toothpaste    45 Peter    Toothpaste    40 ,sep=,header=TRUE,stringsAsFactors=FALSE)  dat1$no.of.orders-  sqrt((dat1$cost-3.40)/1.20)  dat1 #  customer.name   

Re: [R] nested random factor using lme produces errors

2013-02-17 Thread Ben Bolker
melswed amelie.truchy at slu.se writes: Hi, I am running a mixed-effect model with a nested-random effect. I am interested in gut parasites in moose. I has three different type of treatment that I applied to moose which are from different families. My response variable is gut parasites

Re: [R] How to findout the name of a dataframe

2013-02-17 Thread jim holtman
Will this work for you: myFunc - function(var){ + # get the dataframe name + charName - deparse(substitute(var)) + # parse out data.frame + dataFrame - sub(\\$.*, , charName) + cat(input:, charName, data.frame:, dataFrame, \n) + } myFunc(mydata$V1) input: mydata$V1

Re: [R] How to do a backward calculation for each record in a dataset

2013-02-17 Thread Bert Gunter
Homework? We don't do homework here. -- Bert On Sun, Feb 17, 2013 at 5:10 AM, Prakasit Singkateera asltjoey.rs...@gmail.com wrote: Hi Experts, I have a dataset of 3 columns: customer.name product cost John Toothpaste 30 Mike Toothpaste 45 Peter Toothpaste

Re: [R] How to findout the name of a dataframe

2013-02-17 Thread David Winsemius
On Feb 17, 2013, at 5:51 AM, Frans Marcelissen wrote: Let'say we have a dataframe mydata with column v1. If mydata$v1 is passed to a function, is there way, then, to extract the name of the dataframe? What I now do is passing the name of the dataframe to the funcion, so passing two

Re: [R] list of matrices -- array

2013-02-17 Thread Murat Tasan
thanks to all! didn't know about simplify2array, nor about the abind package. they're exactly what i wanted. cheers, -m On Sun, Feb 17, 2013 at 9:41 AM, Tony Plate tapl...@gmail.com wrote: abind() (from package 'abind') can take a list of arrays as its first argument, so in general, no need

Re: [R] Hyperparameters in ARIMA models with dlm package

2013-02-17 Thread Mark Leeds
Hi: Like I said earlier, you really should read west and harrison first, especially if you're a beginner in bayesian methods. giovanni's book and package are both very nice ( thanks giovanni ) but the book is more of a summary of west and harrison and sort of assumes some familarity with the

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Duncan Murdoch
On 13-02-17 10:03 AM, Benjamin Tyner wrote: Thanks Jim -- I had considered this approach; is there any way to hide such arguments from users? Don't export the recursive function, just a non-recursive function that calls it. Duncan Murdoch Jim Lemon wrote: On 02/17/2013 12:55 PM,

Re: [R] histogram

2013-02-17 Thread arun
HI Elisa, You could use ?cut() vec1-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) label1-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x)

Re: [R] addition in the initial question

2013-02-17 Thread arun
Dear Elisa, Try this: vec1-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45) vec2-vec1[1:26] names(vec2)-LETTERS[1:26] label1-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x)

Re: [R] Multidimensional correlation matrix question

2013-02-17 Thread Tanushree Tunstall
Thanks! I will do the needful. On Sun, Feb 17, 2013 at 3:32 PM, John Kane jrkrid...@inbox.com wrote: https://github.com/hadley/devtools/wiki/Reproducibility John Kane Kingston ON Canada -Original Message- From: t...@gurukuli.co.uk Sent: Sun, 17 Feb 2013 07:50:17 + To:

[R] Loop

2013-02-17 Thread Trying To learn again
Hi all, I want to execute a loop of a program: for (u in Timeframemin:Timeframe){} Imagine that Timeframemin-10 Timefram-1 Is it posible to execute the loop but only proving from 10 to 1 but jumping 10 each time, for example, execute for 10,20,30.to Timeframe. Other question is,

[R] strptime() with format %OS does not print millisecs in MacOS

2013-02-17 Thread Agustin Lobo
Hi! I'm finding this on MacOS Lion 10.7.5 getOption(digits.secs) NULL a - 2012_10_01_14_13_32.445 strptime(a,format=%Y_%M_%d_%H_%M_%OS) [1] 2012-02-01 14:13:32 strptime(a,format=%Y_%M_%d_%H_%M_%OS3) [1] NA I can solve it with options(digits.secs=3) strptime(a,format=%Y_%M_%d_%H_%M_%OS)

Re: [R] nested random factor using lme produces errors

2013-02-17 Thread melswed
I understand. I want to specify that drug is only a fixed factor and family should be the only random factor. So maybe, my R code is wrong If I specify random=~1|drug/family it is only because I wanted to specify that family is nested within drug. -- View this message in context:

Re: [R] Loop

2013-02-17 Thread Rui Barradas
Hello, As for the first question, you can do something like Timeframemin-10 Timefram-1 uFrame - seq(Timeframemin, Timefram, by = 10) for(u in uFrame) {} As for the second question, the answer is yes, there is a print() function, which can be used for your purpose. Hope this helps,

Re: [R] detecting entry into a recursive function

2013-02-17 Thread Jim Lemon
On 02/18/2013 02:03 AM, Benjamin Tyner wrote: Thanks Jim -- I had considered this approach; is there any way to hide such arguments from users? Hi Ben, I played around with your solution for a while and if the first argument to the function changes with each recursive call, you may be able to

[R] questions hash functions

2013-02-17 Thread Tania Patiño
Hello R, could you explain to me how to resolve this question: If this is a matrix: Element S1 S2 S3 S4 001 01 101 00 210 01 300 10 400 11 510 00 1. How is

Re: [R] questions hash functions

2013-02-17 Thread Jeff Newmiller
I cannot imagine why you think this is the appropriate place to pose such a question. It certainly has nothing to do with R (which would be appropriate), and it does look like homework (which is identified as NOT appropriate in the Posting Guide for this mailing list).

[R] Computing Spectral Slope

2013-02-17 Thread Marc Comino Trinidad
Greetings, I'm working on image classification and for that I want to use the spectral slope as a feature for my classifier. For this I would prefer to calculate this feature using R, so far I've read my image and converted it's RGB representation into HSL. The spectral slope is computed over the

[R] forecast ARMA(1,1)/GARCH(1,1) using fGarch library

2013-02-17 Thread GUSTAVO SANTA ROSA GARCIA
Hi, i am working in the forecast of the daily price crude . The last prices of this data are the following: 100.60 101.47 100.20 100.06 98.68 101.28 101.05 102.13 101.70 98.27 101.00 100.50 100.03 102.23 102.68 103.32 102.67 102.23 102.14 101.25 101.11 99.90 98.53 96.76 96.12

Re: [R] cumulative sum by group and under some criteria

2013-02-17 Thread arun
Hi, Yes, I wanted to expand directly from d. If there are other variables, says A, B, C that I need to keep  in the final expanded data, how to modify the code? d-data.frame() for (m1 in 2:3) {     for (n1 in 2:2) {     for (x1 in 0:(m1-1)) {     for (y1 in 0:(n1-1)) {

[R] system() stdout not recieved

2013-02-17 Thread John Broecher
I would like to execute a python script from R and receive the stdout in R. I have windows xp and R 2.14.2. The test.py script should print hello, it does work in cmd. Here is a couple tries, thanks for any suggestions!John system('cmd test.py', intern = TRUE)[1] Microsoft Windows XP [Version

[R] compare posterior samples from R2OpenBugs and R function bugs{R2WinBUGS}

2013-02-17 Thread Jia Liu
Hi all, I used both OpenBugs and R function bugs{R2WinBUGS} to run a linear mixed effects model based on the same data set and initial values. I got the same summary statistics but different posterior samples. However, if I order these two sets of samples, one is generated from OpenBugs and the