I want to get the index of a particular letter, e.g.
> match(LETTERS,"G")
[1] NA NA NA NA NA NA 1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
Gives me that the letter exists, but I want it to return 6 in this case for the 6th element of the list.
...
Let's say we have the following function:
foo <- function(x)
{
line1 <- x
line2 <- 0
line3 <- line1 + line2
return(line3)
}
And that we want to change the second line to be:
line2 <- 2
How would you do that?
One way is to use
fix(foo)
And change the function.
Another way is to just write the function again....
This is a naive (and likely dumb) question, but I can't seem to get the R syntax highlighting to work with my Linux setup.
I've downloaded a r.vim file that has improved syntax highlighting, and it works on my Windows gvim setup. Does this r.vim file need to be in the /usr/share/vim/v70/syntax directory? Right now, I have it in my h...
What is the simplest possible C function for starting the R interpreter, passing in a small expression (eg, 2+2), and getting out the result? I'm trying to compile with MingW on Windows.
...
Hi all,
I am wondering if there exists in R a package/function to perform the: "Post Hoc Pair-Wise Comparisons for the Chi-Square Test of Homogeneity of Proportions" (or an equivalent of it) Which is described here:
http://epm.sagepub.com/cgi/content/abstract/53/4/951
My situation is of just making a chi test, on a 2 by X matrix. I fo...
Hi,
I installed/uninstalled java jre/jdk now many times and finally installed the older version 1.6.0_17 which is now located at "C:\Program Files\Java\jre6\bin". Now after all if I call 'java -version' within R i can see that R is looking for Java at the old path which is now wrong. The question is: Why is R looking for Java at the wro...
I have a time series of two indexes, with each row representing the closing price on the same day. I'd like to go to row 30 and lookback over the last 30 'days' and calculate the pearson correlation. And then store that value in a new vector. Then, repeat the calculation for the entire time series.
It is a trivial task in Excel, so I'm...
Hi all,
I am somewhat new to R, and i have this piece of code which generates a variable that i don't know the type for. Are there any introspection facility in R which will tell me which type this variable belongs to?
The following illustrates the property of this variable:
I am working on linear model selection, and the resource I h...
In the R scripting language, how do I write lines of text, e.g. the following two lines
Hello
World
to a file named "output.txt"?
...
Say I have an array of number
a <- c(1,2,3,6,7,8,9,10,20)
if there a way to tell R to output just the range of the continuous sequence from "a"
e.g., the continuous sequences in "a" are the following
1,3
6,10
20
Thanks a lot!
Derek
...
What happens when I call rchisq(100,1:100,1:100):
does R generate 100 numbers with df=1,ncp=1?
or does it generate 100 numbers each with df=k,ncp=k for k=1...100?
What I want to know is whether df and ncp can be vectors or not. It is not clear in the documentation (when compared with rnorm). I suspect that they can also be vectors ...
Hi all,
I am trying to read a .txt file, with Hebrew column names, but without success.
I uploaded an example file to:
http://www.talgalili.com/files/aa.txt
And am trying the command:
read.table("http://www.talgalili.com/files/aa.txt", header = T, sep = "\t")
This returns me with:
X.....ª X...ª...... X...œ....
1 12 ...
Suppose I have a matrix foo as follows:
foo <- cbind(c(1,2,3), c(15,16,17))
> foo
[,1] [,2]
[1,] 1 15
[2,] 2 16
[3,] 3 17
I'd like to turn it into a list that looks like
[[1]]
[1] 1 15
[[2]]
[1] 2 16
[[3]]
[1] 3 17
You can do it as follows:
lapply(apply(foo, 1, function(x) list(c(x[1], x[2]))), function(y...
I am new to R, can anyone help me with boxplot for a dataset like:
file1
col1 col2 col3 col4 col5
050350005 101 56.625 48.318 RED
051010002 106 50.625 46.990 GREEN
051190007 25 65.875 74.545 BLUE
051191002 246 52.875 57.070 RED
220050004 55 70 80.274 BLUE
220150008 75 ...
Hi guys,
I have a scientific paper under review, and a referee asked for my R code to be provided as a Sweave document. I've never heard of Sweave before, do you know what's the better way to do it?
Thanks a lot :-)
...
I'm running R via Rpy on a redhat linux distribution. Periodically I'll encounter this error message:
*** caught segfault ***
address (nil), cause 'unknown'
And the entire program dies right there. It usually occurs when I run a lot of regression r.lm(). But by simply running the identical code again, the problem may or may not go awa...
I'm blanking on the best way to paste a list of strings together to go into an SQL statement... I'm having trouble with the separator bar | printing at the beginning when I don't want it to:
foo = "blah"
paste_all_together = NULL
for (n in 1:4) {
paste_together = paste(foo ,sep = "")
paste_all_together = paste(paste_all_tog...
TRUE/FALSE if clauses are easily and quickly done in R. However, if the argument gets more complex, it also gets ugly very soon.
For instance:
I might want to execute different operations for a row(foo) dependent on the value in one cell (foo[1]).
Let the intervals be 0:39 and 40:59 and 60:100
Something like does not exit:
(if foo[1]...
I have a data.frame from this code:
my_df = data.frame("read_time" = c("2010-02-15", "2010-02-15",
"2010-02-16", "2010-02-16",
"2010-02-16", "2010-02-17"),
"OD" = c(0.1, 0.2, 0.1, 0.2, 0.4, 0.5) )
which produces this:
> my_df
r...
I have data that looks like this:
#val Freq1 Freq2
0.000 178 202
0.001 4611 5300
0.002 99 112
0.003 26 30
0.004 17 20
0.005 15 20
0.006 11 14
0.007 11 13
0.008 13 13
...many more lines..
Full data can be found here:
http://dpaste.com/173536/plain/
What I intend to do is to have a cumulative graph
with "val" as x-axis with "Freq1" & ...