Re: [R] Error in setwd(dir) : cannot change working directory

2011-08-30 Thread Jeff Newmiller
Unless you have a subdirectory called "dir" below the directory returned by getwd(), the command you gave would be expected to fail. Perhaps you should use an absolute directory specification? --- Jeff Newmiller The . ...

[R] Error in setwd(dir) : cannot change working directory

2011-08-30 Thread Greg Lyukshin
Hello, I got some of the R source code and not being able to Run it in RStudio. I get the error: Error in setwd("dir") : cannot change working directory I have gone through forums but nothing seemed relevant to my issue. What bugs me the most is the ("dir") that the error shows, is of those w

[R] Fitting my data to a Weibull model

2011-08-30 Thread Marcio
Hi guys, I have a data-set that fits well into a Weibull model y = a-b*exp(-c*x^d). I want to estimate the parameters of the coefficients a, b, c and d, given x and y. Can you guys help me? Just as an example, I fit the data y <- c(1,2,3,4,10,20) and x <- c(1,7,14,25,29,30) According to this mod

Re: [R] stumped on how to reorder factors

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 10:00 PM, Markus Weisner wrote: snipped long preamble: Now I have a more complicated problem and I need help. Assuming the following factor: B = as.factor(c("Engine 1", "Engine 10", "Ladder 3", "Engine 3", "Ladder 10", "Engine 10")) levels(B) I would like the fa

Re: [R] stumped on how to reorder factors

2011-08-30 Thread Peter Alspach
Tena koe Markus I think you'll have to tailor a solution specific to your case. However, the following might give you some ideas: B <- as.factor(c("Engine 1", "Engine 10", "Ladder 3", "Engine 3", "Ladder 10", "Engine 10")) summary(B) Engine 1 Engine 10 Engine 3 Ladder 10 Ladder 3 1

Re: [R] Multivariate Normal: Help wanted!

2011-08-30 Thread meddee
djmuseR Sorry about that! I am using the mvtnorm package. I forgot that R has (so) many packages as it is has been a while since I last used R. Meddee -- View this message in context: http://r.789695.n4.nabble.com/Multivariate-Normal-Help-wanted-tp3779831p3780104.html Sent from the R help maili

Re: [R] Hmisc Latex Question: column headings and Major Column Headings not properly alligned

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 10:13 PM, . . wrote: By way of follow-up, here is some data and code that generates the output with headings out of alignment: Looks perfectly acceptable to me. I attached what I got when saved as a PDF which is exactly how it looks in my dvi viewer. filed0e744c.pdf

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-30 Thread Jim Holtman
get a 'traceback' at the point of the error to see how deep the stack is and what is being called. Also look at the help page for 'options' to see how to get the browser when an error ocurs; this is under 'error' on the help page. also lookup debugging under R so that you can do this yourself.

Re: [R] reading data from multiple files with multiple header

2011-08-30 Thread Jim Holtman
use readLines to read in the entire file, find your pattern of where your data starts and then write the data starting there using writeLines to a temporary file and now you can just read in that file using read.table; you will have 'skipped' the extra header data. Sent from my iPad On Aug 30,

[R] wdTable() in R2wd

2011-08-30 Thread Wang, Kevin (SYD)
Hi all, I've been using the wdTable() function from R2wd package and it's been working great. However I just tried to do the following: > table.2 WasteRebate code Chargeable (fin_map) Quantity (qty) Total [1,] "Waste" "Rebate code" "CHG"

[R] Question about paste

2011-08-30 Thread Andra Isan
Hello All,  I have a data frame called train.data which has 100 columns. I am using an statistical package to learn a model and the format of using that package is as follows: ex5 <- stepFlexmix(cbind(y,1-y)~x|id2, data=NPreg, k=2, model=FLXMRglm(family="binomial"), nrep=5) the

Re: [R] Hmisc Latex Question: column headings and Major Column Headings not properly alligned

2011-08-30 Thread . .
By way of follow-up, here is some data and code that generates the output with headings out of alignment: > dput(mytab) structure(c(1.3878, -0.7194, 0.3235, 1.6316, -0.4356, 1.8148, 2.1689, -1.3665, -0.2746, -0.5798, 0.7115, -0.1848, -0.2882, -1.2555, 1.0218, -1.0525, 0.0228, -0.412

[R] stumped on how to reorder factors

2011-08-30 Thread Markus Weisner
I am trying to reorder a factor data type so that when I plot stats associated with the factor, the ordering makes sense. For instance, if I have a factor entered as follows ... A = as.factor(c("1", "10", "3", "3", "10", "10")) levels(A) ... the ordering does not really make sense (assuming I

Re: [R] gradient function in OPTIMX

2011-08-30 Thread John C Nash
optimx uses exactly the same code as optim for BFGS. However, the call to optim in optimx is preceded by a check of the gradient at the starting values supplied using numDeriv. That is, we evaluate the gradient with gr=(user's function for gradient) and then with the grad() function from numDer

[R] reading data from multiple files with multiple headers

2011-08-30 Thread Julius Tesoro
Dear All, I have many files with a lot of headers and text at the beginning of the file. The headers are not uniform though and they contain different sizes Is there a way where I can read a table and skip all of the headers/text on top of it until I encounter a certain text pattern? Here is a

[R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-30 Thread . .
Hi all, Why I am getting, Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Thanks in advance! func <- Vectorize(function(x, a, sad, trunc=0, ...) { result <- function(x) { f1 <- function(n) { dcom <- paste("d", deparse(substitute(sad)), sep="")

Re: [R] Multivariate Normal: Help wanted!

2011-08-30 Thread Dennis Murphy
Hi: It's polite to mention from which package you extract certain functions. For example, the function dmvnorm() exists in at least the following packages (following a search from the sos package): mixtools, emdbook, klaR and mvtnorm, not to mention related functions in three other packages. Since

[R] Hmisc Latex Question: column headings and Major Column Headings not properly alligned

2011-08-30 Thread . .
Dear R users: When I create a table without Major Column headings, my *regular* column headings appear correct in the typeset latex file. The major row heading and row groups are as they should. w <- latex(mytab,title="",file="tab/my.tex",ctable=TRUE,caption="Descriptive statistics by Covar

Re: [R] convert a matrix to binaryMatrix in Recommenderlab

2011-08-30 Thread Michael Hahsler
Hi Jing recommenderlab is still under heavy development and quite far away from version 1.0-0. Here is some code to create a binaryRatingMatrix from a 0-1 matrix: library(recommenderlab) ## create a 10x10 0-1 matrix m <- matrix(sample(c(0,1),100, replace=TRUE), nrow=10, ncol=10) m ## coerce

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Simon Zehnder
Hi Rich, I do not know what u really want, because it seems to me, u want to calculate the mean of all rows, where the chemical is Arsenic?? But try this to get a little more inside: mean(chemdata$quant[chemdata$param=="Arsenic"]) The vector chemdata[chemdata$param=="Arsenic",] is a logical ve

[R] Multivariate Normal: Help wanted!

2011-08-30 Thread meddee
I have the following function, a MSE calc based on some Multivariate normals: MV.MSE<-function(n,EP,X,S){ (dmvnorm(X,mean=rep(0,2),I+S+EP)-dmvnorm(X,mean=rep(0,2),I+S))^2 + 1/n*(dmvnorm(X,mean=rep(0,2),1+S+EP/2)*det(4*pi*EP)^-.5- (dmvnorm(X,mean=rep(0,2),I+S+EP

Re: [R] putting in special characters in print statements

2011-08-30 Thread Erin Hodgess
Solved! xe <- paste("\\end{verbatim}\n",sep="") > cat(xe) \end{verbatim} > On Tue, Aug 30, 2011 at 5:31 PM, Erin Hodgess wrote: > Dear R People: > > Here is a question which probably has a very simple answer.  I want to > print "\end{verbatim}" in the output of a sink file.  If I put in > >

[R] term lists with tm package

2011-08-30 Thread Jack Tanner
I've got a sparse term list of the form term1 doc1 term2 doc1 term3 doc2 etc. I'd like to load this into a Corpus, as defined in the tm package. I was thinking that one way to do this is to iterate over the list building up the i, j, v vectors for a simple_triplet_matrix, and then to use that as

Re: [R] lubridate and intervals

2011-08-30 Thread jim holtman
There are 10 overlaps in the data: > df1<-data.frame(start=as.POSIXct(paste('2011-06-01 ',1:20,':00',sep='')), + end=as.POSIXct(paste('2011-06-01 ',1:20,':30',sep=''))) > df2<-data.frame(start=as.POSIXct(paste('2011-06-01 + ',rep(seq(1,20,2),2),':',sample(1:19,20,replace=T),sep='')), + end=as.POSI

[R] Problem resolved: thanks! RE: column names with rbind loop

2011-08-30 Thread Vining, Kelly
Thanks to both Weidong and David for the help! By implementing both of your suggestions I was able to make this work. I did end up putting header=TRUE for both read operations. --Kelly From: David Winsemius [dwinsem...@comcast.net] Sent: Tuesday, August

Re: [R] Error in evalauating a function

2011-08-30 Thread Martin Morgan
On 08/30/2011 04:19 PM, Debs Majumdar wrote: Here's the plik code I ran: plink --bfile olr_try1 --pheno p3.txt --pheno-name dnum --covar p3.txt --covar-name a4 --missing-phenotype -9 --R olr2.R The below function is contained in the olr2.R script. The data which I input is contained in the bi

Re: [R] Error in evalauating a function

2011-08-30 Thread Debs Majumdar
Here's the plik code I ran: plink --bfile olr_try1 --pheno p3.txt --pheno-name dnum --covar p3.txt --covar-name a4 --missing-phenotype -9 --R olr2.R The below function is contained in the olr2.R script. The data which I input is contained in the binary file named olr_try1. The response variable

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Rich Shepard
On Tue, 30 Aug 2011, David Winsemius wrote: That does look more workable. You might consider changing the dates with: chemadata$samp_date <- as.Date(as.character(chemdata$sample_date) ) David, I was thinking that I needed to do this. Thank you. It's now done. Good progress for the first

Re: [R] Error in evalauating a function

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 6:49 PM, Debs Majumdar wrote: Hi, I am very new to R. So, pardon my dumb question. I was trying to write my own function to run a different model (perform an ordered logistic regression) using the example in website http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.sh

[R] Error in evalauating a function

2011-08-30 Thread Debs Majumdar
Hi,   I am very new to R. So, pardon my dumb question. I was trying to write my own function to run a different model (perform an ordered logistic regression) using the example in website http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.shtml But R returns a error `R Error in eval(expr, envi

[R] putting in special characters in print statements

2011-08-30 Thread Erin Hodgess
Dear R People: Here is a question which probably has a very simple answer. I want to print "\end{verbatim}" in the output of a sink file. If I put in \end{verbatim} I get an unrecognized escape sequence. If I put in \\end{verbatim}, it runs fine, but the output is "\\end{verbatim}" How do I g

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 5:38 PM, Rich Shepard wrote: On Tue, 30 Aug 2011, David Winsemius wrote: I think you need to go back and do your input operations again with sep="|" David, Yes, that's better. I did not know of the sep option. The new results: str(chemdata) 'data.frame': 14886

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Rich Shepard
On Tue, 30 Aug 2011, David Winsemius wrote: I think you need to go back and do your input operations again with sep="|" David, Yes, that's better. I did not know of the sep option. The new results: str(chemdata) 'data.frame': 14886 obs. of 4 variables: $ site_id: Factor w/ 148 le

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 5:30 PM, Rich Shepard wrote: On Tue, 30 Aug 2011, David Winsemius wrote: It appears that your original file was delimited by "|" and your used something else, perhaps the default white-space setting? David, Yes, the csv file separator is the pipe. It is _not_ a csv

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Rich Shepard
On Tue, 30 Aug 2011, David Winsemius wrote: It appears that your original file was delimited by "|" and your used something else, perhaps the default white-space setting? David, Yes, the csv file separator is the pipe. I think you need to go back and do your input operations again with se

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Rich Shepard
On Wed, 31 Aug 2011, Tal Galili wrote: It is a bit hard to read the "summary" you are using. Consider please pasting the output of: ls.str(chemdata) Tal, Yes, summary() is inappropriate. I do want str() instead. And what that shows is: str(chemdata) 'data.frame': 14886 obs. of 1 vari

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 5:00 PM, Rich Shepard wrote: I don't find how to do what I need to do in Dalgaard or 'R Cookbook', so I'm asking here. I have a data frame with water chemistry data and I want to start exploring these data. There are three factors (site, date, chemical) associated with

Re: [R] Descriptive Stats from Data Frame

2011-08-30 Thread Tal Galili
Hi Rich, It is a bit hard to read the "summary" you are using. Consider please pasting the output of: ls.str(chemdata) Regarding your question, please start and see if this work (I'm not sure, since it seems you have made some changes to the summary output, and I am only guessing how things look

[R] Descriptive Stats from Data Frame

2011-08-30 Thread Rich Shepard
I don't find how to do what I need to do in Dalgaard or 'R Cookbook', so I'm asking here. I have a data frame with water chemistry data and I want to start exploring these data. There are three factors (site, date, chemical) associated with each measurement. The data frame looks like this:

[R] Fwd: ARMA show different result between eview and R

2011-08-30 Thread John C Frain
-- Forwarded message -- From: John C Frain Date: 30 August 2011 21:52 Subject: Re: [R] ARMA show different result between eview and R To: Young Gyu Park If you check your manuals you will find that R uses full maximum likelihood while Eviews uses an alternative non-linear method

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread Gabor Grothendieck
On Tue, Aug 30, 2011 at 4:43 PM, Gabor Grothendieck wrote: > On Tue, Aug 30, 2011 at 1:36 PM, Christopher W Ryan > wrote: >> Running R 2.13.1 on Windows XP. >> I would like to get week of the year (1-52) for each date. >> >> library(chron) >> dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/

Re: [R] RPostgreSQL Loading Issues

2011-08-30 Thread Joe Conway
On 08/30/2011 10:53 AM, Rich Shepard wrote: > Error in dyn.load(file, DLLpath = DLLpath, ...) : > unable to load shared object > '/home/rshepard/R/i486-slackware-linux-gnu-library/2.13/RPostgreSQL/libs/RPostgreSQL.so': > > libR.so: cannot open shared object file: No such file or directory > Er

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread Gabor Grothendieck
On Tue, Aug 30, 2011 at 1:36 PM, Christopher W Ryan wrote: > Running R 2.13.1 on Windows XP. > I would like to get week of the year (1-52) for each date. > > library(chron) > dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92")) Try this: as.numeric(cut(dts, "weeks")) --

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread David Winsemius
You did read jannis' reply didn't you? -- David. On Aug 30, 2011, at 2:34 PM, Christopher W Ryan wrote: Here it is with the output: library(chron) dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92")) dts [1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92 dts.chron

Re: [R] Generating a sequence of diagonal matrices

2011-08-30 Thread Joshua Wiley
Hi Meddee, Try this: dmat <- lapply(1:100, function(d) diag(d, 2)) That will give you a list of all 100 matrices. Cheers, Josh On Tue, Aug 30, 2011 at 1:00 PM, meddee wrote: > I am trying to generate a sequence of diagonal matrices. > > In the scalar case I would use something like, seq(0,10

Re: [R] RPostgreSQL Loading Issues

2011-08-30 Thread Rich Shepard
On Tue, 30 Aug 2011, Joe Conway wrote: Just a guess, but possibly because libpq.so (the postgres client library) is not being found. Joe, My initial thought, too. But, that's not it. 1) Do you have libpq.so installed on your system? 2) If so, where? 3) If it is not in a standard system lo

Re: [R] column names with rbind loop

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 3:46 PM, Vining, Kelly wrote: Thanks much for your help! This almost works. However, now I am getting the following error: for(i in all.files) { + if (i==all.files[1]) new.data <- read.table(i,header=TRUE) else { + new.data <- rbind(new.data, read.table(i))}} Error in m

[R] Generating a sequence of diagonal matrices

2011-08-30 Thread meddee
I am trying to generate a sequence of diagonal matrices. In the scalar case I would use something like, seq(0,100,by=1). How do I generalise the above for , say a 2 dimensional diagonal matrix. In other words how do I produce the series of diagonal matrices { diag(0,2),diag(1,2), diag(2,2),...,di

Re: [R] Fwd: help with "by" command

2011-08-30 Thread amalka
Thanks very much for the help. I ended up getting it to work with one small change: by(foo, foo$V2, function(foo) mean(foo$trust, na.rm=T)) thanks again, Ari -- View this message in context: http://r.789695.n4.nabble.com/help-with-by-command-tp3766285p3779622.html Sent from the R help mailing

Re: [R] gradient function in OPTIMX

2011-08-30 Thread Rubén Roa
Hi, In my package CatDyn, which uses optimx, I included the gradients of 20 version of the model involved. I estimate model parameters with numerical gradients, and at the final estimates I calculate the analytical gradients. In the simplest version of the model the analytical gradients computed

Re: [R] locate the needed columns

2011-08-30 Thread Weidong Gu
If the pattern is characterized by capital letters as your sample suggests. The following code may help df<-list() names(d) = c("A.x", "B.x", "C.x", "A.y", "B.y", "C.y") group.v<-matrix(NA,nrow=3,ncol=2) ### you may need to modify nrow and ncol for (i in 1:3) { group.v[i,]<-names(d)[grep(LETTERS[i

Re: [R] column names with rbind loop

2011-08-30 Thread Vining, Kelly
Thanks much for your help! This almost works. However, now I am getting the following error: > for(i in all.files) { + if (i==all.files[1]) new.data <- read.table(i,header=TRUE) else { + new.data <- rbind(new.data, read.table(i))}} Error in match.names(clabs, names(xi)) : names do not match pr

Re: [R] splitting into multiple dataframes and then create a loop to work

2011-08-30 Thread Nilaya Sharma
Thank you for the help. My focus was to split data frame for a different function, not lm. I could provide detail of that lengthy function instead I provided the lm function. The comment were very helpful. Thanks; NIL On Mon, Aug 29, 2011 at 3:37 PM, Dimitris Rizopoulos < d.rizopou...@erasmusmc

Re: [R] Multiple Traveling Salesperson Problem

2011-08-30 Thread Michael Hahsler
Hi Ian, There is currently no support for the mTSP in tsp. The paper Tolga Bektas, The multiple traveling salesman problem: an overview of formulations and solution procedures, Omega, 34(3), June 2006, Pages 209-219 describes some methods to reformulate a mTSP as a regular TSP. However, I ha

[R] ROC plot for KNN

2011-08-30 Thread Qian Liu
Hi I need some help with ploting the ROC for K-nearest neighbors. Since KNN is a non-parametric classification methods, the predicted value will be either 0 or 1. It will not be able to test for different cutoff to plot ROC. What is the package or functions I should use to plot ROC for KNN? Thanks

Re: [R] column names with rbind loop

2011-08-30 Thread Weidong Gu
How about to add a conditional statement to get the header from 1st file for(i in all.files) { if (i==all.files[1]) new.data <- read.table(i,header=TRUE) else { new.data <- rbind(new.data, read.table(i))}} Weidong Gu On Tue, Aug 30, 2011 at 1:42 PM, Vining, Kelly wrote: > Hello R  users. > >

Re: [R] ATSP to TSP reformulation

2011-08-30 Thread Ian Deters
It worked fabulously. Thank you so much for help and time. -- View this message in context: http://r.789695.n4.nabble.com/ATSP-to-TSP-reformulation-tp3777105p3779476.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

Re: [R] Error in f(x, ...) : could not find function "f2"

2011-08-30 Thread Uwe Ligges
On 30.08.2011 14:31, . . wrote: Hi all, I am getting the erro showed in the subject. I was strange the this becomes to happen after a computer restar. I think after the restart another function f2 was in memory and it scape from me. func<- Vectorize(FUN= function(y, frac, rate, sad, samp="

Re: [R] Why does loading saved/cached objects add significantly to RAM consumption?

2011-08-30 Thread Henrik Bengtsson
Hi. On Tue, Aug 30, 2011 at 3:59 AM, Janko Thyson wrote: > Dear list, > > I make use of cached objects extensively for time consuming computations and > yesterday I happened to notice some very strange behavior in that respect: > When I execute a given computation whose result I'd like to cache (

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread Christopher W Ryan
Here it is with the output: > library(chron) > dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92")) > dts [1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92 > dts.chron <- as.chron(dts) > dts.chron [1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92 > class(dts.chron) [1] "dates"

[R] locate the needed columns

2011-08-30 Thread Hui Du
Hi All, I have a data frame, whose colnames like "A.x, B.x, C.x, A.y, B.y, C.y". There could be many columns like this pattern. I want to compare data in columns A.x with A.y, B.x with B.y and C.x with C.y etc. Suppose my data frame is d, names(d) = c("A.x", "B.x", "C.x", "A.y",

Re: [R] rpart: apply tree to new data to get "counts"

2011-08-30 Thread Stephen Milborrow
Jay het geskryf When I have made a decision tree with rpart, is it possible to "apply" this tree to a new set of data in order to find out the distribution of observations? Ideally I would like to plot my original tree, with the counts (at each node) of the new data. Sadly, neither plot.rpart

Re: [R] ATSP to TSP reformulation

2011-08-30 Thread Michael Hahsler
Hi Ian, I checked your example again and found the problem in tsp. fix(x) seems to create column names but not row names which exposes a bug in as.ATSP in tsp. This code replicates your error message: library(TSP) x <- rbind(c(1,2,3,4), c(1,0,11,5), c(2,4,0,6), c(3,5,6,0)) colnames(x) <- 1:4

Re: [R] character vector to text with returns

2011-08-30 Thread Ben qant
David, Yes, I understand that cat() won't do what I want, but that is the only way I can illustrate what I am after. Note the phrasing in my question: '...cat() like...' Regarding assigning the paste to a variable: it produces the same error. I've already tried that. Thanks for your suggestion!

[R] lubridate and intervals

2011-08-30 Thread Justin Haynes
Hiya, maybe there is a native R function for this and if so please let me know! I have 2 data.frames with start and end dates, they read in as strings and I am converting to POSIXct. How can I check for overlap? The end result ideally will be a single data.frame containing all the columns of th

[R] RPostgreSQL Loading Issues

2011-08-30 Thread Rich Shepard
I'm starting to seriously use R and have tried to solve this issue using my reference books but I'm missing something simple. Running R-2.13.1 on Slackware-13.1. Trying to invoke RPostgreSQL so I can copy data from a postgres table to an R data-frame. I installed RPostgreSQL and the library()

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 1:36 PM, Christopher W Ryan wrote: Running R 2.13.1 on Windows XP. I would like to get week of the year (1-52) for each date. library(chron) dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92")) dts dts.chron <- as.chron(dts) dts.chron class(dts.chro

Re: [R] having trouble extracting week from chron object

2011-08-30 Thread Jannis
Well, there is no function called "weeks" in chron. Funny that the help mentions it. You can, however, use normal POSIXct objects and extract the week with: dts <- dates(c("02/27/92", "02/27/92")) dts.posx <- as.POSIXct(dts) result <- as.integer(format(dts.posx,format="%W")) HTH Jannis

Re: [R] Gradient function in OPTIMX

2011-08-30 Thread Ravi Varadhan
Hi Kathie, The gradient check in "optimx" checks if the user specified gradient (at starting parameters) is within roughly 1.e-05 * (1 + fval) of the numerically computed gradient. It is likely that you have correctly coded up the gradient, but still there can be significant differences b/w num

[R] column names with rbind loop

2011-08-30 Thread Vining, Kelly
Hello R users. This is a fairly basic question: I am concatenating data from sets of files in a directory using a loop. The column names in all files are exactly the same. My understanding is that rbind takes column names from the first file it reads. However, my output is showing that the co

Re: [R] "Negative length vector" error in simple merge

2011-08-30 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of DimmestLemming > Sent: Tuesday, August 30, 2011 10:20 AM > To: r-help@r-project.org > Subject: Re: [R] "Negative length vector" error in simple merge > > Thanks! I'd just never h

[R] having trouble extracting week from chron object

2011-08-30 Thread Christopher W Ryan
Running R 2.13.1 on Windows XP. I would like to get week of the year (1-52) for each date. library(chron) dts <- dates(c("02/27/92", "02/27/92", "01/14/92","02/28/92", "02/01/92")) dts dts.chron <- as.chron(dts) dts.chron class(dts.chron) # all of these component extractions work: months(dts.chron

Re: [R] character vector to text with returns

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 1:09 PM, Ben qant wrote: Hello, (Sorry if this is a dup post...) I need to clarify, Henrique's suggestion worked great for getting the text that I needed via cat(), but I haven't sorted out how to get cat() like output into a variable so I can pass it into the message

Re: [R] "Negative length vector" error in simple merge

2011-08-30 Thread DimmestLemming
Thanks! I'd just never heard of cbind or rbind... bit new. -- View this message in context: http://r.789695.n4.nabble.com/Negative-length-vector-error-in-simple-merge-tp3778980p3779267.html Sent from the R help mailing list archive at Nabble.com. __ R-

Re: [R] character vector to text with returns

2011-08-30 Thread Ben qant
Hello, (Sorry if this is a dup post...) I need to clarify, Henrique's suggestion worked great for getting the text that I needed via cat(), but I haven't sorted out how to get cat() like output into a variable so I can pass it into the message body variable I am using. Here is what I mean: x [1

Re: [R] R cmd build error -- "running 'zip' failed"

2011-08-30 Thread Duncan Murdoch
On 30/08/2011 11:05 AM, Pitt, Joel wrote: Hi All, My attempts to build an R package on my Windows 7 computer using R V13.0 ir R V13.1 using R CMD build --binary have been failing at the penultimate step with the error message "running 'zip' failed" coming after the procedure has completed t

[R] algorithm to merge same entries in a matrix

2011-08-30 Thread Martin Batholdy
Hi, I have the following, rather unorthodox problem: I have a matrix that looks like this: m1 <- matrix(c('a','b','d',NA,'c','c'), 2,3, byrow=TRUE) [,1] [,2] [,3] [1,] "a" "b" "d" [2,] NA "c" "c" now I would like to transform this matrix into this matrix: [,1] [,2]

Re: [R] "Negative length vector" error in simple merge

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 11:08 AM, DimmestLemming wrote: Hi, I'm trying to take a vector (length almost 2,000,000) and merge it with a data frame of the same length. I'm trying to do it solely based on index, and not any other factors. The vector is called "offense", and the data frame is jus

[R] R crash

2011-08-30 Thread Ivan Calandra
Dear users, By running the script below, R crashes systematically at the last command, namely dev.off(), on Windows 7, but not on Windows XP. I therefore don't provide a reproducible example and do not really extract the relevant parts of the script because it has most likely nothing to do wit

Re: [R] Exception while using NeweyWest function with doMC

2011-08-30 Thread Simon Zehnder
Hi Jay, first: thank u very much for your comments! U made some very important points clear. I tried immediately to write directly the sample function from trade<-as.big.matrix(matrix(sample(c(1,-1), (N+1)*K, replace=TRUE),ncol=K), backingpath=backingpath, backingfile="trade.bin",descriptorfil

[R] GMM with panel data

2011-08-30 Thread Cecilia Carmo
Hi everyone, I´m starting with GMM estimator for panel data in R. In fact I’m starting with GMM estimation with panel data, my research area is accounting and finance, so I’ve been reading many «econometric» books but I have some difficulties in applying GMM estimation. I’ve also read the

Re: [R] Help with the 'reshape' package

2011-08-30 Thread Gabor Grothendieck
On Tue, Aug 30, 2011 at 7:42 AM, Filipe Leme Botelho wrote: > Hi all, > > I am reading previous posts and guidance on the 'reshape' package in order to > solve the simple problem below. Thinking that this might be very trivial for > most of you, I thought there could be a fast solution coming fr

[R] test message

2011-08-30 Thread Gabor Grothendieck
Please ignore this message. __ 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] "Negative length vector" error in simple merge

2011-08-30 Thread DimmestLemming
Hi, I'm trying to take a vector (length almost 2,000,000) and merge it with a data frame of the same length. I'm trying to do it solely based on index, and not any other factors. The vector is called "offense", and the data frame is just called "data". I went with the simplest option: merge(data

Re: [R] character vector to text with returns

2011-08-30 Thread Ben qant
Hello, I need to clarify, Henrique's suggestion worked great for getting the text that I needed via cat(), but I haven't sorted out how to get cat() like output into a variable so I can pass it into the message body variable I am using. Here is what I mean: x [1] "a" "b" "c" "d" paste(x,collaps

[R] multi-response regression with random forest

2011-08-30 Thread Cédric Mondy
Dear list, I performed a multivariate analysis on freshwater invertebrates data. So I obtained coordinates of my samples on the axes defining the first factorial plane (F1 and F2). I would like to see if the positions on my factorial plan could be linked to levels of impairment ('low' vs 'signifi

Re: [R] url prep function (backslash issue)

2011-08-30 Thread Tyler Rinker
Duncan, Thanks. Combined with what Brian Ripley wrote it all works. For future thread searchers this worked: oldstring <- readline() C:\Users\Rinker\Desktop\Research& Law\Data\School Data 09-10 chartr("\\", "/",oldstring) Thank you both,Tyler #> Dat

Re: [R] Exception while using NeweyWest function with doMC

2011-08-30 Thread David Winsemius
On Aug 30, 2011, at 11:29 AM, Simon Zehnder wrote: Hi David, thank you very much for your advice! I updated R and all my packages. Regrettably it doesn't work yet. But, I think, that the parallel processing (using 32bit) does improve time, especially when it comes to higher dimensions:

[R] R cmd build error -- "running 'zip' failed"

2011-08-30 Thread Pitt, Joel
Hi All, My attempts to build an R package on my Windows 7 computer using R V13.0 ir R V13.1 using R CMD build --binary have been failing at the penultimate step with the error message "running 'zip' failed" coming after the procedure has completed the MD5 sums step.The same build comma

Re: [R] ATSP to TSP reformulation

2011-08-30 Thread Ian Deters
Dr. Hahsler, Thank you so much for looking at my code. I made sure that I had TSP_1.0-3 install and ran the code again (this time with "<-" instead of "=" for my assignments). I received the same response. I checked my sessionInfo and did not see anything out of the ordinary. Does anything loo

[R] RES: Help with the 'reshape' package

2011-08-30 Thread Filipe Leme Botelho
Petr, many thanks. It´s very straightforward to to deal with the package, I had different sources of revenues for same company, same month, like below, and just by adding "sum" at the end of the function it collapsed values from all sources. Very useful! Cheers cast(dta, Data~Company, value="Re

Re: [R] Showing zero frequencies with xtabs

2011-08-30 Thread Luca Meyer
Thanks Peter & Petr, It was indeed an issue of having some character variables in there. Now it works just fine. Cheers, Luca Il giorno 30/ago/2011, alle ore 10.15, peter dalgaard ha scritto: > > On Aug 30, 2011, at 10:04 , Luca Meyer wrote: > >> Hi, >> >> Does anyone know how to show zero

Re: [R] url prep function (backslash issue)

2011-08-30 Thread Duncan Murdoch
Brian Ripley told you how to do the translation, but there's another problem: On 30/08/2011 8:14 AM, Tyler Rinker wrote: [ much deleted ] When I try the function the backslash gets me again: > readyPath("C:\Users\Rinker\Desktop\Research& Law\Data\School Data 09-10") The problem is that you

Re: [R] Configuring Proxy: Proxy Authentication Required with --internet2

2011-08-30 Thread Duncan Murdoch
On 30/08/2011 3:48 AM, behave wrote: That was my first guess as well, but unfortunately this doesn't solve the problem. I is remarkably that IE requires authentification for every new instance I open (even if another instance is already open)... Any other hints? You can read about how WinINet

Re: [R] url prep function (backslash issue)

2011-08-30 Thread Tyler Rinker
Thank you Brian. When I wrote the email I typed url into the subject line by accident. I mean path. Thank you,Tyler > Date: Tue, 30 Aug 2011 14:00:22 +0100 > From: rip...@stats.ox.ac.uk > To: tyler_rin...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] url prep function (backslash

Re: [R] ATSP to TSP reformulation

2011-08-30 Thread Michael Hahsler
Hi Ian, Your example runs for me without problems. It seems that you are using an older version of TSP. Please upgrade to the latest version TSP (update to TSP_1.0-3). I am using: > sessionInfo() R version 2.13.1 (2011-07-08) Platform: i686-pc-linux-gnu (32-bit) locale: [1] LC_CTYPE=en_US.U

Re: [R] Conditional plots in the soiltexture package

2011-08-30 Thread samuel-rosa
Dear Julien It is exactly what I need. Thanks a lot. - Bc.Sc.Agri. Alessandro Samuel-Rosa Postgraduate Program in Soil Science Federal University of Santa Maria Av. Roraima, nº 1000, Bairro Camobi, CEP 97105-970 Santa Maria, Rio Grande do Sul, Brazil -- View this message in context: http://

Re: [R] Saving a graph

2011-08-30 Thread Jannis
Chang Cheng, this question has been asked on this list for several times. I would suggest you search the list archive (http://r.789695.n4.nabble.com/R-help-f789696.html or www.rseek.com) prior to posting in the future. "graph size many points pdf" would give you at least 10 threads with detail

Re: [R] url prep function (backslash issue)

2011-08-30 Thread Prof Brian Ripley
You seem to be looking for chartr("\\", "/", path) (and FAQ Q7.8) What does any of this have to do with 'url prep': URLs are never written with backslashes? On Tue, 30 Aug 2011, Tyler Rinker wrote: Greeting R Community, I am a windows user so this problem may be specific to windows. I of

[R] Error in f(x, ...) : could not find function "f2"

2011-08-30 Thread . .
Hi all, I am getting the erro showed in the subject. I was strange the this becomes to happen after a computer restar. I think after the restart another function f2 was in memory and it scape from me. func <- Vectorize(FUN= function(y, frac, rate, sad, samp="Poisson", trunc=0, ...){

  1   2   >