[R] .R file

2010-10-25 Thread zhiji19

Hello everyone

Can you please teach me how to save my homework as .R file?

I write my code in RGui. When I tried to save my work, the RGui only allows
me to save it as .RData.

By the way, after I save my work as .RData, I cannot reopen it. when I open
it, only one message comes out as following: ARGUMENT_ignored_.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-file-tp3009812p3009812.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 save R file into specific type

2010-10-25 Thread zhiji19

Hello everyone 

Can you please teach me how to save my homework as .R file? 

I write my code in RGui. When I tried to save my work, the RGui only allows
me to save it as .RData. 
Is there any difference between .R and .RData?

By the way, after I save my work as .RData, I cannot reopen it. when I open
it, only one message comes out as following: ARGUMENT_ignored_.  

-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-save-R-file-into-specific-type-tp3009879p3009879.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] Exponent of sqr symmetric matrix

2010-11-07 Thread zhiji19

Dear R experts,

I really have difficulty when I try to deal with this question.

suppose X is a square symmetric matrix. The exponent of X is defined by the
matrix limit as following:
exp(X) = lim (I + X/n)^n,  note: the limit is from n to infinite.

How can I write R function for the above?

Thank you very much

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Exponent-of-sqr-symmetric-matrix-tp3031436p3031436.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] Help with Iterator

2010-11-09 Thread zhiji19

Dear Experts,

The following is my Iterator. When I try to write a new function with
itel, I got error. 

This is what I have: 
 supDist-function(x,y) return(max(abs(x-y)))
 
 myIterator - function(xinit,f,data=NULL,eps=1e-6,itmax=5,verbose=FALSE) {
+ xold-xinit
+ itel-0
+ repeat {
+   xnew-f(xold,data)
+   if (verbose) {
+ cat(
+ Iteration: ,formatC(itel,width=3, format=d),
+ xold: ,formatC(xold,digits=8,width=12,format=f),
+ xnew: ,formatC(xnew,digits=8,width=12,format=f),
+ \n
+ )
+ }  
+ if ((supDist(xold,xnew)  eps) || (itel == itmax)) {
+   return(xnew)
+ }
+   xold-xnew; itel-itel+1
+   }
+ }

 mat-function (x, data=NULL) {return (1+x^itel)}
 myIterator(3, f=mat, verbose=TRUE)
Error in f(xold, data) : object 'itel' not found


Can anyone please help me to fix the error?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-Iterator-tp3033254p3033254.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] Exponent of asymmetric matrix

2010-11-09 Thread zhiji19

Dear Experts,

the exponent of asymmetric matrix makes me very curious.
can anyone please explain to me what will happen if we apply exponent to
the asymmetric matrix?

Thank you very much 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Exponent-of-asymmetric-matrix-tp3035374p3035374.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] matrix limit

2010-11-09 Thread zhiji19

Dear experts,

I need to write R code for lim(I+X/n)^n with repeat loop. (note: limit is
n from 1 to infinity, I is identity matrix, X is square symmetric matrix)
Can anyone please provide help with my question.

Thank you. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/matrix-limit-tp3035508p3035508.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 this SAS transport file in R?

2010-12-05 Thread zhiji19

Dear All, 

I try to read the SAS transport file in R, but it shows error. Please help!
I am using R 2.11.1 

library(foreign) 
download.file(http://isites.harvard.edu/fs/docs/icb.topic35387.files/demo_c.xpt,C:/Desktop/demo_c.xpt;)
 
sasxport - read.xport(C:/Desktop/demo_c.xpt) 

Error in lookup.xport(file) : file not in SAS transfer format  


-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-this-SAS-transport-file-in-R-tp3073969p3073969.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] Loading .RData from Internet

2010-12-06 Thread zhiji19

Dear All,

Can you please suggest me a correct way to load the following R data frame
from the internet and save it to the hard drive?

The following is what I tried:
 raceprofiling -
 read.table(http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData;)
 save(raceprofiling, file = 'raceprofiling.RData')

However, when I used dim() to check the dataset, I got:
 dim(raceprofiling)
[1] 11085  1

The correct dimension should be 5000 and 10.

Many Thanks.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Loading-RData-from-Internet-tp3074103p3074103.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] Loading .RData from Internet

2010-12-06 Thread zhiji19

I tried the load() already. It does not work. The erro is shown as following:

Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
  cannot open compressed file
'http://rss.acs.unt.edu/Rdoc/library/twang/data/raceprofiling.RData',
probable reason 'Invalid argument'

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Loading-RData-from-Internet-tp3074103p3074162.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] Summing up Non-numeric column

2010-12-07 Thread zhiji19

Dear All

If I have the following dataset

V1 V2
x   y
y   x
z   b
a   c
b   j
d   l
c   o

How do I use R command to get the total number of different letter in column
V1
column V1 has 7 different letters.

Thank you
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Summing-up-Non-numeric-column-tp3077710p3077710.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] Summing up Non-numeric column

2010-12-07 Thread zhiji19

Thanks a lot
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Summing-up-Non-numeric-column-tp3077710p3077733.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.