search for: mresendeufv

Displaying 20 results from an estimated 20 matches for "mresendeufv".

2010 Mar 15
5
storing matrix(variables) in loop
Hello R-helpers, I have the following code that works well, b <-list() for (i in 1:3){ a <- matrix(runif(1),3,3) b[[i]] <- a } b however, I need to do something similar with two loops and I was looking for something that would look like b <- list() for (i in 1:3){ for (j in 1:4){ a <- matrix(runif(1),3,3) b[[i,j]] <- a #but this doesn?t work } } Anyway, I wanted
2010 Oct 29
2
Differenciate numbers from reference for rows
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 matrix where I need to extract the element from. The numbers after the multiplication sign are regular
2009 Sep 22
2
chage the output file name
After I run my script I save all my output e.g. write.table(d, file = "C:/PINEheight.txt) write.table(v, file = "C:/PINEvolume.txt) write.table(v, file = "C:/PINEdiameter.txt) write.table(v, file = "C:/PINEdensity.txt) and then I would like to run again with another tree and save again e.g write.table(d, file = "C:/POPULUSheight.txt) Is there anyhow I can define a
2010 Dec 28
1
Faster way to do it??...using apply?
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 element in y is equal to 1 If the element in x is equal to 1, the element in y is either 0 or 1
2009 Oct 28
1
Is there a faster way to do it?
#Mdarts is a matrix 2343x788 #frequencia is a vector 2343x1 # 9 in Mdarts[fri,frj] stands for my missing values which i want to replace by the value in the vector frequencia Mdarts<-t(matrix(scan("C:/GWS/CNB/dartg.txt"),ncol=nindT,nrow=nm, byrow=T)) frequencia <- matrix(scan("C:/GWS/CNB/freq.txt"),ncol=1) for (fri in 1:nindT){ for (frj in 1:nm){ Mdarts[fri,frj] <- if
2011 May 12
3
Help with "apply"
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] - x[i,k]*gtemp[k] } } It works fine but I wanted to make it faster and I think an apply function
2009 Sep 27
2
Count number of zeros in a collumn
I have a matrix 700x2000 which is sampled in each cycle from another matrix 788x2000 with the numbers 0,1 and 9 There is one specific collumn of this matrix, dart[,1977], that usually, after the samplimg procedure has only 1 and 9 (because the zero frequency in this collumn is low). However, when this happens, I want to include an IF conditional in my code. so basically what i wanted to do was to
2009 Sep 18
1
Incorrect Dimension
I am new in R and i am having trouble here. I?ve already searched in the list but hasn?t helped When i run this script above i get the message "Error in gen[j, i] : incorrect number of dimensions". However gen is 1000x200 (ind x loc) and so is g could anybody help me for (i in 1 : loc) { #loc=200 for (j in 1 : ind) { #ind=1000 g1 <= function ( gen ) matrix ( if (gen[j, i]
2009 Sep 17
3
How to separate a function by 2 probabilities
Good Mourning, I have a function to generate a matrix as I show part of it; g[j,i]<-if (gen[j,i]==0) al1[i,1]+al1[i,1] else ... However i would like that this function occurred with a probability P and that another function (another formula to generate g matrix) with probability P-1 That?s it, if P is .7, i would like that in 70% of the times (for random i and j) the matrix g was generated
2010 Oct 29
3
How to scan df from a specific word?
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 then but they have different sizes asdfhjkash asdfhjksa source tret 2 res 3 Can
2009 Dec 01
3
Using two (...) in a function
Hello R-Helpers, I am not sure if it is a very simple question but I would like to use two (...) in a function, for example, this is a script where I would like to input the variable names (in one of the (...)) and the variances associated to those variables which are not calculated in the script because there is a specific software to calculate it (the other (...)) data <- function
2009 Oct 15
1
Sampling procedure
I would like to divide a vector in 9 groups in a way that each number is present in only one group. In a vector of 783 I would like to divide in 9 different groups of 87 Example <- matrix(c(1:783),ncol = 1) s1 <- as.matrix(sample(Example,87, re = FALSE)) Example <- Example[-s1] s2 <- as.matrix(sample(Example,87, re = FALSE)) #however I don?t know how to remove the second group from
2010 Mar 26
2
Is there a faster way to do this?
Hi guys, I am still learning R, and not well familiar with all the apply functions. I am trying to find faster alternatives to replace the for cycle. Is there a faster way to do the example below? nm <- 1000 b <- matrix (rnorm (5000, 0, 1), nrow = 500, ncol = nm) a <- matrix (0, nm, nm) for (i in 1 : nm) { for (j in 1 : nm) { if ( j == i) { next } a[i, j] <- t (b [, i]) %*% b[, j] } }
2010 Nov 22
1
empity value in colnames
Hi Guys. I have a matrix which has names in every other column and the other one is empity ("") example X10000 X10001 X10002 [1,] "A" "G" "A" "G" "G" [2,] "G" "G" "A" "G" "A" [3,] "G" "G" "A" "A" "A"
2009 Sep 23
1
BLUP with missing data
hello guys, I need to do a BLUP in the simplest model y = Xm + Zg + e however I have missing data in the analysis which I can?t consider as 0(zero). So I need to generate the matrix X'Z, Z'X and Z'Z step by step; I can?t use crossprod(x) #neither X'X <- t(x)%*%x because I should skip the elements with missing data in the matrix I?ll try to be more clear, supposing a matrix x
2009 Sep 23
1
Sum of Product in a Matrix
Hi, I am new in R and I don?t know how to sum the product of two elements at the time in a matrix X=[ 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16] I would like to do (1*5+2*6+3*7+4*8) I need to do it step by step because I will further put a conditional in the formula It worked this way x <- matrix ( c (1 : 16),ncol = 4) #generating my x matrix qw <- matrix (0,
2010 May 18
2
Counting Frequencies in Data Frame
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 generate a vector (or another data.frame) with 7000 rows, and 3
2010 Mar 16
2
Dimnames of array inside loop
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): for (i in 1:A){ for (j in 1:B){ for (k in 1:C){ acuracia[,,i,j,k] <- correlacao / (sqrt(ac)) } } } then I
2010 May 31
3
error on Windows OS
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 tryed to install using install.packages("foo.tar.gz", repos=NULL, type="source") but
2009 Nov 25
5
How to sum only a few elements in a line
Hello, I have a matrix with the numbers 0,1 and 9 I would like to write a function that could sum each line skiping everytime a number 9 appears for example [0 1 0 1 1 9 1] the sum would be 4. However I cannot replace 9 by 0 otherwise after the sum is done I wouldn?t be able to distiguish which ones were real zeros and which ones were nines replaced by zero just to sum. Thank you very much --