Re: [R] generating phi using function()

2015-03-31 Thread Daniel Nordlund
On 3/30/2015 12:30 PM, T.Riedle wrote: Hi, I am struggling with following function phi - function(w1, w2, j, k, K){ + zaehler - (k/K)^(w1-1)*(1-k/K)^(w2-1) + nenner - sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) + return( zaehler/nenner ) + } phi(c(1, 1), 44L, 1) Error in phi(c(1, 1),

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread Jeff Newmiller
This is no better because (a) you are still posting using HTML format, and (b) using printed output loses the internal representation of the data. The dput function is very helpful for solving this. [1] [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Re: [R] matrix manipulation question

2015-03-31 Thread Stéphane Adamowicz
Many thanks, Stéphane Le 30 mars 2015 à 10:42, peter dalgaard pda...@gmail.com a écrit : On 30 Mar 2015, at 09:59 , Stéphane Adamowicz stephane.adamow...@avignon.inra.fr wrote: However, in order to help me understand, would you be so kind as to give me a matrix or data.frame example

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread Frederic Ntirenganya
Hi All, Sorry for the shape of data which was not good enough.This is how my data look like. I want to plot multiple using ggplot function from a data frame of many columns. I want to plot only Start.of.Rain..i., Start.of.Rain..ii. and Start.of.Rain..iii. and I failed to make it. What I want

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread Jeff Newmiller
By failing to take the advice given to you, you make it harder to help you. Learn to control your email program to send plain text, and learn to use the dput function. With regard to this function call: ggplot(df2, aes(Date,value)) + I highly recommend using named parameters in the aes call.

[R] MethComp exported object namespace error

2015-03-31 Thread Kylie Lange
Hi everyone, I am using the MCmcmc function of the MethComp package and receive the following error: Error: 'coda.samples' is not an exported object from 'namespace:coda' I emailed the package author last week but haven't had a reply. I have installed JAGS 3.4.0 as required by MethComp. I am

Re: [R] Error in lm() with very small (close to zero) regressor

2015-03-31 Thread RiGui
I found a fix to my problem using the fastLm() from package RcppEigen, using the Jacobi singular value decomposition (SVD) (method 4) or a method based on the eigenvalue-eigenvector decomposition of X'X - method 5 of the fastLm function install.packages(RcppEigen) library(RcppEigen) n_obs -

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread Frederic Ntirenganya
Hi All, Thanks for the help. I want to plot some of the columns on the same graph not all of them. Sorry, I failed to follow the instructions. Here is the output of *dput()* but I don't know how it works. dput(head(data))structure(list(Date = structure(c(-6575, -6209, -5844, -5479, -5114,

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread stephen sefick
The error message is very informative. You named a column in the melted data Start, and told ggplot to use start. start is a function. R is case sensitive. On Tue, Mar 31, 2015 at 8:46 AM, Frederic Ntirenganya ntfr...@gmail.com wrote: Hi All, Thanks for the help. I want to plot some of the

Re: [R] Plotting using tapply function output

2015-03-31 Thread John Kane
Reproducibility https://github.com/hadley/devtools/wiki/Reproducibility http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: amc5...@gmail.com Sent: Mon, 30 Mar 2015 16:07:05 -0700 To:

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread John Kane
Hi Frederic, Thanks for sending the data in dput() format. All it does in convert a data set into a standardized format (perfect copy) that anyone with R can read. People have different setups and defaults for reading data and so on and what you may read in to R as a character variable may be

Re: [R] Calculating Kendall's tau

2015-03-31 Thread Bert Gunter
This sounds like homework. Homework is discouraged on this list (but you might get lucky). Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. Clifford Stoll On Tue, Mar 31,

Re: [R] Error in lm() with very small (close to zero) regressor

2015-03-31 Thread William Dunlap
If you really want your coefficient estimates to be scale-equivariant you should test those methods for such a thing. E.g., here are functions that let you check how scaling one predictor affects the estimated coefficients - they should give the same results for any scale factor. f - function

Re: [R] Calculating Kendall's tau

2015-03-31 Thread Bert Gunter
OK. But always reply to the list (which I am ccing here) so that everyone knows -- and re-submit your OP in **PLAIN TEXT**, not html, as this is a plain text list and html typically garbles everything. Also, reading and following the posting guide (see end of this email) generally improves your

[R] Calculating Kendall's tau

2015-03-31 Thread Desta Yoseph via R-help
I am analyzing trend  using Mann-kendall  test for 31 independent sample, each sample  have 34 years dataset.  I supposed to find Kendall “tau” for each sample. The data is arranged in column wise (I attached  the data).To find Kendall tau, I wrote R script as:      desta-read.csv(rainfall.csv,

Re: [R] changing column labels for data frames inside a list

2015-03-31 Thread r-help
Date: Mon, 30 Mar 2015 09:54:39 -0400 From: Vikram Chhatre crypticline...@gmail.com To: r-help@r-project.org Subject: [R] changing column labels for data frames inside a list Message-ID: CAJZnH0=uGay_1VzjVTMMc=fweydkdjxm_tpi4hzo-ardztr...@mail.gmai Content-Type: text/plain;

Re: [R] how to deal with changing weighting functions

2015-03-31 Thread Adams, Jean
Can you give a concrete simple example of inputs with expected results? Is phi a function? Of omega 1 and 2? Is the summation over everything through V_d-k? On Mon, Mar 30, 2015 at 2:58 PM, T.Riedle tr...@kent.ac.uk wrote: Hi everybody, Does anybody have an idea how I can generate tau

[R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Kevin E. Thorpe
Hello. I am trying to simulate recruitment in a randomized trial. Suppose I have three streams (strata) of patients represented by these data frames. df1 - data.frame(strat=rep(1,10),id=1:10,pid=1001:1010) df2 - data.frame(strat=rep(2,10),id=1:10,pid=2001:2010) df3 -

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread Frederic Ntirenganya
Hi John, Sorry for the mistake I made for providing useless data. Here I am interest only on Tmin and Tmax columns. I want to use the same approach with the previous data. I want to plot on the same graph not separate graph. Thanks dput(head(BUTemp))structure(list(Year = c(1971L, 1971L, 1971L,

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread John Kane
I think we need some data and code Reproducibility https://github.com/hadley/devtools/wiki/Reproducibility http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example John Kane Kingston ON Canada -Original Message- From: r...@catwhisker.org Sent: Mon,

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread Tom Wright
Nice clean-up!!! On Tue, 2015-03-31 at 14:19 -0400, Ista Zahn wrote: library(tidyr) library(dplyr) bw - gather(bw, key = tmp, value = value, matches(^d[a-z]+[0-9]+)) bw - separate(bw, tmp, c(disc, var), _, extra = merge) bw - spread(bw, var, value)

[R] How to obtain a cross tab count of unique values

2015-03-31 Thread Walter Anderson
I have a data frame that shows all of the parks (including duplicates) that are impacted by a projects 'footprint': PROJECT PARKNAME A PRK A A PRK B A PRK A B PRK C B PRK A C PRK B C PRK D ... What I need is a cross tabulation that shows me the number of

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread Tom Wright
Not entirely sure I understand your problem here (your first email was a lot of reading). Would it make sense to add an extra column device_name Thus ending up with something like: Host Device Type host_Aada0ssd host_Aada1ssd host_Aada2hdd ... host_Nda3 ssd

Re: [R] idiom for constructing data frame

2015-03-31 Thread Ista Zahn
You can make it as elegant as you want, e.g., make.empty.df - function(nrow,ncol, names) { if(length(names) %% ncol != 0) stop(Lenght of names is not a multiple of the number of colums) data.frame(matrix(NA, nrow, ncol, dimnames = list(NULL, names))) } Best, Ista On Tue, Mar 31, 2015

Re: [R] idiom for constructing data frame

2015-03-31 Thread William Dunlap
You can use structure() to attach the names to a list that is input to data.frame. E.g., dfNames - c(First, Second Name) data.frame(lapply(structure(dfNames, names=dfNames), function(name)rep(NA_real_, 5))) Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Mar 31, 2015 at 11:37 AM, Sarah

Re: [R] idiom for constructing data frame

2015-03-31 Thread Sarah Goslee
Hi, Duncan Murdoch suggested: The matrix() function has a dimnames argument, so you could do this: names - c(strat, id, pid) data.frame(matrix(NA, nrow=10, ncol=3, dimnames=list(NULL, names))) That's a definite improvement, thanks. But no way to skip matrix()? It just seems unRlike,

[R] Does fitCopula work for amhCopula and joeCopula?

2015-03-31 Thread Laura Gianfagna
Good evening, this is a part of my Routine which calculates the copula parameter and loglikelihood for each pair of rows of a data matrix, choosing, for each pair, the copula which gives the maximum likelihood. If I do my computation with this routine with only: f - frankCopula(2,2) g -

[R] Fwd: non-conformable arguments

2015-03-31 Thread Soheila Khodakarim
Dear All, I want to run neural network on my data. i run these codes: #load mydata dim(mydata) # 20 3111 library(neuralnet) fm - as.formula(paste(resp ~, paste(colnames(mydata)[1:3110], collapse=+))) out - neuralnet(fm,data=mydata, hidden = 4, lifesign = minimal, linear.output = FALSE,

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Duncan Murdoch
On 31/03/2015 1:05 PM, Kevin E. Thorpe wrote: Hello. I am trying to simulate recruitment in a randomized trial. Suppose I have three streams (strata) of patients represented by these data frames. df1 - data.frame(strat=rep(1,10),id=1:10,pid=1001:1010) df2 -

Re: [R] idiom for constructing data frame

2015-03-31 Thread Sarah Goslee
I just snagged this from Duncan Murdoch's reply to the same question: # Create an empty dataframe to hold the results df - data.frame(strat=NA, id=NA, pid=NA)[rep(1, length(sel)),] This skips matrix(), but how to set the column names programmatically within a function? Sarah, still sure I'm

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Nordlund, Dan (DSHS/RDA)
-Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kevin E. Thorpe Sent: Tuesday, March 31, 2015 10:53 AM To: Duncan Murdoch Cc: R Help Mailing List Subject: Re: [R] Randomly interleaving data frames while preserving order On 03/31/2015 01:44 PM,

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Kevin E. Thorpe
On 03/31/2015 01:44 PM, Duncan Murdoch wrote: On 31/03/2015 1:05 PM, Kevin E. Thorpe wrote: Hello. I am trying to simulate recruitment in a randomized trial. Suppose I have three streams (strata) of patients represented by these data frames. df1 -

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread David Wolfskill
On Tue, Mar 31, 2015 at 07:11:28AM -0800, John Kane wrote: I think we need some data and code Reproducibility https://github.com/hadley/devtools/wiki/Reproducibility http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example I apologize for failing to

[R] idiom for constructing data frame

2015-03-31 Thread Sarah Goslee
Hi folks, I KNOW there has to be a way to do this more elegantly, but I consistently fail to come up with it, as I was just reminded while writing an example for a query on this list. What's a nifty way to construct a data frame of a given size? The only way I know of it to use matrix(), eg

Re: [R] idiom for constructing data frame

2015-03-31 Thread Duncan Murdoch
On 31/03/2015 1:52 PM, Sarah Goslee wrote: I just snagged this from Duncan Murdoch's reply to the same question: # Create an empty dataframe to hold the results df - data.frame(strat=NA, id=NA, pid=NA)[rep(1, length(sel)),] This skips matrix(), but how to set the column names programmatically

Re: [R] data.frame: data-driven column selections that vary by row??

2015-03-31 Thread Ista Zahn
Hi David, I suggest reading http://www.jstatsoft.org/v59/i10, then: library(tidyr) library(dplyr) bw - gather(bw, key = tmp, value = value, matches(^d[a-z]+[0-9]+)) bw - separate(bw, tmp, c(disc, var), _, extra = merge) bw - spread(bw, var, value) Best, Ista On Tue, Mar 31, 2015 at 1:22 PM,

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Sarah Goslee
That's a fun one. Here's one possible approach. (Note that it can be done without using a loop, but I find that a loop here increases readability.) I wrote it to work on a list of data frames. If the selection is random, I'd set it up so that size is passed to the function, but selection is

Re: [R] Randomly interleaving data frames while preserving order

2015-03-31 Thread Tom Wright
samples-sample(c(rep(1,10),rep(2,10),rep(3,10)),30) samples[samples==1]-1001:1010 samples[samples==2]-2001:2010 samples[samples==3]-3001:3010 fullDf-rbind(df1,df2,df3) fullDf[sort(order(samples),index.return=TRUE)$ix,] On Tue, 2015-03-31 at 13:05 -0400, Kevin E. Thorpe wrote: Hello. I am

Re: [R] How to obtain a cross tab count of unique values

2015-03-31 Thread Tom Wright
table(unique(df)$PROJECT) On Tue, 2015-03-31 at 14:51 -0500, Walter Anderson wrote: I have a data frame that shows all of the parks (including duplicates) that are impacted by a projects 'footprint': PROJECT PARKNAME A PRK A A PRK B A PRK A B PRK C B PRK A

Re: [R] Debug package options

2015-03-31 Thread Keith S Weintraub
Duncan, Thanks for the help. Since I am the only person using this machine and I couldn’t figure out where to put the option statement aside from: C:\Program Files\R\R-3.1.2\etc In the file Rprofile.site The option that I wanted was: options(debug.font = Consolas 12”) Which allowed me to

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread stephen sefick
Your data and post is still not provided in one of the formats provided here: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. I am unsure of what you want to do, but I have made a reproducible example that might help. zz - Date Number.of.Rain.Days Total.rain

Re: [R] Multiple Plots using ggplot

2015-03-31 Thread John Kane
The data you supplied is still in a useless format. Please send it to us in dput format (and don't post in html) Here is a complete example of creating a data.frame and converting it to a useable data set that readers on R-help can use ##=Start Example===## # Simple

Re: [R] Using matlab code in R

2015-03-31 Thread Jeff Newmiller
The Posting Guide recommends searching the archives before posting. Consider [1] and learn. [1] https://stat.ethz.ch/pipermail/r-help/2007-March/127981.html --- Jeff NewmillerThe . .

Re: [R] idiom for constructing data frame

2015-03-31 Thread Sarah Goslee
On Tue, Mar 31, 2015 at 6:35 PM, Richard M. Heiberger r...@temple.edu wrote: I got rid of the extra column. data.frame(r=seq(8), foo=NA, bar=NA, row.names=r) Brilliant! After much fussing, including a disturbing detour into nested lapply statements from which I barely emerged with my sanity

Re: [R] idiom for constructing data frame

2015-03-31 Thread Sven E. Templer
If you don't mind an extra column, you could use something similar to: data.frame(r=seq(8),foo=NA,bar=NA) If you do, here is another approach (see function body): empty.frame - function (r = 1, n = 1, fill = NA_real_) { data.frame(setNames(lapply(rep(fill, length(n)), rep, times=r), n)) }

Re: [R] How to obtain a cross tab count of unique values

2015-03-31 Thread Rui Barradas
Hello, Try the following. table(unique(df)$PROJECT) And please note that 'df' is the name of an R function, use something else. Hope this helps, Rui Barradas Em 31-03-2015 20:51, Walter Anderson escreveu: I have a data frame that shows all of the parks (including duplicates) that are

Re: [R] How to obtain a cross tab count of unique values

2015-03-31 Thread Sarah Goslee
Sure: tell R you want unique rows. mydf - data.frame(PROJECT=c(A,A,A,B,B,C,C), PARKNAME=c(PRK A, PRK B, PRK A, PRK C, PRK A, PRK B, PRK D), stringsAsFactors=FALSE) mydf PROJECT PARKNAME 1 APRK A 2 APRK B 3 APRK A 4 BPRK C 5 BPRK A 6

Re: [R] idiom for constructing data frame

2015-03-31 Thread Richard M. Heiberger
I got rid of the extra column. data.frame(r=seq(8), foo=NA, bar=NA, row.names=r) Rich On Tue, Mar 31, 2015 at 6:18 PM, Sven E. Templer sven.temp...@gmail.com wrote: If you don't mind an extra column, you could use something similar to: data.frame(r=seq(8),foo=NA,bar=NA) If you do, here is

Re: [R] Can not load Rcmdr

2015-03-31 Thread a b
I have a similar issue with tcl. I am using R on a Linux server. Rcmdr installed OK, but it won't run: R.Version() $platform [1] x86_64-unknown-linux-gnu $arch [1] x86_64 $os [1] linux-gnu $system [1] x86_64, linux-gnu $status [1] $major [1] 3 $minor [1] 1.0 $year [1] 2014 $month [1]

[R] Calculating different PCAs in R

2015-03-31 Thread im db
Dear All, I want to use princomp() function in R in order to calculate Principle Component Analysis.In different papers, I have seen PCA 1, PCA 2, PCA 11 , etc. Would you please tell me how can i calculate different PCAs in R?At the moment i just use this line eigenVectors - pca$loadingsBut I

[R] Using matlab code in R

2015-03-31 Thread T.Riedle
Hi everybody, I have a matlab code which I would like to use for my empirical analysis. Unfortunately, I am not familiar with matlab and it would be great if there was a tool to translate the matlab code into R so that I can work with the code in R. Is there such a tool or package in R? Kind

Re: [R] idiom for constructing data frame

2015-03-31 Thread Henrik Bengtsson
I've got dataFrame() in R.utils for this purpose, e.g. df - dataFrame(colClasses=c(a=integer, b=double, c=character), nrow=10L) str(df) 'data.frame': 10 obs. of 3 variables: $ a: int 0 0 0 0 0 0 0 0 0 0 $ b: num 0 0 0 0 0 0 0 0 0 0 $ c: chr ... Related: You can use the