similar to: re order vector in order given by another vector

Displaying 20 results from an estimated 20000 matches similar to: "re order vector in order given by another vector"

2008 Aug 12
5
produce variable on the fly
Hi guys, I want to create variable on the fly: for example for (i in 1:10) { cat(paste("VAR",i,sep="")) } Will print VAR1, VAR2 etc up to VAR10. However I want to make these into variables, and then give them a value, for example: vect = c(10:20) for (i in 1:10) { cat(paste("VAR",i,sep="")) = vect[i] } THis doesnt work but I hope it demonstrates
2008 Jul 04
4
Re ad in a file - produce independent vectors
Is there a way of reading in a file in a way that each line becomes a vector: for example: meals.txt breakfast bacon eggs sausage lunch sandwich apple marsbar crisps dinner chicken rice custard pie I want to read in this file and end up with 3 different vectors, one called breakfast which contains "bacon", "eggs", sausage" One called
2008 Sep 22
1
Combine data frames using column names as "key"
Hi guys, Suppose I have 2 data frames ie: values one 0.32 two 0.25 three 0.11 and values two 0.66 one 0.74 three 0.19 nb the first column is the row names in both cases How can I combine them on the row names column? Ie to make something like values.1 values.2 one 0.32 0.74 two 0.25 0.66 three 0.11 0.19 I guess its
2012 Jul 30
3
replace values in vector from a replacement table
Dear all I've got stuck when trying to replace values in a vector by selecting replacements from a replacement table. I'm trying to use only base functions. Here's a dummy example: > (x <- rep(letters,2)) [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l"
2011 Feb 04
1
Dovecot 2 multiple address/port binding
Hello, Sorry, I know the topic has been talked about already but I searched the archives and I'm still unsure of the proper way to have dovecot (imap-login) listen to several addresses and/or several ports. 1. how do I translate dovecot-1 protocol imap { listen = xx.xx.xx.xx:143 yy.yy.yy.yy:143 ssl_listen = xx.xx.xx.xx:993 yy.yy.yy.yy:939 } I started by service imap-login {
2009 Jul 28
3
character vector -> numeric matrix ??
Dear R users... I'd like to change this character vector, "zz", zz <- c("12","56","89") to the following numeric matrix. [,1] [,2] [1,] 1 2 [2,] 5 6 [3,] 8 9 Actually, "zz" vector has a long length. Any comments will be greatly appreciated. Kathryn Lord -- View this message in context:
2007 Apr 12
1
Assignment from list
I have a list of groups of xy positions I want to set to 0 in an array full of 1s. When the assignments are done directly from the list, they are incorrect, while if I use a temporary array derived from the list the assignments are correct. The following example will hopefully make my problem clearer. The matrices z and zz are initialised with 1. The z and zz values at coordinates in
2005 Apr 13
2
multinom and contrasts
Hi, I found that using different contrasts (e.g. contr.helmert vs. contr.treatment) will generate different fitted probabilities from multinomial logistic regression using multinom(); while the fitted probabilities from binary logistic regression seem to be the same. Why is that? and for multinomial logisitc regression, what contrast should be used? I guess it's helmert? here is an example
2006 Jan 09
1
How to use filled.contour(x,y,z) data for levelplot(z)?
Dear all, We used the following function to create a spatial plot of a raster image: filled.contour(xx,yy,zz, color = terrain.colors, nlevels=10, main=naamjaar, plot.axes = { contour(Xcoord/1000,Ycoord/1000,lim.data, nlevels = 4, col=4,drawlabels = T, axes = FALSE, frame.plot = FFALSE, add = TRUE);axis(1); axis(2);
2009 Mar 04
2
adding value labels on Interaction Plot
Hello - and sorry for what might look like a simple graphics question. I am building an interaction plot for d: d=data.frame(xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3)) d[[1]]<-as.factor(d[[1]]) d[[2]]<-as.factor(d[[2]]) print(d) interaction.plot(d$xx, d$yy, d$zz, type="b", col=c("red","blue"), legend=F, lty=c(1,2), lwd=2,
2007 Mar 07
5
How to open more windows to make more graphs at once!
Dear R users, I have a data frame (test) including five columns of upper (numeric), lower (numeric), observed (numeric), best_sim (numeric) and stname (factor with 80 levels, each level with different length). Now I would like to write a short program to draw one graph as follow for each level of stname but I would like also to draw each time 12 graphs for the 12 levels of stname in the same
2017 Oct 20
1
Another issue with Sys.timezone
>>>>> Stephen Berman <stephen.berman at gmx.net> >>>>> on Thu, 19 Oct 2017 17:12:50 +0200 writes: > On Wed, 18 Oct 2017 18:09:41 +0200 Martin Maechler <maechler at stat.math.ethz.ch> wrote: >>>>>>> Martin Maechler <maechler at stat.math.ethz.ch> >>>>>>> on Mon, 16 Oct 2017 19:13:31 +0200
2009 Sep 04
1
predicting from segmented regression
Hello I'm having trouble figuring out how to use the output of "segmented()" with a new set of predictor values. Using the example of the help file: ??set.seed(12) xx<-1:100 zz<-runif(100) yy<-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2) dati<-data.frame(x=xx,y=yy,z=zz) out.lm<-lm(y~x,data=dati) o<-## S3
2003 Nov 18
2
ask problem about softphone--asterisk--softphone, Urgent!!!
Hi, all, I want to use asterisk SIP as a proxy, and two softphone (Ubiquity SIP Phone) as user agent, like below: Softphone1<-------------->Asterisk SIP<------------>Softphone2 (User Agent) (Proxy) (User Agent) 155.69.xx.xx 155.69.yy.yy 155.69.zz.zz zhou mysipproxy.com
2008 Mar 11
4
Graphing question (multiple line graphs arranged spatially)
station month bas 190 5 0.000 190 7 1.563 190 10 0.000 190 11 0.000 202 4 18.750 202 5 18.750 202 7 6.250 202 10 4.800 202 11 3.125 198 4 18.750 198 5 31.250 198 7 3.125 198 10 3.200 198 11 12.500 205 4 0.000 205 5 0.000 205 7 0.000
2011 Jun 13
3
combine the data frames into comma separated list.
Hi R users, I am new to R and am trying to merge data frames in the following way. Suppose I have n data frames each with two fields. Field 1 is common among data frames but may have different entries. Field 2 is different. Data frame 1: Src Target1 1 aaa 1 bbb 1 ccc 2 aaa 3 ddd Data frame 2: Src Target2 2 aaaa 3 dddd 4 bbbb 4
2011 Apr 20
3
Help needed!
Hi everyone, I have a question. Now I am reading the resource code of the package "ssfcov". The resource code is as following. I cannot find the resource code of the function "myss2d" anywhere in the package. Can anyone give me a hint how to find it in the package. Thanks a lot!!bv > ssfcov function (time, x, subject, nbasis = 5, centered = FALSE, noDiag = TRUE) {
2008 Oct 20
2
convert matrix to dataframe with repeating row names
Hi R, I have a matrix x with repeating row names. > dim(x) [1] 862 19 zz<-matrix(0,4,4) rownames(zz)=c("a","a","b","b") data.frame(zz) (?) I need to use x in a linear regression lm(as.formula(paste("final_dat[,5]~",paste(colnames(x),collapse="+"))),x ) this gives me a error Error in
2017 Dec 01
3
tryCatch in on.exit()
The following example involves a function whose on.exit() expression both generates an error and catches the error. The body of the function also generates an error. When calling the function wrapped in a tryCatch, should that tryCatch's error function be given the error from the body of the function, since the one from the on.exit has already been dealt with? Currently the outer tryCatch
2011 Jun 14
1
[Resolved] combine the data frames into comma separated list.
Hi Thanks Gabor for your suggestion. I am posting the code that worked for me. dataframe1 = data.frame(cbind(Src = c(1,1,1,2,3), Target1 = c('aaa','bbb','ccc','aaa','ddd'))); #must be data frame dataframe2 = data.frame(cbind(Src = c(2,3,4,4,4), Target2 = c('aaaa','dddd','bbbb','eeee','ffff'))); dataframe3 =