similar to: Skip last NA's?

Displaying 20 results from an estimated 10000 matches similar to: "Skip last NA's?"

2006 May 30
3
Time rather than dates?
Using strptime() and other functions for dates has been very helpful with the kind of data I often work with. However, I haven't found out how time as such should be specified. All my attempts result in time *and* date: >treatment_time<-c("01:02:03","02:03:04") # hours:minutes:seconds >time.2<-strptime(treatment_time,format="%H:%M:%S") >time.2 [1]
2006 May 30
4
Add text/numbers to x axis?
Is there any simple way to add text to the x axis in R? I have tried to add simple characters in R without any greater sucess. As an example of what I want to do is the added C in the following "dumb" plot (produced with MacAnova using the option "dumb:T"): ++------+-------+------+-------+------+-------+------+-------++ 1+ :
2006 May 30
4
Automate concatenation?
I have this typical problem of joining a number of vectors with similar names - a1, a2,..., a10 - which should be concatenated into one. Using c(a1,a2,a3,a4,a5,a6,a,a8,a9,a10) naturally works, but I would like to do it with less manual input. My attempts to use paste() gives a vector of the vector names, see below. The question is how to do the the concatenation? Any suggestions?
2003 Nov 14
4
LOCF - Last Observation Carried Forward
Hi! Is there a possibilty in R to carry out LOCF (Last Observation Carried Forward) analysis or to create a new data frame (array, matrix) with LOCF? Or some helpful functions, packages? Karl --------------------------------- Gesendet von http://mail.yahoo.de Schneller als Mail - der neue Yahoo! Messenger. [[alternative HTML version deleted]]
2005 Sep 20
5
Add function to histogram?
Is there any neat way to add a curve (frequency function or the like) to a histogram or other plots? I haven't found one yet... Robert
2006 Mar 08
1
info() function?
I would like to have some function for getting an overview of the variables in a worksheet. Class, dimesions, length, number of missing values,... Guess it wouldn't be that hard to set up such a function, but I guess there are others who have made it already. Or is it already a standard feature in the base package? Any suggestions? Robert
2008 Nov 13
1
replacing Na's in a vector with the preceding integer element
Hi, I have a vector where an integer is followed by a randomly varying number of NA elements. I want to replace the NA's with the preceding integer. Let me explain with a simple?example : avec<- c(1,NA,NA,5,NA,3,4,NA,NA,NA,NA,9,NA,0,NA,NA) I want to get the following vector from a : bvec<-c(1,1,1,5,5,3,4,4,4,4,4,9,9,0,0,0) How can I do this with R? Will appreciate all the help that I
2008 Jul 28
3
Fill in NA values in vector with previous character/factor
I have a vector of data (species names) interspersed with NA values and I want a function to "fill in the blanks", replacing NA values with whatever the last species name was. For example the vector: "A","B",NA,NA,"C",NA,NA,NA,NA,"D",NA,NA. should evaluate to: "A" "B" "B" "B" "C"
2005 May 17
2
cumsum on chron objects
Hi, Is there some alternative to cumsum for chron objects? I have data frames that contain some chron objects that look like this: DateTime 13/10/03 12:30:35 NA NA NA 15/10/03 16:30:05 NA NA ... and I've been trying to replace the NA's so that a date/time sequence is created starting with the preceding available value. Because the number of rows with NA's following each available
2011 Jun 22
3
Documenting variables, dataframes and files?
Every now and then I realize that my attempts to document what all dataframes consist of are unsufficient. So far, I have been writing notes in an external file. Are there any better ways to do this within R? One possibility could be to set up the data as packages, but I would like to have a solution on a lower level, closer to data. I can't find any pointers in the standard manuals.
2013 Mar 18
2
data.frame with NA
I have this little data.frame http://dl.dropbox.com/u/102669/nanotna.rdata Two column contains NA, so the best thing to do is use na.locf function (with fromLast = T) But locf function doesn't work because NA in my data.frame are not recognized as real NA. Is there a way to substitute fake NA with real NA? In this case na.locf function should work Thank you
2011 Sep 30
1
last observation carried forward +1
Hi R-helpers I'm looking for a vectorised function which does missing value replacement as in last observation carried forward in the zoo package but instead of a locf, I would like the locf function to add +1 to each time a missing value occurred. See below for an example. > require(zoo) > x <- 5:15 > x[4:7] <- NA > coredata(na.locf(zoo(x))) [1] 5 6 7 7 7 7 7 12 13
2010 May 11
3
Smoothing Techniques - short stepwise functions with spikes
R Friends, I have data from which I would like to learn a more general (smoothened) trend by applying data smoothing methods. Data points follow a positive stepwise function. | x x | xxxxxxxx xxxxxxxx | x x |xxxx xxx xxxx | xxxxxxxxxxxxxxxxx | |
2009 Jun 18
3
Replace zeroes in vector with nearest non-zero value
Folks, If I have a vector such as the following: x <- c(0, -1, -1, -1, 0, 0, 1, -1, 1, 0) and I want to replace the zeroes by the nearest non-zero number to the left, is there a more elegant way to do this than the following loop? y <- x for (i in 2 : length(x)) { if (y[i] == 0) { y[i] <- y[i - 1] } } > y [1] 0 -1 -1 -1 -1 -1 1 -1 1 1 You can see the
2009 Oct 10
2
Matching Dates Closest without going over
Hi, I have 2 date vectors d1 and d2. d1 <- structure(c(14526, 14495, 14464, 14433, 14402, 14371, 14340, 14309, 14278, 14247, 14216, 14185), class = "Date") d2 <- structure(c(14526, 14509, 14488, 14466, 14453, 14441, 14396, 14388, 14343, 14333, 14310, 14281), class = "Date") I would like to create another dataframe with columns d1 and d2, where d1 is the original d1
2012 Jul 02
2
using "na.locf" from package zoo to fill NA gaps
Hi everybody, I have a small question about the function "na.locf" from the package "zoo". I saw in the help that this function is able to fill NA gaps with the last value before the NA gap (or with the next value). But it is possible to fill my NA gaps according to the last AND the next value at the same time? Actually, I want R to fill my gaps with the method of
2017 Sep 15
1
Calculating Weeks Since Last Event
Hi, I have an input data > dput (input) structure(list(ScanDate = structure(c(16433, 16440, 16447, 16454, 16461, 16468, 16475, 16482, 16489, 16496, 16503, 16510, 16517, 16524, 16531, 16538, 16545, 16552, 16559, 16566, 16573, 16580, 16587, 16594, 16601, 16608, 16615, 16622), class = "Date"), OnPromotion = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1,
2011 May 12
3
assigning creating missing rows and values
I have a dataset where I have missing times (11:00 and 16:00). I would like the outputs to include the missing time so that the final time vector looks like "realt" and has the previous time's value. Ex. If meas at time 15:30 is 0.45, then the meas for time 16:00 will also be 0.45. meas are the measurements and times are the times at which they were taken. meas<-runif(18)
2006 Jan 03
2
For loop gets exponentially slower as dataset gets larger...
I am running R 2.1.1 in a Microsoft Windows XP environment. I have a matrix with three vectors (“columns”) and ~2 million “rows”. The three vectors are date_, id, and price. The data is ordered (sorted) by code and date_. (The matrix contains daily prices for several thousand stocks, and has ~2 million “rows”. If a stock did not trade on a particular date, its price is set to “NA”)
2011 Oct 09
1
help with using last observation carried forward analysis for a clinical trial please
Hi, I have a series of id's with multiple visits and questionnaire scores. This is a clinical trial that will be analyzed using the last observation carried forward method. In other words, in order to comply with intent to treat analysis when many subjects withdraw, data points for the last visit must be generated and filled in with the last observation. The ultimate goal is to tabulate the