Re: [R] Automating R script with Windows 7

2012-03-05 Thread vincent.deluard
Hi Jim,

Please disregard my earlier post -- I have done some research and realized
the space between after "program " was the the issue. I can now open
RScript.exe from the command prompt using the abbreviated form:

C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe

>From your earlier post, I understand the structure to type in the command
prompt should be:
'Path to RScript.exe' SPACE 'Path to the .R file I want to execute'

Which should translate as the following on my machine:
C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe
\C:\Users\Vincent\Documents\temp\test.r
Yet I get the following error message:
'Fatal Error: cannot open file \C:\Users\Vincent\Documents\temp\test.r'

What am I doing wrong?

Thanks for your help!


--
View this message in context: 
http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4447406.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Automating R script with Windows 7

2012-03-05 Thread vincent.deluard
Hey Jim,

Thanks for the help. It took me a little bit of research but I got your
solution to work.
For everybody who has the same problem 

(1) remember to use the abbreviated names (no space) in folder paths:
ex: 'C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe'

(2) put the folder with the R script to run in the same location (in my
case: C:\)
C:\PROGRA~1\R\R-2.11.1\bin\RScript.exe \temp\dailyroutine.r

Using the task scheduler in Windows 7.0 is straightforward.

Vincent Deluard, CFA 

--
View this message in context: 
http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4447669.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Automating R script with Windows 7

2012-03-05 Thread vincent.deluard

Hi R-users,

I am trying to automate the daily running of a simple R script from Windows
7.
>From previous posts, I understand that this needs to be done with the task
scheduler.
I can schedule my laptop to automatically open R at a certain time, but not
to execute a script.

Secondary question: how do I save a list of R commands so that they get
executed once the file is open?
Right now, I save my code in a notepad doc and paste over in R, but there
has to be another way. I have tried saving my code as .r file using the
editor and open the file with R later but this does not seem to execute the
code.

I very much appreciate the help.

Vincent Deluard, CFA
  

--
View this message in context: 
http://r.789695.n4.nabble.com/Automating-R-script-with-Windows-7-tp4446693p4446693.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Saving run time in loop

2011-04-19 Thread vincent.deluard
Hi r users,

I am trying to compute the "moving variance" of a large matrix. I now use a
loop but I am looking for a faster solution. Here is a sample of the code.

Source= matrix(rnorm(400),ncol=100)
variances= matrix(rep(NA,4*100),ncol=100)

for (i in 1:80) {variances[,i]=apply(Source[,i:(i+80)],1,var)}

any idea? Many thanks in advance.


Vincent.

--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-run-time-in-loop-tp3462228p3462228.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Panel regression

2010-10-25 Thread vincent.deluard


Hi,

I am trying to run a panel regression where I have a matrix of observations
and a matrix of independant variables - examples would trying to predict
countries's GDP with their data on education, FDI, tax rates, over time.

For the purpose of simplicity, my data would be:

dep = matrix(rnorm(50),ncol=5) 
indep1 = matrix(rnorm(50),ncol=5)
indep2 = matrix(rnorm(50),ncol=5)

>From what I could find, the lme{nlme} function would be the function.
However, after I installed the package and I type in:

> lme(dep~indep1, indep2)
Error in model.frame.default(formula = ~indep1 + dep, data =
c(-0.63665929869261,  : 
  'data' must be a data.frame, not a matrix or an array 

I keep getting error messages even after I transform the data in a data
frame. Any idea on how I could get R to perform a simple panel regression?


Thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Panel-regression-tp3012794p3012794.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Right digits of a floating number

2010-07-27 Thread vincent.deluard


Hi all,

I am dealing with very large numbers but I am only interested in their last
digits.

> 244^244
[1] Inf

As far as I can tell, the largest number R can take has 308 digits (1+E308).
Is there a way I could see the last digits only of 244^244?

Many thanks for your help.

Vincent Deluard, CFA.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Right-digits-of-a-floating-number-tp2304210p2304210.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Anybody has experience with plotlm3d function and can help me?

2010-05-24 Thread vincent.deluard


Hi Duncan, 

I am trying to use the plotlm3d function which I believe was written by John
Fox and later modified by Jose Claudio Faria and Duncan Murdoch. It is a
great way to plot data points in a 3D environment but I do not see how to
customize the size of the axes. 

I want to plot the following data: 

> x 
 [1]  1  2  3  4  5  6  7  8  9 10 
> y 
 [1] 0.5678042 0.3986702 0.3063544 0.2554426 0.1954868 0.1238850 0.1161249
0.1689951 0.1826783 0.2406300 
> z 
 [1] 0.2558812 0.2619668 0.2585930 0.2563669 0.2588323 0.2734029 0.2770458
0.2782657 0.2850179 0.3015296 

Then i execute: 

open3d() 
plotlm3d(x, y, z, 
 surface = T, 
 model   = 'z ~ x + y', 
 xlab= 'x', 
 ylab= 'y' 
) 

The chart is beautiful but I would like to change the scale on the z-axis
to: 
seq(0.25,0.31,0.01)) 

I tried this command: 
axis(3, at=seq(0.25,0.34,0.01)) 

But it not work - my guess is that the underlying function plotlm3d needs to
modified but I cannot figure where. 

Best, 

Vincent
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Tutorial-on-rgl-Graphics-tp791589p2229309.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Tutorial on rgl Graphics

2010-05-24 Thread vincent.deluard


Hi Duncan,

I love your plotlm3d function!

I want to plot the following data:

> x
 [1]  1  2  3  4  5  6  7  8  9 10
> y
 [1] 0.5678042 0.3986702 0.3063544 0.2554426 0.1954868 0.1238850 0.1161249
0.1689951 0.1826783 0.2406300
> z
 [1] 0.2558812 0.2619668 0.2585930 0.2563669 0.2588323 0.2734029 0.2770458
0.2782657 0.2850179 0.3015296

Then i execute:

open3d() 
plotlm3d(x, y, z, 
 surface = T, 
 model   = 'z ~ x + y', 
 xlab= 'x', 
 ylab= 'y'
)

The chart is beautiful but I would like to change the scale on the z-axis
to: 
seq(0.25,0.31,0.01))

I tried this command:
axis(3, at=seq(0.25,0.34,0.01))

But it not work - my guess is that the underlying function plotlm3d needs to
modified but I cannot figure where.

Best,

Vincent. 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Tutorial-on-rgl-Graphics-tp791589p2228983.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to rank matrix data by deciles?

2010-05-13 Thread vincent.deluard



Dear Phil,

You helped me with a request to rand matrix columns by deciles two weeks
ago.

This really un-blocked me on this project but I found a little bug.

As in before, my data is in a matrix:

> madebt[1:16,1:2]
   X4.19.2010  X4.16.2010
 [1,] 26.61197531 26.58950617
 [2,]  5.72765432  5.73074074
 [3,]  5.95839506  5.9622
 [4,]  5.6433  5.6478
 [5,] 20.93814815 20.95728395
 [6,]  0.  0.
 [7,]  0.0700  0.0700
 [8,] 12.87802469 12.8689
 [9,]  3.64407407  3.64543210
[10,]  0.05037037  0.05049383
[11,] 25.59024691 25.6089
[12,]  3.47987654  3.53246914
[13,]  0.  0.
[14,] 31.39037037 31.39049383
[15,]  3.78296296  3.77641975
[16,] 13.17876543 13.19617284

The apply function will work for this sample of my data:

debtdeciles = apply(madebt[1:16,1:2],2,function(x)
cut(x,quantile(x,(0:10)/10,
na.rm=TRUE),label=FALSE,include.lowest=TRUE))

debtdeciles

 X4.19.2010 X4.16.2010
 [1,] 10 10
 [2,]  6  6
 [3,]  6  6
 [4,]  5  5
 [5,]  8  8
 [6,]  1  1
 [7,]  2  2
 [8,]  7  7
 [9,]  4  4
[10,]  2  2
[11,]  9  9
[12,]  3  3
[13,]  1  1
[14,] 10 10
[15,]  4  4
[16,]  8  8

However, it will fail for

> madebt[1:17,1:2]
   X4.19.2010  X4.16.2010
 [1,] 26.61197531 26.58950617
 [2,]  5.72765432  5.73074074
 [3,]  5.95839506  5.9622
 [4,]  5.6433  5.6478
 [5,] 20.93814815 20.95728395
 [6,]  0.  0.
 [7,]  0.0700  0.0700
 [8,] 12.87802469 12.8689
 [9,]  3.64407407  3.64543210
[10,]  0.05037037  0.05049383
[11,] 25.59024691 25.6089
[12,]  3.47987654  3.53246914
[13,]  0.  0.
[14,] 31.39037037 31.39049383
[15,]  3.78296296  3.77641975
[16,] 13.17876543 13.19617284
[17,]  0.  0.


> debtdeciles = apply(madebt[1:17,1:2],2,function(x)
+ cut(x,quantile(x,(0:10)/10,
na.rm=TRUE),label=FALSE,include.lowest=TRUE))
Error in cut.default(x, quantile(x, (0:10)/10, na.rm = TRUE), label = FALSE, 
: 
  'breaks' are not unique 

My guess is that we now have 3 "zeros" in each column. For each decile, we
cannot have more than 2 elements (total of 17 numbers in each column) and I
believe R cannot determine where to put the third "zero". Do you have any
solution for this problem?

Many thanks,

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-rank-matrix-data-by-deciles-tp2133496p2215945.html
Sent from the R help mailing list archive at Nabble.com.

__
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] tapply function with NA

2010-05-09 Thread vincent.deluard

Hi R users,

I have a matrix "m" of the type:

m
   X4.20.2010 X4.19.2010   X4.16.2010
[1,]  0.008319468 0. -0.008250825
[2,]  0.005574136 0.01816118  0.073081608
[3,] -0.047830688 0.01612903 -0.030239833
[4,]   NA NA   NA
[5,]  0.008746356 0.02848576 -0.025566107
[6,] -0.007990868 0. -0.02667

I want to get the sum of each column. Normally I would do:

apply(m,2,sum)

but I get:

> apply(m,2,sum)
X4.20.2010 X4.19.2010 X4.16.2010 
NA NA NA 

This is because of the presence of "NA" in m. How do you the equivalent of 
> sum(m[1:6,1],na.rm=TRUE)
using apply?

Many thanks!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/tapply-function-with-NA-tp2164930p2164930.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Evaluating matrices without using loops

2010-05-08 Thread vincent.deluard


Hi R users,

I am trying to set the values of elements of one matrix based on the values
of elements of another matrix.

Say I have 2 matrices, y and z.

y = matrix(rnorm(35), ncol=5)
z = matrix(rep(0,35), ncol=5)

I want z[i,j] to take a value  of y[i,j] when y[i,j] is greater than 0, and
zero otherwise.

I was able to do it using the following loop:


for(i in 1:7) 

{

for(j in 1:5) 
{

if(y[i,j]>0) {
z[i,j]=y[i,j]
} else {
z[i,j]=0}}
}

but since my dataset is very large, looping often crashes. Is there a more
elegant way I can achieve the same result?

Many thanks!!!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Evaluating-matrices-without-using-loops-tp2155574p2155574.html
Sent from the R help mailing list archive at Nabble.com.

__
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] How to rank matrix data by deciles?

2010-05-06 Thread vincent.deluard


Hi R users,

I have a matrix of data similar to:

> y=matrix(rnorm(55),ncol=5)


I would like to know to which decile each number belongs compared to the
numbers in its column.

Say y[1,1] is the third decile among y[1:11,1] and y[2,1] is in the second
decile
I would like get a matrix that would return their ranks in decile, i.e., 

y[1,1] -> 3
y[2,1] -> 2

Your help is much appreciated!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-rank-matrix-data-by-deciles-tp2133496p2133496.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.table or read.csv without row index?

2010-05-05 Thread vincent.deluard

YES IT WORKED!!!

Many thanks JiHO

 



Vincent Deluard

 <mailto:vincent.delu...@trimtabs.com> vincent.delu...@trimtabs.com

Global Equity Strategist, CFA Charter Award Pending

TrimTabs Investment Research

40 Wall Street, 28th Floor

New York, NY 10005

Phone: (+1) 646-512-5616

 

From: JiHO-2 [via R] [mailto:ml-node+2131575-1078352091-90...@n4.nabble.com] 
Sent: Wednesday, May 05, 2010 3:51 PM
To: vincent.deluard
Subject: Re: read.table or read.csv without row index?

 

> I tried as.matrix but it did not help. 

as.matrix() won't work because a matrix requires everything in it to 
be of the same type (number, character, logical etc.). You do not have 
only numbers in your data.frame, so it will convert everything to 
character strings. If you try as.matrix(temp[,-1]) it should work 
(assuming you only have characters in the first column, otherwise 
remove all non-numeric columns). 

But what you really want is to circumvent the fact that, on a 
data.frame, mean works column-wise. In fact, when you call mean() on a 
data.frame() it calls mean.data.frame(), which code you can see by 
typing its name at the prompt: 

> mean.data.frame 
function (x, ...) 
sapply(x, mean, ...) 
 

And indeed, it uses sapply() to apply the function mean to each 
column. You could have tried: 

mean.default(temp[2,2:3]) 

but this returns and error because it needs a numeric vector and does 
not automatically convert your data.frame into it. So you need: 

mean.default(as.numeric(temp[2,2:3])) 

or more simply 

mean(as.numeric(temp[2,2:3])) 

I hope that helped. Sincerely, 

JiHO 
--- 
http://maururu.net

__ 
[hidden email] 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. 



  _  

View message @ 
http://r.789695.n4.nabble.com/read-table-or-read-csv-without-row-index-tp883594p2131575.html
 
To unsubscribe from Re: read.table or read.csv without row index?, click
< (link removed) 
AwNTU4Mzk3>  here. 

 


-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-or-read-csv-without-row-index-tp883594p2131597.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
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] Read data from .csv file as a matrix

2010-05-05 Thread vincent.deluard

Hi R-users, 
 

I have a csv file that contains weather observation (rows) by days (in
columns). 

I open using: 

> temp = read.csv("Weather.csv", sep=",") 

and read: 

 X X1.Jan X2.Jan X3.Jan X4.Jan 
1  Min  2  3  4  1 
2  Max  6 10  8  6 
3 Forecast Min  3  1  1  3 
4 Forecast Max  8  7  4  9 

If I type 

mean(temp[2,2:3]) 

I get 

X1.Jan X2.Jan 
 6 10 

The same command on 

> y = matrix(1:21, ncol=7) 

> mean(y[2,2:3]) 
[1] 6.5 

Works because the data is in a matrix. I believe R stores the data from the
csv file as a data.frame with these annoying headers. So how do I convert
the data from my csv file into a matrix? 

I tried as.matrix but it did not help. 


Many many thanks! 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Read-data-from-csv-file-as-a-matrix-tp2131546p2131546.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.table or read.csv without row index?

2010-05-05 Thread vincent.deluard

Hi,

I have the same problem as Wong.

I have a csv file that contains weather observation (rows) by days (in
columns).

I open using:

> temp = read.csv("Weather.csv", sep=",")

and read:

 X X1.Jan X2.Jan X3.Jan X4.Jan
1  Min  2  3  4  1
2  Max  6 10  8  6
3 Forecast Min  3  1  1  3
4 Forecast Max  8  7  4  9 

If I type

mean(temp[2,2:3])

I get

X1.Jan X2.Jan 
 6 10 

The same command on 

> y = matrix(1:21, ncol=7)

> mean(y[2,2:3])
[1] 6.5

works because the data is in a matrix. So how do I convert the data from my
csv file into a matrix?
I tried as.matrix but it did not help.


Many many thanks! 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/read-table-or-read-csv-without-row-index-tp883594p2131537.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] / Operator not meaningful for factors

2010-05-03 Thread vincent.deluard

Hi John,

 

Thanks for responding so quickly. 

 

So I tried:

 

Test2[1:3,1:3])

'data.frame':   3 obs. of  3 variables:

 $ Date  : Factor w/ 2480 levels "A UN Equity",..: 1033 2396 613

 $ X4.20.2010: Factor w/ 1994 levels "0.24","0.33",..: 953 497 1814

 $ X4.19.2010: Factor w/ 1957 levels "0.24","0.33",..: 933 486 1779

 

But I am not sure how to interpret it.

 

The stringAsFactors = False option did not work either.

 

> Test2 <- read.table('Test2.csv', sep=",", header=TRUE, stringAsFactors=FALSE)

Error in read.table("Test2.csv", sep = ",", header = TRUE, stringAsFactors = 
FALSE) : 

  unused argument(s) (stringAsFactors = FALSE)

 

If you want to look at it, I attach a section of my data. 

 

Right now if I type:

> Test2[2,2]+1

Which should return 19.72

 

I get 

[1] NA

Warning message:

In Ops.factor(Test2[2, 2], 1) : + not meaningful for factors

 

Your help is SO appreciated!

 



Vincent Deluard

 <mailto:vincent.delu...@trimtabs.com> vincent.delu...@trimtabs.com

Global Equity Strategist, CFA Charter Award Pending

TrimTabs Investment Research

40 Wall Street, 28th Floor

New York, NY 10005

Phone: (+1) 646-512-5616

 

From: John Kane-2 [via R] 
[mailto:ml-node+2124731-1168690456-90...@n4.nabble.com] 
Sent: Monday, May 03, 2010 6:51 PM
To: vincent.deluard
Subject: Re: / Operator not meaningful for factors

 

 I think that you are correct.  R has the annoying habit of converting 
character data to factors when you don't want it
to while it is importing data.  This is because the in the option 
"stringsAsFactors" is set to TRUE for some weird
historical reasons. 

Try the command str(insert name of data) and see what happens.  It should show 
you which columns of data are being
treated as factors. 

You can convert the back to character or to numeric.  See the FAQ Part 7 "How 
do I convert factors to numeric? " or you
can use the String as options command in the read.table to FALSE 

Something like this should work, I think, but it's not tested 
read.table("C:/rdata/trees.csv", stringsAsFactors=FALSE) 





--- On Mon, 5/3/10, vincent.deluard <[hidden email]> wrote: 


> From: vincent.deluard <[hidden email]> 
> Subject: Re: [R] / Operator not meaningful for factors 
> To: [hidden email] 
> Received: Monday, May 3, 2010, 6:22 PM 
> 
> Hi there, 
> 
> This will sound very stupid because I just started using R 
> but I see you had 
> similar problems. 
> 
> I just loaded a very large dataset (2950*6602) from csv 
> into R. The format 
> is ticker=row, date=column. 
> Every time I want to compute basic operations, R returns 
> "In Ops.factor: not 
> meaningful for factors" 
> 
> I believe it is because R does not read the data as numbers 
> but I am not 
> sure. Can anybody help? 
> 
> Thanks! 
> -- 
> View this message in context: 
> http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html
> Sent from the R help mailing list archive at Nabble.com. 
> 
> __ 
> [hidden email] 
> 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. 
> 


__ 
[hidden email] 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. 



  _  

View message @ 
http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124731.html
 
To unsubscribe from Re: / Operator not meaningful for factors, click
< (link removed) 
AwNTU4Mzk3>  here. 

 


 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124759.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] / Operator not meaningful for factors

2010-05-03 Thread vincent.deluard

Hi David,

 

Thanks for the prompt answer. 

In this file, I have cut the data to the first 15 columns.

Here is the code:

 

t2 <- read.csv('Test2.csv', sep=",", header=TRUE)

> Test2[2,2]

[1] 18.72

1994 Levels: 0.24 0.33 0.49 0.53 0.65 0.67 0.72 0.76 0.88 0.9 0.94 ... 98.88

> Test2[2,2]+1

[1] NA

Warning message:

In Ops.factor(Test2[2, 2], 1) : + not meaningful for factors

 

The funny thing is that the same commands work normally for a shorter matrix 
– just the 1st 6 rows and columns.

Which led me to think it had to do with the blank cells.

But typing :

Test2 <- read.csv('Test2.csv', sep=",", header=TRUE, na.strings=" ")

does not help.

 

Your help is infinitely appreciated.

 



Vincent Deluard

 <mailto:vincent.delu...@trimtabs.com> vincent.delu...@trimtabs.com

Global Equity Strategist, CFA Charter Award Pending

TrimTabs Investment Research

40 Wall Street, 28th Floor

New York, NY 10005

Phone: (+1) 646-512-5616



From: David Winsemius [via R] 
[mailto:ml-node+2124710-750256529-90...@n4.nabble.com] 
Sent: Monday, May 03, 2010 6:35 PM
To: vincent.deluard
Subject: Re: / Operator not meaningful for factors




On May 3, 2010, at 6:22 PM, vincent.deluard wrote: 


> 
> Hi there, 
> 
> This will sound very stupid because I just started using R but I see   
> you had 
> similar problems. 
> 
> I just loaded a very large dataset (2950*6602) from csv into R. The  
> format 
> is ticker=row, date=column. 


Not a particularly precise description of what is in the data. 


> Every time I want to compute basic operations, R returns "In   
> Ops.factor: not 
> meaningful for factors" 

Code  we want to see code. All of it. 
> 
> I believe it is because R does not read the data as numbers 

Probably true. Were they dates or numbers? 

> but I am not 
> sure. Can anybody help? 

I generally read in my data  with read.table( , as.is=TRUE,   
stringsAsFactors=FALSE, ) and then convert the columns that I know   
should be numeric with as.numeric. If all of your columns should have  
been numeric, you might use the colClasses argument, perhaps along   
these lines: 

rd.obj <- read.csv(file="something", colClasses= rep("numeric",   
) ) 

-- 
David Winsemius, MD 
West Hartford, CT 

__ 
[hidden email] 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. 



  _  

View message @ 
http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124710.html
 
To unsubscribe from Re: / Operator not meaningful for factors, click
< (link removed) 
AwNTU4Mzk3>  here. 





-- 
View this message in context: 
http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124747.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] / Operator not meaningful for factors

2010-05-03 Thread vincent.deluard

Hi there,

This will sound very stupid because I just started using R but I see you had
similar problems.

I just loaded a very large dataset (2950*6602) from csv into R. The format
is ticker=row, date=column.
Every time I want to compute basic operations, R returns "In Ops.factor: not
meaningful for factors"

I believe it is because R does not read the data as numbers but I am not
sure. Can anybody help?

Thanks! 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Operator-not-meaningful-for-factors-tp791563p2124697.html
Sent from the R help mailing list archive at Nabble.com.

__
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.