for i from 1 to 3]]>

appendInfoLine("appendInfoLine: ",i)

printline printline: 'i'

endfor

This produces the following output in the info window:

appendInfoLine: 1

printline: 1

appendInfoLine: 2

printline: 2

appendInfoLine: 3

printline: 3

but the following in my terminal:

appendInfoLine: 1

printline: 1

appendInfoLine: 1

appendInfoLine: 2

printline: 2

appendInfoLine: 1

appendInfoLine: 2

appendInfoLine: 3

printline: 3

I've been looking for a Ipython-notebook style workspace for R, and here are some great resources in using Rmd to generate R reports in HTML including source code and results:

- http://www.rstudio.com/ide/docs/authoring/using_markdown
- http://www.rstudio.com/ide/docs/authoring/markdown_notebooks

As I was experimenting with it, there are two choices you can do.

1. you can create a rmd document from scratch, this is nice if you are writing a report, so that you can put things that are worth showing only, and it's simpler than writing in html.

2.you can also just do the normal thing in which you have a plain .r file with codes and comments in it. just make sure everything can compile in this file, and then you can use the button on the far right in r-studio editor window to automatically generate a html file with all results and plots in it.

]]>

> m <- matrix(1:4, 2)

> m [,1] [,2]

[1,] 1 3

[2,] 2 4

> i <- matrix(c(1, 1, 2, 2), 2, byrow = TRUE)

> i [,1] [,2]

[1,] 1 1

[2,] 2 2

> m[i]

[1] 1 4

Negative indices are not allowed in indexing matrices. NA and zero values are allowed: rows in an index matrix containing a zero are ignored, whereas rows containing an NA produce an NA in the result.

consult:http://cran.r-project.org/doc/manuals/r-release/R-lang.html#Indexing-matrices-and-arrays

In general, above is the case where i is two dimensional and specifies the row and column number for m. but, if i is three dimensional, then m[i] list the elements of m by a numbering by row, then by column:

1 2 3

4 5 6

7 8 9

if

>m <- matrix(10:18, 3)

>i <- matrix(c(1:9), 3, byrow=TRUE)

>m[i]

[1] 10 11 12 13 14 15 16 17 18 NA

then switch:

>i <- matrix(c(1:9), 3)

> m[i]

[1] 10 11 12 13 14 15 16 17 18

log file: see here]]>

- http://math.usask.ca/~longhai/software/installrpkg.html

1.Download the add-on R package, say

Here substitute 'mypkg' with the name of your downloaded file, in my case, RWeka_0.4-18.tar.

Then, the last path is your R library path. To get your library path, use this command(in R environment, for reference see

http://stat.ethz.ch/R-manual/R-devel/library/base/html/libPaths.html):

[1] "/Library/Frameworks/R.framework/Resources/library"

in my case, the last line above showed the path to my library. Just use that as /my/own/R-packages/ path. Then you're all set.

In my case, it showed that RWeka cannot find two dependencies:rJava and RWekajars. I need to download and install those two first, using the same method. Then you can smoothly install RWeka.

attachment:log file (see the very last portion for correct operations)]]>

+ return(factorial(n)/(factorial(n-k)*factorial(k)))

call hello:

> hello(5,3)

[1] 10

]]>

return float(sum(data))/len(data)

...

def flip(N):

N=1000

f=flip(N)

print mean(f)

]]>

writeInfo()]]>

#String function works with Chinese characters in Linux (Ubuntu)

fileName$="02 你好大家好"

a$=right$(fileName$,2)

printline 'a$'

#Regular Expression doesn't work with Chinese characters, but works with English in Linux (Ubuntu)

length=length(fileName$)

a=rindex_regex (fileName$, "\d")

printline a='a'

b$="02 Next time"b=rindex_regex (b$, "\d")

printline b='b'

#output:家好(correct),a=8(wront),b=2(correct)

http://en.wikipedia.org/wiki/Fourier_transform

]]>