[R] Help with apply

2011-05-12 Thread M.Ribeiro
Hello R gurus, I have a simple routine using for loops that i was just trying to make it faster y - rnorm(10) Nindiv - 10 x -matrix(sample(c(0:2),50,re = T),10) gtemp - rnorm(10) ycorr - array(0,c(Nindiv,1)) for (i in 1:Nindiv) { for (k in 1:ncol(x)) { ycorr[i] - y[i] -

Re: [R] Help with apply

2011-05-12 Thread M.Ribeiro
Ok, I am sorry, I was building a reproducible example to post here and I made a mistake. Th second loop (in the variable k) updates ycorr. Therefore, it would be ycorr - rnorm(10) Nindiv - 10 x -matrix(sample(c(0:2),50,re = T),10) gtemp - rnorm(10) for (i in 1:Nindiv) { for (k in

[R] Faster way to do it??...using apply?

2010-12-28 Thread M.Ribeiro
Hi, I have a simple task, but I am looking for a clever and fast way to do it: I have a vector x with 0,1 or 2 and I want to create another vector y with the same length following the rules: If the element in x is equal to 0, the element in y is equal to 0 If the element in x is equal to 2, the

Re: [R] Faster way to do it??...using apply?

2010-12-28 Thread M.Ribeiro
Hi Henrique, Thanks for the fast answer, The only problem in your code, which I think I didn't mention in my message is that I would like one different random sampling procedure for each 1 in my vector The way it was written, it samples only once and replace by every 1: x =

[R] empity value in colnames

2010-11-22 Thread M.Ribeiro
Hi Guys. I have a matrix which has names in every other column and the other one is empity () example X1 X10001 X10002 [1,] AG AG G [2,] GG AG A [3,] GG AA A [4,] GG AA A [5,] AG AA A I am creating another matrix (I called

[R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Hi R-helpers, I need to read some file with different lines (I don't know the number of lines to skip) and I would like to find a way to start reading the data.frame from the word source. ex: djhsafk asdfhkjash shdfjkash asfhjkash #those lines contain numbers and words, I want to skip

Re: [R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Sorry, the explanation wasn't very good...just to explain better. I am writing a loop to read and process different files in the same script. And what I want to load into a variable is a data.frame that is above the word source in all of my files. So I would like to recognize the word Source in

Re: [R] How to scan df from a specific word?

2010-10-29 Thread M.Ribeiro
Sorry, the explanation wasn't very good...just to explain better. I am writing a loop to read and process every time a different file in the same script. And what I want to load into a variable each time is a data.frame that is bellow the word source in all of my files. So I would like to

[R] Differenciate numbers from reference for rows

2010-10-29 Thread M.Ribeiro
So, I am having a tricky reference file to extract information from. The format of the file is x 1 + 4 * 3 + 5 + 6 + 11 * 0.5 So, the elements that are not being multiplied (1, 5 and 6) and the elements before the multiplication sign (4 and 11) means actually the reference for the row in a

Re: [R] Dimnames of array inside loop

2010-06-23 Thread M.Ribeiro
any clue?? hello R-helpers, I have an array acuracia - array(NA, dim = c(1, 1, A, B, C)) which is first defined and in the example above with dimensions 1x1xAxBxC. My array is then filled using 3 loops (I am not well familiar yet with lapply or sapply functions so I am still a loop-user):

[R] error on Windows OS

2010-05-31 Thread M.Ribeiro
I received by email an R package (file.tar.gz) that was created in Linux. The package was already installed in another computer in linux using install.packages and it worked I am not familiar with installing packages but I would like to install it on Windows I downloaded the Rtools29.exe and

Re: [R] error on Windows OS

2010-05-31 Thread M.Ribeiro
Ok, I re-installed the Rtools (now Rtools211 because I was in another computer with R version 2.10) , and the message now when I tried to install the package was Warning: invalid package 'GWSR_1.0.tar.gz' Erro: ERROR: no packages specified Warning message: In install.packages(GWSR_1.0.tar.gz,

Re: [R] error on Windows OS

2010-05-31 Thread M.Ribeiro
Thanks for all the help, So let me undestand, The Rtools is currently installed in c:\Rtools\bin; c:\Rtools\perl\bin; c:\Rtools\MinGW\bin; %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem; C:\Program Files (x86)\QuickTime\QTSystem\; C:\Program Files (x86)\SAS\Shared

[R] Counting Frequencies in Data Frame

2010-05-18 Thread M.Ribeiro
Hi, I am sure there is an easy way to do it, but I can't find it. I have a data frame that has 15 columns and 7000 rows. The only values inside the data.frame are aa, ab, bb as you can see an example bellow. 1 2 3 1 aa ab ab 2 ab ab ab 3 aa aa aa 4 bb bb bb What I would like to do, is to