similar to: getting column names of row-by-row sorted matrix

Displaying 6 results from an estimated 6 matches similar to: "getting column names of row-by-row sorted matrix"

2010 Nov 08
4
Random Sample
Hello R users, Here is my question about generating random sample. How to set the random seed to recreate the same random numbers? For example, 10 random numbers is generated from N(0,1), then "runif(10)" is used.What if I want to get the same 10 random numbers when I run runif(10) again? Is it possible?I think .Random.seed should be used here. Thanks. Xiaoxi [[alternative
2007 Dec 13
1
creating lagged variables
Hi all. I'm looking for robust ways of building lagged variables in a dataset with multiple individuals. Consider a dataset with variables like the following: ## set.seed(123) d <- data.frame(id = rep(1:2, each=3), time=rep(1:3, 2), value=rnorm(6)) ## >d id time value 1 1 1 -0.56047565 2 1 2 -0.23017749 3 1 3 1.55870831 4 2 1 0.07050839 5 2 2 0.12928774 6
2008 May 07
1
Automatically generating new column names (and columns)
Once again I need to tap into the collective knowledge here. Let's say I have the following columns and data below Y X1 X2 X3 X4 I would like to generate additional new columns and column names (ie the data would be squared - and I'd like the column names to reflect this) like: Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2 I believe I can compute the values correctly with the code below, but I
2008 Mar 11
2
Replacing text
Sorry, another newbie question :-( I loaded a data set with 10 rows and 30 columns. The first column is characters for names of car manufacturers: Jeep Nissan Toyota1 Toyota2 Etc. How can I replace "Toyota2" with "Scion"? Thanks again [[alternative HTML version deleted]]
2010 Jul 27
6
Eval() or parse() do not work inside function
I am writing a function where the arguments are names of objects or variable names in a data frame. To convert the strings to the objects I am using eval(parse(text=name)): f.graph.two.vbs<-function(dataname,v1){ val<-paste(dataname,v1,sep="$") val<-eval(parse(text=val)) val } However running this returns an error:
2008 Sep 05
5
Lowest k values of list
Hi @ all, how do I get the largest or lowest k values of list? It must similar to the min() / max() function, but I just don't get it. Best wishes, Markus