[R] Subtraction loop

2010-06-28 Thread ecvetano
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 Da

[R] Calculating a daily average

2010-06-21 Thread ecvetano
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 d

[R] 3D ncdf file

2010-06-14 Thread ecvetano
Hello, I have an ncdf file with different variables for dimensions and dates where the dimensions are as follows, where X=i and Y=j creating a 88 by 188 set of cells. For each cell there are 12 readings for DO taken at 2 hour intervals and recoded by according to the Julian calendar under

[R] How to skip negative values when calculating average

2010-05-31 Thread ecvetano
I have a data frame 10 by 12 with positive and negative numbers. I want to select only the positive numbers and find the average. This calculates the average of everything: av5 <- subset(ER9r, Day == 253, select = c (Depth1j:Depth0.75j) av5 <- mean(av5) I need something along the lines of "sel

[R] if negative value, make zero

2010-05-28 Thread ecvetano
I have a data frame with both positive and negative values, and I want to make all the negative values equal zero, so i can eventually take an average. I've tried temp2 <- ifelse(tempr<0, 0, tempr) but it doesn't seem to work. Any suggestions? Thanks! ___

[R] How to calculate mean of means

2010-05-26 Thread ecvetano
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 __

[R] Repeating Name for Rows

2010-05-18 Thread ecvetano
Hello, I have a large data frame (47:2186), where i want to label every 12th row. This command works, Day <-rep(97:278, each = 12) However i need 97 to only labeled 11 rows and then from 98:278 can be labeled every 12 times. Thanks! __ R-help@r-proj

[R] Adding a row at top of dataframe

2010-05-17 Thread ecvetano
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 app

[R] Adding name to nth row

2010-05-13 Thread ecvetano
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! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do rea