similar to: cbind objects using character vectors

Displaying 20 results from an estimated 30000 matches similar to: "cbind objects using character vectors"

2009 Sep 04
2
help with functions
Hi all, I have got 2 function (see bellow) which are simplifications of what I need to do. These functions are precisely the same, except for the last line. My question is, why doesn't function testA work in the same way as function testB. Both functions produce two objects, "a" and "b" that must merged with rbind. The difference is that in testA, I specify the name
2009 Oct 13
2
axis labels
Dear list, why does the distance between the axis labels and the tick marks looks different for x axis and y axis in the plot (see code below). In fact, the x axis labels look furthest from the tickmarks than in the y axis. How can I make them look the same? par(mfrow=c(1,1), cex.axis = 0.5, cex.lab = 0.5) plot(1,1, axes = F) axis(1) axis(2) Thanks in advance Jonas [[alternative HTML version
2009 May 16
1
vector fragment
Dear R users: I have got a simple question that has been bothering me for a while. Given a certain character vector, I would like to get in a separate vector a fragment of text, in this case the 3rd and 4th letters of each element. So, if: v<- c(“stratosphere”, “mesosphere”, “troposphere”) I want to obtain a different vector like this: c(“ra”, “so”, “op”) Thanks in advance
2011 Sep 12
1
Multilevel model in lme4 and nlme
Dear list, I am trying to fit some mixed models using packages lme4 and nlme. I did the model selection using lmer but I suspect that I may have some autocorrelation going on in my data so I would like to have a look using the handy correlation structures available in nlme. The problem is that I cannot translate my lmer model to lme: mod1<- lmer(y~x + (1|a:b) + (1|b:c), data=mydata)
2008 Dec 10
2
missing argument
Dear list, I have a question and I'm going to give an example of my problem f<- function(d1, d2, d3) { d<- d1*d2/d3 return(d) } v1<- 1 v2<- 2 If I try f(v1, v2, v3) Error in f(v1, v2, v3) : object "v3" not found I obviously got the above error message. I would like to add something to my function to allow me to get a certain value (say zero) if one of the arguments is
2010 Mar 03
1
End of line marker?
Dear R users, I am trying to read a huge file in R. For some reason, only a part of the file is read. When I further investigated, I found that in one of my non-numeric columns, there is one odd character responsible for this, which I reproduce bellow: In case you cannot see it, it looks like a right arrow, but it is not the one you get from microsoft word in menu "insert symbol". I
2002 Apr 10
3
problem with do.call
Hi I'm writing a function that uses four parameters (scalars) and I need to run it in an iterative process (the parameters vary to find the minimum RSS). I don't want to use loops and so tried the do.call function. However it didn't work. My understanding is that the do.call simple runs the function replacing the arguments (scalars by vectors), instead of runing the function for
2008 May 21
1
split character string in matrix into character vector and numeric vector
Hello, I've got a matrix consisting of one column with n rows. Each field in the matrix is filled with a character vector. I would like to convert this matrix into a character vector containing the B03_MAH-type entries from the beginning of each row and a data.frame that contains the numeric data, but I am stuck. I have tried to use textConnection with sep = " " but since
2008 Mar 13
3
fast way to compare two matrices of combinations
I have a list (length 750), each element containing a vector of unique strings (unique gene ids), with length up to ~40 (median 15). I want to compile a matrix of all possible triplets and their frequency within gene elements. Using combn and a lot of looping, I am accomplishing this but it is VERY slow. I've tried to figure out a way to vectorize this, using "match" and
2009 Oct 02
2
how to fill out the empty spots when using rbind or cbind?
I have uneven vectors I want to use cbind or rbind to combine them into a matrix. Is there a way to make it so that R would not return error msg saying they're uneven? Thanks. Edward Chen Email: tkedch@msn.com Cell Phone: 510-371-4717 [[alternative HTML version deleted]]
2008 Jun 12
2
numbers as part of long character
Hi, I'm looking for some way to pick up the numbers which are contained and buried in a long character. For example, outtree.new="(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:17139.21);" num.char =
2009 Mar 11
3
Matrix Construction; Subdiagonal
I'm trying to enter a vector into the subdiagonal of a matrix but cannot find a command in R which corresponds to the MatLab version of diag(vec, k), where vec = the vector of interest, and k = the diagonal (k=0 for the diagonal; k=-1 for the subdiagonal; k=1 for superdiagonal, etc.) Is there an equivalent command in R? I'm looking for something like this: vec = seq(1, 5, 1)
2013 Oct 11
3
matrix values linked to vector index
Hi, In the example you showed: m1<- matrix(0,length(vec),max(vec)) 1*!upper.tri(m1) #or ?m1[!upper.tri(m1)] <-? rep(rep(1,length(vec)),vec) #But, in a case like below, perhaps: vec1<- c(3,4,5) ?m2<- matrix(0,length(vec1),max(vec1)) ?indx <- cbind(rep(seq_along(vec1),vec1),unlist(tapply(vec1,list(vec1),FUN=seq),use.names=FALSE)) m2[indx]<- 1 ?m2 #???? [,1] [,2] [,3] [,4] [,5]
2013 Mar 23
4
Converting a character vector to numeric
Hello again, Let say I have following vector: Vec <- c("0.0365780769", "(1.09738648244378)", "(0.812507787221523)", "0.5778069963", "(0.452456601362355)", "-1.8900812605", "-1.8716093762", "0.0055217041", "-0.4769192333", "-2.4133018880") Now I want to convert this vector to numeric vector. I
2006 Apr 04
1
Indexing a vector by a list of vectors
Hello R-help - I have vec <- c("string1", "string2", "string3") ind <- list(c(1,2),c(1,2,3)) I want "vec" indexed by each vector in the list "ind". The first element of the list I want would be vec[c(1,2)], the second element would be vec[c(1,2,3)], like the following. [[1]] [1] "string1" "string2" [[2]] [1]
2006 Aug 22
2
listing a sequence of vectors in a matrix
Hi, I'm having trouble applying the matrix function. I'd like to be able to create a matrix of vectors filled in by rows, which are not all the same length, and so I need it to fill in NAs where applicable. It's easiest to explain with a simple example: Suppose vec = c(3,4,5). How can I form a matrix of the vectors 1:vec[j] for j=1:3? i.e. 1 2 3 NA NA 1 2 3 4
2012 Nov 20
1
tcl/tk problem with tklistbox,the " " character and Rcmdr.
I everyone, i have a little problem with tklistbox,the " " character and Rcmdr. Please look at this code require(tcltk) tt<-tktoplevel() levels.list2 <-tklistbox(tt,selectmode="multiple",exportselection="FALSE", height=4, yscrollcommand=function(...)tkset(levels.list2.scroll,...))
2006 Sep 14
1
attributes of S4 objects
I am having a bit of a struggle deciding when to use attributes with S4 objects. Clearly the 'class' attribute will always be present. But it is not clear to me whether the architects of the methods package intend that other attributes, such as 'names', will still be used when the S4 implementation is complete. I notice that, when you create a formal object from an
2004 Jun 30
1
Developing functions
Without trying to understand your code in detail let me just assume you are trying to create a matrix, ret, whose i,j-th entry is some function, f, of row i of X and row j of X. In that case this should do it: apply(X,1,function(x)apply(X,1,function(y)f(x,y))) Date: Wed, 30 Jun 2004 15:28:47 -0300 (ART) From: <daniel at sintesys.com.ar> To: <r-help at stat.math.ethz.ch>
2009 Dec 11
4
extracting vectors from lists of lists
Good evening I often have as output from simulations a list of various values, vectors and matrices. Supposing that I then run said simulation several times, I often want to extract a particular result from each simulation for plotting and, ideally, put it in a matrix. A simple example v1 <- 1:5 v2 <- 6:10 other1 <- "stuff" other2 <- "stuff" set1 <-