similar to: if negative value, make zero

Displaying 20 results from an estimated 10000 matches similar to: "if negative value, make zero"

2010 May 17
4
Adding a row at top of dataframe
I have a large data frame 48:2185 with different numbers. I would like to add only one row at the very top of my data frame with 0's or NA's. I don't know which approach to use. Should i create 2 different data frames and merge them? Ive also tried the rbind command with no luck. I would appreciate some help to achieve what I'm trying to create. Thanks!
2010 May 13
2
Adding name to nth row
Hello, I have a data frame with many rows, and I want to create a column with a name only at every 12th row, starting from 97 to 278. Thanks in advance!
2010 Nov 19
3
Sweave Dynamic Graph Question
i have a time Series of IBM closing px from 1/1/2000 to today I want to graph the time serie by dividing the graph by year and month all the monthly graphs with the same year will go to one page. so from 1/1/2000 to 11/19/2010. i will have 11 pages, and each page will have 12 graphs (jan to dec) except for 2010. I am able to do it in R, but when i use sweave, I can only print the last page.
2003 Nov 23
4
remove 0 rows from a data frame
Dear all, As part of a larger function, I am randomly removing rows from a data frame. The number of removed rows is determmined by a Poisson distribution with a low mean. Sometimes, the random number is 0, and that's when the problem starts: My data frame: > temp occ x y dbh age 801 0 2977.196 3090.225 6 36.0 802 0 2951.892 3083.769 8 40.6 803 0 2919.111
2010 May 26
2
How to calculate mean of means
I have 3 columns of numbers, and i want to find the mean of each separately, and then the mean of all of the means. ive tried: av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3)) av3daysB but it only gives me the mean of the first column (avr1) Any suggestions? Thanks, Emilija
2012 Mar 29
1
Error, Variable is Missing
Hi, I am writing a function to plot a pdf of a distribution, GNL.pdf.fn = function(x,mu,sigma,alpha,beta,rho) { y = x-rho*mu cf.fn = function(s){ cplex = complex(1,0,1) temp1 = alpha*beta*exp(-sigma*s^2/2) temp2 = (alpha-cplex*s)*(beta+cplex*s) out = (temp1/temp2)^rho out } temp.fn = function(s){ (Mod(cf.fn(s)))*cos(Arg(cf.fn(s))-s*y) } int.fn =
2010 Jun 21
2
Calculating a daily average
I have a set of data with 12 readings for temperature per day, with 180 days. I want to find the average temperature of each day. I am able to do this one by one, but with that many days to calculate the average for, it will get very long. I'm sure there is a faster way to do this, I just don't know how. What i have so far is: av1 <- subset(ER9r, Day == 98, select = c
2010 Jan 14
5
Better way than an ifelse statement?
Hello All, I am trying to create a column of weights based off of factor levels from another column. I am using the weights to calculate L scores. Here is an example where the first column are scores, the second is my "factor" and the third I want to be a column of weights. I can do what I want with an ifelse statement (see below), but I am wondering if anyone knows of a cleaner way
2009 Feb 11
2
error in my previous message
i'm sorry. i had an error in my previous code because i left out a letter in the rownames. while fixing that, i also found a solution. so i'm sorry for the confusion. below is my fix. temp2 <- matrix(rnorm(10),nc=1,nrow=10) rownames(temp2) <-
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 <-
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
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$column
2007 Jan 30
2
rbind-ing list
hi, i have a list of data.frame that has same structure. i would like to know a efficient way of rbind-ing it. right now, i write: n = length(temp) # 'temp' is a list of data.frames temp2 = data.frame() for (i in 1:n) temp2 = rbind( temp2, temp[[i]]) return(temp2) but this is not an efficient way since we keeping overwriting temp2. i wonder if there's faster way. thanks --
2004 Sep 28
3
sapply behavior
Hi, I use sapply very frequently, but I have recently noticed a behavior of sapply which I don't understand and have never seen before. Basically, sapply returns what looks like a matrix, says it a matrix, and appears to let me do matrix things (like transpose). But it is also a list and behaves like a list when I subset it, not a vector (so I can't sort a row for instance). I
2011 Jun 17
3
rle on large data . . . without a for loop!
I think need to do something like this: dat<-data.frame(state=sample(id=rep(1:5,each=200),1:3, 1000, replace=T,prob=c(0.7,0.05,0.25)),V1=runif(1,10,1000),V2=rnorm(1000)) rle.dat<-rle(dat$state) temp<-1 out<-data.frame(id=1:length(rle.dat$length)) for(i in 1:length(rle.dat$length)){ temp2<-temp+rle.dat$length[[i]] out$V1[i]<-mean(dat$V1[temp:temp2])
2010 Jun 28
1
Subtraction loop
I have a data frame with 2 columns, one for day and one for average. The day starts at 97 all the way to 279. I want to subtract day 98 average- day 97 average, then day99 average -day 98 average and so on down my list, creating another column with the subtracted results. I have: Day DailyAverage 1 97 0.6076782 2 98 0.7121478 3 99 0.8059347 4 100 0.9545806 5
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 seems to crop up
2010 Apr 06
0
[LLVMdev] How to get the left-hand operand of an instruction?
Hi Qiuping yi, > I am a new novice of LLVM, and I want know how to get the left-hand > operand of an instruction? > > For example: > how to get the %temp2 operand in the next instruction: > > %temp2 = malloc i8, i32 %n there is no left-hand side, temp2 is just a name for the instruction. Since the LLVM IR is in SSA form, registers have exactly one definition, and thus there
2013 Jan 28
6
Thank you your help.
Hi, temp3<- read.table(text=" ID CTIME WEIGHT HM001 1223 24.0 HM001 1224 25.2 HM001 1225 23.1 HM001 1226 NA HM001 1227 32.1 HM001 1228 32.4 HM001 1229 1323.2 HM001 1230 27.4 HM001 1231 22.4236 #changed here to test the previous solution ",sep="",header=TRUE,stringsAsFactors=FALSE) ?tempnew<- na.omit(temp3) ?grep("\\d{4}",temp3$WEIGHT) #[1] 7 9 #not correct
2006 Mar 03
1
NA in eigen()
Hi, I am using eigen to get an eigen decomposition of a square, symmetric matrix. For some reason, I am getting a column in my eigen vectors (the 52nd column out of 601) that is a column of all NAs. I am using the option, symmetric=T for eigen. I just discovered that I do not get this behavior when I use the option EISPACK=T. With EISPACK=T, the 52nd eigenvector is (up to rounding error) a