[R] Updating a worksheet in Excel file using RODBC

2007-03-23 Thread Moshe Olshansky
, : [RODBC] ERROR: Could not SQLExecDirect 37000 -3553 [Microsoft][ODBC Excel Driver] Syntax error in field definition. Am I doing it wrong way or is there a problem with the Excel driver? Thank you in advance, Moshe Olshansky Chimaera Capital Group Moshe Olshansky Chimaera Capital Limited Level 4

Re: [R] Updating a worksheet in Excel file using RODBC

2007-03-26 Thread Moshe Olshansky
: Saturday, 24 March 2007 3:44 AM To: Moshe Olshansky Cc: R Help Subject: Re: [R] Updating a worksheet in Excel file using RODBC Hi, 2007/3/23, Moshe Olshansky [EMAIL PROTECTED]: Hello! I have no problem reading Excel files (each worksheet in the file is a table which can be read - at least in my

[R] Updating a worksheet in Excel file using RODBC

2007-03-26 Thread Moshe Olshansky
. manually create an Excel file with a small VBA macro, make many copies of this file (under appropriate names), write an appropriate data to each file and then the macro will work on the right data (different for each file). Thanky you! Moshe. Moshe Olshansky Chimaera Capital Limited

Re: [R] Updating a worksheet in Excel file using RODBC

2007-03-26 Thread Moshe Olshansky
that there was no such table! -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Tuesday, 27 March 2007 4:44 PM To: Moshe Olshansky Cc: [EMAIL PROTECTED] Subject: Re: Updating a worksheet in Excel file using RODBC Yes, sqlDrop does not work correctly for Excel worksheet

[R] Creating an Access (.mdb) database using R

2007-06-07 Thread Moshe Olshansky
Hello! I have a short question: Is it possible to create a (non-existing) Access database using R (and if yes, how)? I need to create a new database and then insert a few tables into it. Thank you in advance, Moshe Olshansky [EMAIL PROTECTED] __ R

Re: [R] Stock Price Correlation to Index Price Levels

2007-06-13 Thread Moshe Olshansky
). Hope this helps, Moshe Olshansky. __ R-help@stat.math.ethz.ch 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

Re: [R] Appropriate regression model for categorical variables

2007-06-13 Thread Moshe Olshansky
). Regards, Moshe Olshansky [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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

[R] Responding to a posting in the digest

2007-06-14 Thread Moshe Olshansky
Is there a convenient way to respond to a particular posting which is a part of the digest? I mean something that will automatically quote the original message, subject, etc. Thank you! Moshe Olshansky [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch

Re: [R] if within a function

2007-06-20 Thread Moshe Olshansky
Hi Yuchen, In R, if you do not put an explicit return statement in the function, the value the function returns is the value of the last statement in the function. Unlike VB, it does not matter whether you assign this value to aaa (which is identical to your function name) or b or c or x etc. So

[R] Speed up R

2007-06-21 Thread Moshe Olshansky
a few minutes! Languages like R and Matlab are extreemely convenient but if performance is a very important issue you shoul use C, Fortran, C++, etc. Regards, Moshe Olshansky. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman

Re: [R] Binary decision problem

2007-06-21 Thread Moshe Olshansky
Hi Tolga, I do not see any problem with: max {a1*x1 + a2*x2 + ... + a800*x800} subject to: x1+x2+ ... + x800 = 100 b1*x1+b2*x2+ ... +b800*x800 = B c1*x1+c2*x2+ ... +c800*x800 = C and an additional condition that x1,x2,...,x800 are binary 0-1. Regards, Moshe Olshansky --- Tolga Uzuner [EMAIL

Re: [R] anova on data means

2007-06-21 Thread Moshe Olshansky
An ugly solution (but which works) would be something like this (assuming that d is a data.frame with 4 columns named Tank, Trt, Fish, Size): x -1:12 for (i in 1:12) x[i] - mean(d$Size[d$Tank == i]) Regards, Moshe Olshansky --- Ronaldo Reis Junior [EMAIL PROTECTED] wrote: Em Quinta 21 Junho

Re: [R] sorting data

2007-06-21 Thread Moshe Olshansky
Try ReadWriteXls package from CRAN. --- dala [EMAIL PROTECTED] wrote: I have a 2 columns, Date and Number, in Excel. I copy and paste them into Notepad. I can use scan() to import the file but how do I plot this data with Date as the x-axis? -- View this message in context:

Re: [R] R-excel

2007-06-25 Thread Moshe Olshansky
Also try xlsReadWrite package on CRAN. --- Erika Frigo [EMAIL PROTECTED] wrote: Good morning to everybody, I have a problem : how can I import excel files in R??? thank you very much Dr.sa. Erika Frigo Università degli Studi di Milano Facoltà di Medicina Veterinaria Dipartimento

Re: [R] surprising difference in log()

2007-06-26 Thread Moshe Olshansky
This is not surprizing at all! The exact result is log(8,2) = 3, but the numerical procedure which calculates the logarithm may produce a result which is a few ULPs different from the exact one, i.e. you can get that log(8,2) = 2.99 and then floor(2.99) = 2. --- Fausto

Re: [R] Gaussian elimination - singular matrix

2007-06-27 Thread Moshe Olshansky
All the nontrivial solutions to AX = 0 are the eigenvectors of A corresponding to eigenvalue 0 (try eigen function). The non-negative solution may or may not exist. For example, if A is a 2x2 matrix Aij = 1 for 1 =i,j =2 then the only non-trivial solution to AX = 0 is X = a*(1,-1), where a is any

Re: [R] restructuring matrix

2007-06-27 Thread Moshe Olshansky
If your original matrix is A then unique(A$People) and unique(A$Desc) will produce a vector of different people and a vector of different descriptions. --- yoo [EMAIL PROTECTED] wrote: Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary

Re: [R] Optimization

2007-07-17 Thread Moshe Olshansky
This is partially true since both the function to be maximized and the constraint are non-linear. One may substitute 1-x1-x2 for x3 and use (let say) Lagrange multipliers to get two non-linear equations with 2 unknowns for which there should be a function solving them. Then you must find the

Re: [R] Date problem

2007-07-17 Thread Moshe Olshansky
Try the xlsReadWrite package from CRAN. --- Mr Natural [EMAIL PROTECTED] wrote: Dear Natalia: I have had the same problem. Solved it by keeping my dates in Excel files with the rest of my data. When I want to do something in R, highlight the date column and format it as general You will

Re: [R] Optimization

2007-07-17 Thread Moshe Olshansky
[EMAIL PROTECTED] wrote: G'day Moshe, On Tue, 17 Jul 2007 17:32:52 -0700 (PDT) Moshe Olshansky [EMAIL PROTECTED] wrote: This is partially true since both the function to be maximized and the constraint are non-linear. I am not sure what your definition of non-linear is, but in my book

Re: [R] Linear programming question

2007-07-18 Thread Moshe Olshansky
Hi Tobias, Could you please explain the role of x and y - are they somehow related to S1,S2,S3,S4? Are they constant? Are they additional variable? What was your original problem (without the slack variables)? Regards, Moshe. --- Tobias Schlottmann [EMAIL PROTECTED] wrote: Hi everybody,

Re: [R] help with heatmap - how to remove annoying X before numeric values?

2007-07-18 Thread Moshe Olshansky
Hi Suzanne, My solution (which I am sure is not the best) would be: heat - read.table('temp.txt') heat X1905 X1910 X1950 X1992 X2011 X2020 Gnat 0.08 0.29 0.29 0.37 0.39 0.43 Snake 0.16 0.34 0.32 0.40 0.41 0.53 Bat0.40 0.54 0.52 0.60 0.60 0.63 Cat0.16 0.27 0.29

Re: [R] help with heatmap - how to remove annoying X before numeric values?

2007-07-18 Thread Moshe Olshansky
I was right saying that my solution was not the best possible! --- Prof Brian Ripley [EMAIL PROTECTED] wrote: read.table('temp.txt', check.names = FALSE) would be easier (and more general, since make.names can do more than prepend an 'X'). On Wed, 18 Jul 2007, Moshe Olshansky wrote

Re: [R] Matrix Multiplication, Floating-Point, etc.

2007-07-30 Thread Moshe Olshansky
After multiplication by 10 you get 6*8 = 48 - the result is an exact machine number so there is no roundoff, while 0.6*0.8 = 0.48, where neither of the 3 numbers (0.6, 0.8, 0.48) is an exact machine mumber. However, (-0.6)*0.8 should be equal EXACTLY to -(0.6*0.8), and in fact you get that

Re: [R] how to plot a differential equation?

2007-08-01 Thread Moshe Olshansky
Hi Montserrat, What exactly would you like to plot? Your differential equation can be easily integrated so that you can get an implicit expression for F(x), i.e. expression like G(c,x,F(x)) = 0 where G is a known function and c is an arbitrary constant. For every value of c and each value of x

Re: [R] Solve equations

2007-08-06 Thread Moshe Olshansky
Hi Sebastian, Your equations can be easily solved - no programming is required! Let's number you equations: (1) 0.007= 2VZ (2) 0.03= W(Y+Z) (3) 0.034= X(y+Z) (4) 0.013 = (X+W)Y +(X-W)Z (5) X = W+V Substitute (5) into (3) and then divide (2) by (3) to get (W+V)/W = 0.034/0.03 so that (6) V =

Re: [R] simulate a null expectation

2007-08-06 Thread Moshe Olshansky
Hi Ryan, I think that the only function you need is the one which generates random variable. The simplest one is to generate a uniform (0,1) variable U and then do not move if U 0.25, move to the first nearest point if 0.25 = U 0.5, move to the second nearest point if ).5 = U 0.75 and move to

Re: [R] Spatial sampling problem

2007-08-06 Thread Moshe Olshansky
Hi SK, If I understand you correctly you are trying to assign to each point of a 10x10 2D grid a normal variable with a certain dependency between the values at each grid point. Is this correct? If so, please explain the dependence structure. Do you need something like X(i,j) = f(i,j) + Z(i,j)

Re: [R] small sample techniques

2007-08-07 Thread Moshe Olshansky
Hi Nair, If the two populations are normal the t-test gives you the exact result for whatever the sample size is (the sample size will affect the number of degrees of freedom). When the populations are not normal and the sample size is large it is still OK to use t-test (because of the Central

Re: [R] XL files

2007-08-08 Thread Moshe Olshansky
Hi Animesh, Can you send an example of an Excel file you need to process (and the result you wish to get)? Regards, Moshe. --- Acharjee, Animesh [EMAIL PROTECTED] wrote: Dear All, I am new to R. I need to read XLs files, parse the data and convert them into txt format for

Re: [R] small sample techniques

2007-08-08 Thread Moshe Olshansky
: Indeed, I understand what you say. The df of freedom for the dummy example is n1+n2-2 = 8. But when I run the t.test I get it as 5.08, am I missing something? -Original Message- From: Moshe Olshansky [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 07, 2007 9:05 PM To: Nair

Re: [R] small sample techniques

2007-08-08 Thread Moshe Olshansky
Well, this an explanation of what is done in the paired t-test (and why the number of df is as it is). I was too lazy to write all this. It is nice that some list members are less lazy! --- Rolf Turner [EMAIL PROTECTED] wrote: On 9/08/2007, at 2:57 PM, Moshe Olshansky wrote: As Thomas

Re: [R] small sample techniques

2007-08-09 Thread Moshe Olshansky
PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nair, Murlidharan T Sent: Thursday, August 09, 2007 9:19 AM To: Moshe Olshansky; Rolf Turner; r-help@stat.math.ethz.ch Subject: Re: [R] small sample techniques Thanks, that discussion was helpful. Well, I have another question I am

Re: [R] binomial simulation

2007-08-13 Thread Moshe Olshansky
P(T+,D+)=P(T+|D+)*P(D+) Thank you for your reply, Sigalit. On 8/13/07, Moshe Olshansky [EMAIL PROTECTED] wrote: Hi Sigalit, Do you want to find the probability P(T+ = t AND D+ = d) for all the combinations of t and d (for ICU and Reg.)? Is the probability of false detection

Re: [R] invert 160000x160000 matrix

2007-08-13 Thread Moshe Olshansky
While inverting the matrix may be a problem, if you need to solve an equation A*x = b you do not need to invert A, there exist iterative methods which do need A or inv(A) - all you need to provide is a function that computes A*x for an arbitrary vector x. For such a large matrix this may be slow

Re: [R] binomial simulation

2007-08-15 Thread Moshe Olshansky
again, Sigalit. On 8/14/07, Moshe Olshansky [EMAIL PROTECTED] wrote: As I understand this, P(T+ | D-)=1-P(T+ | D+)=0.05 is the probability not to detect desease for a person at ICU who has the desease. Correct? What I asked was whether it is possible to mistakenly detect

Re: [R] How to write to a table column by column?

2007-08-15 Thread Moshe Olshansky
Hi Yuchen, First of all please notice that you may not have more than 2^8 = 256 columns in Excel, so if you have more than 256 time-series you can not put them all in one Excel sheet. I also believe that you can not have more than 2^16 = 65536 rows. If you do not have more than 256 time-series, I

Re: [R] binomial simulation

2007-08-15 Thread Moshe Olshansky
) ?choose choose(200,2) 19900 choose(200,100) 9.054851e+58 N=200; k=100; m=50; p=.6; q=.95 choose(N,k)*p^k*(1-p)^(N-k)*choose(k,m)*q^m*(1-q)^(k-m) 6.554505e-41 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Moshe Olshansky Sent

Re: [R] Combine matrix

2007-08-16 Thread Moshe Olshansky
This does not work in the general case. To see this, try: rownames(a}[5] - a and see what happens then. --- François Pinard [EMAIL PROTECTED] wrote: [Gianni Burgin] let say something like this a=matrix(1:25, nrow=5) rownames(a)=letters[1:5] colnames(a)=rep(A, 5) a A A A A A

Re: [R] function to find coodinates in an array

2007-08-16 Thread Moshe Olshansky
A not very good solution is as below: If your array's dimensions were KxMxN and the linear index is i then n - ceiling(i/(K*M)) i1 - i - (n-1)*(K*M) m - ceiling(i1/K) k - i1 - (m-1)*K and your index is (k,m,n) I am almost sure that there is a function in R which does this (it exists in Matlab).

[R] Fwd: Re: Combine matrix

2007-08-17 Thread Moshe Olshansky
Note: forwarded message attached. Mistakenly I did not send this to the list! ---BeginMessage--- Here is a solution which (I think) works, but it contains a loop which most likely can be eliminated by more knowledgable people): Let a and b be like in your example but to make things more

Re: [R] Partial comparison in string vector

2007-08-21 Thread Moshe Olshansky
Use grep(^e,x) if you are looking for the entries where e is the first character. --- Vladimir Eremeev [EMAIL PROTECTED] wrote: Hi! seq(along=x) %in% grep(e,x) Steve Powell-4 wrote: I have a vector of strings x=c(w,ex,ee) And I want to get a logical vector showing the

Re: [R] Calculating diameters of cirkels in a picture.

2007-08-23 Thread Moshe Olshansky
Hi Bart, I have never used image processing software in R (I was doing this with Matlab), but here is what I would have done algorithmically: 1) convert the picture to gray-scale 2) find a threshold value which separates the circles from the background and convert your image to black and white 3)

Re: [R] Choice of data.frame column by index?

2007-08-23 Thread Moshe Olshansky
This won't work since it produces a matrix (try this). What should work is x[(1:nrow(x)) + nrow(x)*(v-1)] --- Johannes Graumann [EMAIL PROTECTED] wrote: Thanks! Joh On Thursday 23 August 2007 12:01:50 you wrote: x[cbind(1:nrow(x), the.vector)] Patrick Burns [EMAIL PROTECTED]

Re: [R] Choice of data.frame column by index?

2007-08-23 Thread Moshe Olshansky
Correct, I didn't notice that the coma was inside the cbind(). Sorry... --- Rolf Turner [EMAIL PROTECTED] wrote: On 24/08/2007, at 12:51 PM, Moshe Olshansky wrote: This won't work since it produces a matrix (try this). On the contrary, Patrick's solution is correct. I tried

Re: [R] Calculating diameters of cirkels in a picture.

2007-08-23 Thread Moshe Olshansky
which touches the boundaries is the background while all other components are holes and you can make them white (1) in the original black-and-white image. --- Moshe Olshansky [EMAIL PROTECTED] wrote: Hi Bart, I have never used image processing software in R (I was doing this with Matlab

Re: [R] Calculating diameters of cirkels in a picture.

2007-08-27 Thread Moshe Olshansky
you mean with morphological closing and the labeling to split the images. Could you please clarify this a bit? Thanks for your support Bart Moshe Olshansky-2 wrote: Hi Bart, One more comment: You do not really need the morphological closing to close the holes

Re: [R] Excel

2007-08-27 Thread Moshe Olshansky
As far as I understand, changing the format changes the way data is displayed by Excel but this does not change the data itself - if while reading the data Excel decided that it was a date, it is being converted to an integer (the number of days since January 1, 1900 - and they mistakenly think

Re: [R] How to multiply all dataframe rows by another dataframe's columns

2007-08-29 Thread Moshe Olshansky
Below is one way to do this: Loc1.alleles - c(1,5,6,7,8) Loc1.Freq- c(0.35, 0.15, 0.05, 0.10, 0.35) Loc1 - cbind( Loc1.alleles,Loc1.Freq) X- data.frame(Loc1) Loc2.alleles - c(1,4,6,8) Loc2.Freq - c(0.35, 0.35, 0.10, 0.20) Loc2 -

Re: [R] element wise opertation between a vector and a list

2007-09-03 Thread Moshe Olshansky
Hi, Getting your e is not a problem: a- list(c(1,3),c(1,2),c(2,3)) b-c(10,20,30) aa-matrix(unlist(a),nrow=2) ee-aa+rbind(b,b) e-apply(ee,2,sum) e [1] 24 43 65 But this will not work if different list members have different number of elements. --- Yongwan Chun [EMAIL PROTECTED] wrote:

Re: [R] how to compute cross correlation

2007-09-03 Thread Moshe Olshansky
The simlest answer is that X and Y are two vectors of length n then (un-normalized) cross correlation between X and Y is sum(i=1 to n) {X(i)-Xbar)*(Y(i)-Ybar)} where Xbar and Ybar are the means of X and Y respectively. You may need something different, so could you be more specific? What do you

Re: [R] The quadprog package

2007-09-03 Thread Moshe Olshansky
Hi Thomas, On my computer the solution is (0,0,1,0,0,0,0) (within machine accuracy) and it satisfies the constraints. --- [EMAIL PROTECTED] wrote: Hi everybody, I'm using Windows XP Prof, R 2.5.1 and a Pentium 4 Processor. Now, I want to solve a quadratic optimization program (Portfolio

Re: [R] interpolation

2007-09-04 Thread Moshe Olshansky
If your data is in data.txt file you can do the following: x - read.table(file=data.txt,header=TRUE) t-ISOdatetime(x[,1],x[,2],x[,3],x[,4],x[,5],x[,6]) secs - as.numeric(t) So now secs represents your time in seconds and you can use any type of interpolation you wish to interpolate co2obs. ---

Re: [R] question about non-linear least squares in R

2007-09-05 Thread Moshe Olshansky
Below is one possibility: If you knew MA you would get a regular linear least-squares for parameters A,B and constant which can be easily solved. So now you can define a function f(MA) which returns that value. Now you must minimize that f - a function of one argument. It can have several local

Re: [R] SQL like function?

2007-09-07 Thread Moshe Olshansky
observation %in% ID --- Takatsugu Kobayashi [EMAIL PROTECTED] wrote: Hi RUsers, I am wonder if I can search observations whose IDs matches any of the values in another vector, such as in MySQL. While I am learing MySQL for future database management, I appreciate if anyone could give

Re: [R] Problems with strsplit

2007-09-10 Thread Moshe Olshansky
unlist(strsplit(bA531F16-rep,\\-))[1] [1] bA531F16 --- Carlos Morales [EMAIL PROTECTED] wrote: Hello, I would like to know what can I do if I use strplit with a string and I want to use the middle left,I mean I have this: strsplit(bA531F16-rep,\\-) [[1]] [1] bA531F16 rep

Re: [R] Generating Replicate Datasets (using loops or other means)

2007-09-10 Thread Moshe Olshansky
Hi Jonathan, What exactly do you mean by replication? Do you want to keep a1,b1,c1,... unchanged but have 30 different sets of random numbers? Regards, Moshe. --- VTLT1999 [EMAIL PROTECTED] wrote: Hello All, I have searched many help forums, message boards, etc. and I just can't

Re: [R] finding the minimum positive value of some data

2007-09-10 Thread Moshe Olshansky
Either min(diff(sort(x))[diff(sort(x))0]) or min(diff(sort(unique(x --- dxc13 [EMAIL PROTECTED] wrote: useRs, I am looking to find the minimum positive value of some data I have. Currently, I am able to find the minimum of data after I apply some other functions to it: x