na

delete NAs to move data up, no stairs anymore

牧云@^-^@ 提交于 2020-06-04 02:22:35
问题 The data file that I get from an experiment looks like this VP Selbst ES eigForm eigES andForm andES MM MMRT Wunschform Geschlecht Muttersprache Alter 99 1 unhöflich NA NA NA NA NA NA 99 5 gesellig NA NA NA NA NA NA 99 6 ehrlich NA NA NA NA NA NA 99 NA 5 gründlich NA NA NA NA NA 99 NA 6 treu NA NA NA NA NA 99 NA 5 romantisch NA NA NA NA NA 99 NA NA 6 stark NA NA NA NA 99 NA NA 3 klein NA NA NA NA 99 NA NA 5 rational NA NA NA NA 99 NA ordentlich NA NA ["y"] [0.4] NA NA NA NA 99 NA sentimental

delete NAs to move data up, no stairs anymore

☆樱花仙子☆ 提交于 2020-06-04 02:19:59
问题 The data file that I get from an experiment looks like this VP Selbst ES eigForm eigES andForm andES MM MMRT Wunschform Geschlecht Muttersprache Alter 99 1 unhöflich NA NA NA NA NA NA 99 5 gesellig NA NA NA NA NA NA 99 6 ehrlich NA NA NA NA NA NA 99 NA 5 gründlich NA NA NA NA NA 99 NA 6 treu NA NA NA NA NA 99 NA 5 romantisch NA NA NA NA NA 99 NA NA 6 stark NA NA NA NA 99 NA NA 3 klein NA NA NA NA 99 NA NA 5 rational NA NA NA NA 99 NA ordentlich NA NA ["y"] [0.4] NA NA NA NA 99 NA sentimental

delete NAs to move data up, no stairs anymore

强颜欢笑 提交于 2020-06-04 02:19:40
问题 The data file that I get from an experiment looks like this VP Selbst ES eigForm eigES andForm andES MM MMRT Wunschform Geschlecht Muttersprache Alter 99 1 unhöflich NA NA NA NA NA NA 99 5 gesellig NA NA NA NA NA NA 99 6 ehrlich NA NA NA NA NA NA 99 NA 5 gründlich NA NA NA NA NA 99 NA 6 treu NA NA NA NA NA 99 NA 5 romantisch NA NA NA NA NA 99 NA NA 6 stark NA NA NA NA 99 NA NA 3 klein NA NA NA NA 99 NA NA 5 rational NA NA NA NA 99 NA ordentlich NA NA ["y"] [0.4] NA NA NA NA 99 NA sentimental

R unique columns or rows incomparables with NA

六月ゝ 毕业季﹏ 提交于 2020-05-26 04:02:10
问题 Anyone know if the incomparables argument of unique() or duplicated() has ever been implemented beyond incomparables=FALSE ? Maybe I don't understand how it is supposed to work... Anyway I'm looking for a slick solution to keep only unique columns (or rows) that are identical to another column besides extra NA s? I can brute force it using cor() for example, but for tens of thousands of columns, this is intractable. Heres an example, sorry if its a little messy, but I think it illustrates the

R unique columns or rows incomparables with NA

為{幸葍}努か 提交于 2020-05-26 04:00:23
问题 Anyone know if the incomparables argument of unique() or duplicated() has ever been implemented beyond incomparables=FALSE ? Maybe I don't understand how it is supposed to work... Anyway I'm looking for a slick solution to keep only unique columns (or rows) that are identical to another column besides extra NA s? I can brute force it using cor() for example, but for tens of thousands of columns, this is intractable. Heres an example, sorry if its a little messy, but I think it illustrates the

Fill missing values rowwise (right / left)

…衆ロ難τιáo~ 提交于 2020-05-23 17:35:32
问题 I'm looking for a way to "fill" NA s to the right (as opposed to down/up) with dplyr. In other words, I would like to convert d into d2 without having to explicitly reference any columns in a mutate call. My real dataframe has several 10s of fields with staggered blocks of NAs spanning variable numbers of columns. I'm curious whether there's a short way to globally inherit the first non-NA value to the left, regardless of what field it occurs in. d<-data.frame(c1=c("a",1:4), c2=c(NA,2,NA,4,5)

Finding the index of an NA value in a vector [duplicate]

旧时模样 提交于 2020-05-23 06:12:10
问题 This question already has an answer here : How can I find the index of all NA in a dataframe column? (1 answer) Closed 6 years ago . I have the following vector: x <- c(3, 7, NA, 4, 8) And I just want to know the index of the NA in the vector. If, for instance, I wanted to know the index of 7 , the following code would work: > which(x == 7) [1] 2 I find it odd that running the same code when trying to find the index of the NA does not give me the desired result. > which(x == NA) integer(0) I

Dealing dataframes with conditional statements

為{幸葍}努か 提交于 2020-05-14 08:49:50
问题 Following the previous two questions: removing the first 3 rows of a group with conditional statement in r Assigning NAs to rows with conditional statement in r I'm having some troubles with my code. If Instead of deleting rows, I want to assign NAs to every event that has in their first row a Value higher than 2. So, if an event is having in its first row a Value higher than 2, I want to assign NA to that row, and to the coming two rows of that event. If the event has no more rows, just

Dealing dataframes with conditional statements

萝らか妹 提交于 2020-05-14 08:49:08
问题 Following the previous two questions: removing the first 3 rows of a group with conditional statement in r Assigning NAs to rows with conditional statement in r I'm having some troubles with my code. If Instead of deleting rows, I want to assign NAs to every event that has in their first row a Value higher than 2. So, if an event is having in its first row a Value higher than 2, I want to assign NA to that row, and to the coming two rows of that event. If the event has no more rows, just

ggplot line graph with NA values

匆匆过客 提交于 2020-04-05 15:20:11
问题 I'm having with trouble with ggplot trying to plot 2 incomplete time series on the same graph where the y data does not have the same values on the x-axis (year) - NAs are thus present for certain years : test<-structure(list(YEAR = c(1937, 1938, 1942, 1943, 1947, 1948, 1952, 1953, 1957, 1958, 1962, 1963, 1967, 1968, 1972, 1973, 1977, 1978, 1982, 1983, 1986.5, 1987, 1993.5), A1 = c(NA, 24, NA, 32, 32, NA, 34, NA, NA, 18, 12, NA, 10, NA, 11, NA, 15, NA, 24, NA, NA, 25, 26), A2 = c(40, NA, 38,