search for: temp1

Displaying 20 results from an estimated 138 matches for "temp1".

Did you mean: temp
2010 Jun 09
2
Help needed on "switch" function
Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable :   temp1 <- "1"               temp1.name <- switch(temp1,                                   1 == "aa",                                   2 == "bb",                                   3 == "cc",                                   4 == "dd",               ...
2009 Feb 11
2
sorting a matrix by the column
this is a bad question but I can't figure it out and i've tried. if i sort the 2 column matrix , temp1, by the first column, then things work as expected. But, if I sort the 1 column matrix, temp2, then it gets turned coerced to a vector. I realize that I need to use drop=FALSE but i've put it in a few different places with no success. Thanks. temp1 <- matrix(rnorm(10),nc=2,nrow=5) rowname...
2009 May 15
4
replace "%" with "\%"
Dear all, I'm trying to gsub() "%" with "\%" with no obvious success. > temp1 <- c("mean", "sd", "0%", "25%", "50%", "75%", "100%") > temp1 [1] "mean" "sd" "0%" "25%" "50%" "75%" "100%" > gsub("%", "...
2006 Jan 04
3
matrix math
I am using R 2.1.1 in an windows XP environment. I have 2 dataframes, temp1 and temp2. Each dataframe has 20 variables (“cocolumns") and 525 observations (“rows”). All variables are numeric. I want to create a new dataframe that also has 20 columns and 525 rows. The values in this dataframe should be the sum of the 2 other dataframe. (i.e. temp1$co...
2009 Feb 11
2
error in my previous message
...","j") print(temp2) temp2 <- as.matrix(temp2[order(temp2[,1,drop=FALSE]),]) print(temp2) On Wed, Feb 11, 2009 at 1:18 AM, markleeds at verizon.net wrote: > this is a bad question but I can't figure it out and i've tried. if i > sort the 2 column > matrix , temp1, by the first column, then things work as expected. > But, > if I sort the 1 column matrix, temp2, then it gets turned coerced to a > vector. I realize that I > need to use drop=FALSE but i've put it in a few different places with > no success. Thanks. > > temp1 <- ma...
2009 Jul 01
2
?max (so far...)
...pos <- (MyFrame$p > 0) MyFrame$pc <- cumsum(pos) pos <- (MyFrame$l < 0) MyFrame$lc <- cumsum(pos) return(MyFrame) } PercentWins = function (MyFrame) { MyFrame$pwin <- round((MyFrame$pc / (MyFrame$pc+MyFrame$lc)),2) return(MyFrame) } HighLow = function (MyFrame) { temp1 <- MyFrame$p[1:row] MyFrame$hp <- max(temp1) ## Highest p temp1 <- MyFrame$l[1:row] MyFrame$ll <- min(temp1) ## Lowest l return(MyFrame) } F1 <- data.frame(x=1:10, y=2*(-4:5) ) F1 <- AddCols(F1) F1 <- BinPosNeg(F1) F1 <- RunningCount(F1) F1 <- PercentWins(F1) F1 F1...
2005 May 20
4
issues with identical()
Hi all, hope you having a nice day, I ahve this weird results with identical (probably I am not understanding correctly what it does ...) I have these two data frames and I issue : > identical(temp, temp1) [1] FALSE However, these data frames are Nx2 and when I issue: > identical(temp[,2], temp1[,2]) [1] TRUE > identical(temp[,1], temp1[,1]) [1] TRUE and the results from str > str(temp) `data.frame': 7072 obs. of 2 variables: $ pub_id : int 10000 1000 10001 10002 10003 10004 10...
2011 Mar 09
2
Anomaly with unique and match
...; stest <- data.frame(start = 10*temp, + stop = 10*temp + test1$time, + status = rep(test1$status,4), + x = c(test1$x+ 1:7, rep(test1$x,3)), + epoch = rep(1:4, rep(7,4))) > > fit1 <- coxph(Surv(start, stop, status) ~ x * factor(epoch), stest) ## New lines > temp1 <- fit1$linear.predictor > temp2 <- as.matrix(temp1) > match(temp1, unique(temp1)) [1] 1 2 3 4 4 5 6 7 7 7 6 6 6 8 8 8 6 6 6 9 9 9 6 6 > match(temp2, unique(temp2)) [1] 1 2 3 4 4 5 6 7 7 7 6 6 6 NA NA NA 6 6 6 8 8 8 6 6 ----------------------- I've solved...
2013 Mar 29
1
multiple plots and looping assistance requested (single plot)
..., "Data1", "Data2"), class = "data.frame", row.names = c(NA, -2L))), .Names = c(":Bostoncitydata", ":Chicagocitydata", ":NewYorkcitydata", ":Philadelphiacitydata", ":Atlantacitydata", ":Baltimorecitydata")) temp1<-lapply(temp,function(x) {x1<-x[,colSums(is.na(x))!=nrow(x)]; if(is.data.frame(x1)) x1[complete.cases(x1),] else x1[complete.cases(x1)] }) # temp1<-lapply(temp1,function(x) x[is.data.frame(x)]) #3 columns subset temp3<-temp1[lapply(temp1,length)==3] temp3New<-temp3[sapply(temp3,is....
2012 Oct 31
2
Aggregate Table Data into Cell Frequencies
R-help - I have this set of aggregated tables (sample data below via dput()). And I would like to have delayValue as the column variables with the "temp" (temp1, temp2, temp3) values as the row variables. However I would like to have the temp variables *aggregated into single rows* so that I have the frequency ("Freq" | counts) of each time each "delayValue" occurs in the cells. I've tried this command without luck, it seems to be...
2008 Aug 26
1
parse and eval character vector
Dear R-help, I have a character vector, some elements will be numeric, some not, and some even empty. E.g.: temp1 <- c("abcd"," 2 ","") I'm only interested in the numeric elements, the rest I can just throw away. It is easy enough to loop through the vector: temp <- try(eval(parse(text=temp1[1])), silent=TRUE); class(temp) # try-error temp <- try(eval(parse(text=te...
2005 Nov 23
2
vector of permutated products
...3 Now, I already have the correctly sorted matrix of permutations! So, the input looks something like: #input x<-c(0.3,0.1,0.2) Nx<-length(x) Ncomb<-2^Nx permat<-matrix(c(1,1,1,1,1,0,1,0,1,1,0,0,0,1,1,0,1,0,0,0,1,0,0,0),Ncomb,Nx) I code the rest as follows: #correct but clumsy code temp1<-t(matrix(rep(x,2^3),3,2^3)) temp2<-t(matrix(rep(1-x,2^3),3,2^3)) result<-apply(permat*temp1-(permat-1)*temp2,1,prod) But I would like to do without temp1 and temp2. To have something like result<-apply(permat*x-(permat-1)*x,1,prod) My problem is that permat*x does not produce permat...
2010 Nov 19
3
Sweave Dynamic Graph Question
...uot;2000-01-01") IBM.Close <- IBM[,"IBM.Close"] rng=range(time(IBM.Close)) Syr <- as.numeric(format(rng[1],"%Y")) Eyr <- as.numeric(format(rng[2],"%Y")) Smth <- as.numeric(format(rng[1],"%m")) for( yr in Syr:Eyr){ par(mfrow=c(4,3)) Temp1 <- IBM.Close[which(format(time(IBM.Close),"%Y")==yr),] Temp3 <- tapply(Temp1[,1],as.yearmon(time(Temp1)),FUN=mean) for(i in Smth:length(Temp3)){ i <- ifelse(i < 10, paste(0,i,sep=""),i) Date <- paste(i,yr,sep="-") Temp2 <- IBM.Close[wh...
2008 Feb 15
1
problem with heatmap.2
Hi, > temp1[1:6,] AAAA_XXX BBBBBB_XXX CCCCC_XXX DDDDD_XXX EEEEE_XXX SkHep1_XXX 50 0.75285 0.30630 0.56330 0.45755 0.49665 0.74685 63 0.35930 -0.22725 0.04725 0.53955 0.56390 0.51170 69 -1.57515 -1.67610 -1.61695 -1.11685 -0.00085 -1.89155 91 0.84640 0.43595 0.62350...
2009 May 28
2
Replace is leaking?
Okay, someone explain this behaviour to me: Browse[1]> replace(rep(0, 4000), temp1[12] , temp2[12])[3925] [1] 0.4462404 Browse[1]> temp1[12] [1] 3926 Browse[1]> temp2[12] [1] 0.4462404 Browse[1]> replace(rep(0, 4000), 3926 , temp2[12])[3925] [1] 0 For some reason, R seems to shift indices along when doing this replacement. Has anyone encountered this bug before? It see...
2010 Oct 14
1
Basic data question
I have a question about the output given below after running few lines of code. Surely a 101 query! MF_Data <- read.csv("MF_Data_F.txt", header = F, sep="|") temp <- head(MF_Data) #Get the sample Data temp1 <- subset(temp, select= c(V1,V4,V6)) #where V1, V4, V6 are the col names .. to Get the relevant data names(temp1) <- c('Ticker', 'Price','Date') #Adjusted column names Now as expected, I get: > temp1 Ticker Price Date 1 106270 10.3287 01-Apr-2008 2 10626...
2006 Mar 03
1
NA in eigen()
...h my large matrix. My original matrix has no NAs in it. Here is code, but of course it requires my original, 601x601 symmetric matrix called mat > any(is.na(mat)) [1] FALSE > any(is.na(d)) [1] FALSE > dim(mat) [1] 601 601 > length(which(d==0)) [1] 5 > d<-rowSums(mat) > temp1<-eigen(diag(d)-mat,symmetric=T) > temp2<-eigen(diag(d)-mat,symmetric=T,EISPACK=T) > any(is.na(temp1$vec)) [1] TRUE > any(is.na(temp1$vec[,-52])) [1] FALSE > any(is.na(temp2$vec)) [1] FALSE > all.equal(abs(temp1$vec[,-52]),abs(temp2$vec[,-52])) [1] "Mean relative diff...
2003 May 31
1
Minor problem with unwritable directories
...es with potentially open files--such as when I backup /home). All directories that are not writable--even though unchanged--will be sent again. [Note that unwritable files are not transferred again--this only occurs with directories]. -- Set of commands to reproduce problem -- mkdir -p temp1/some/set/of/subdirectories/ mkdir temp2 chmod -R a-w temp1/some/set/of rsync -av temp1/ temp2/ rsync -av temp1/ temp2/ -- Output from those commands -- # Note the 2nd rsync run and how unwritable directories are listed # again 1190 newren@amr:~$ mkdir -p temp1/some/set/of/subdirect...
2011 Dec 12
1
Lagged values problem requiring short solution time
...may or may not give the theoretically optimal solution, but, regardless, is too slow when 'x' becomes lengthy due to its reliance on loops. Hope you can help! x = runif(10,1,5) delta = 0.75 chg = diff(c(x,x[1])) y = x while (any(abs(chg)>delta)) { temp = sign(chg)*chg - delta temp1=temp temp1[chg>=(-delta)] = 0 temp1 = c(temp1[length(temp1)],temp1[-length(temp1)]) temp2 = temp temp2[chg<=delta] = 0 y = y+temp1+temp2 chg = diff(c(y,y[1])) } #Solution vector: y Thank you, Kevin Kevin Ummel CARMA Project Manager Center for Global Development [[alterna...
2009 Feb 18
2
understanding how R determines numbers and characters when creating a data frame
...for example 1. Why does the cbind command convert the numeric data to character data? Why can't the character data be converted to numeric data using the fix command? ### Example 1 ############# data(iris) obsnum<-NULL results<-NULL for(s in unique(as.character(iris$Species))){ temp1<-iris[iris$Species==s,] obsnum<-length(unique(temp1$Sepal.Length)) # a number out1<-cbind(species=as.character(paste(s)),obsnum) # number converted to character results<-rbind(out1,results) } results #fix(results) # cannot convert obsnum to numeric using fix ##################...