na

Error while creating heatmaps - NA/NaN/Inf in foreign function call (arg 11)

本小妞迷上赌 提交于 2019-12-23 09:03:09
问题 I'm trying to prepare heatmap for my data but I have no idea why this error appears. My data: > dput(head(tbl_ready)) structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.370330677123077, 0, 0, 0, 0, 0, 0.53318856142826, 0, 0, 0, 0, 0, 0.217669675587482, 0, 0, 0, 0.79337589572453, 0, 1, 0.0132525790616207, 0, 0, 1, 0.498415470211292, 0.216961707575178, 0.0646831352678839, 0, 0, 0, 0.778625047514492, 0.165974546372072, 0.076951015613392, 0.889894091237216, 0, 0, 1, 0.129806153151281, 0

R: NA/NaN/Inf in foreign function call (arg 1)

筅森魡賤 提交于 2019-12-22 10:48:10
问题 When i use a package named HydroMe to fit a model, some data groups will return the following errors: Error in qr.default(.swts * attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call (arg 1) Actually,there is no missing value in the data groups. the codes are as followed: library(HydroMe) fortst<-read.csv(file="F:/fortst.csv") van.lis <-nlsList(y~SSvan(x,Thr, Ths, alp, scal)|Sample,data=fortst) the example data canbe download from here: http://www.fileden.com/files/2012/9/13/3346981

NA filling only if “sandwiched” by the same value using dplyr

▼魔方 西西 提交于 2019-12-22 08:29:54
问题 Ok, here is yet another missing value filling question. I am looking for a way to fill NAs based on both the previous and next existent values in a column. Standard filling in a single direction is not sufficient for this task. If the previous and next valid values in a column are not the same, then the chunk remains as NA. The code for the sample data frame is: df_in <- tibble(id= 1:12, var1 = letters[1:12], var2 = c(NA,rep("A",2),rep(NA,2),rep("A",2),rep(NA,2),rep("B",2),NA)) Thanks, 回答1:

Deduplicating/collapsing records in an R dataframe

懵懂的女人 提交于 2019-12-21 20:43:28
问题 I have a dataset that is comprised of various individuals, where each individual has a unique id. Each individual can appear multiple times in the dataset, but it's my understanding that besides differing in one or two variables (there are about 80 for each individual) the values should be the same for each entry for the same user id in the dataset. I want to try to collapse the data if I can. My main obstacle is certain null values that I need to back populate. I'm looking for a function

dplyr idiom for summarize() a filtered-group-by, and also replace any NAs due to missing rows

荒凉一梦 提交于 2019-12-21 05:34:05
问题 I am computing a dplyr::summarize across a dataframe of sales data. I do a group-by (S,D,Y), then within each group, compute medians and means for weeks 5..43, then merge those back into the parent df. Variable X is sales. X is never NA (i.e. there are no explicit NAs anywhere in df), but if there is no data (as in, no sales) for that S,D,Y and set of weeks, there will simply be no row with those values in df (take it that means zero sales for that particular set of parameters). In other

R can't convert NaN to NA

本小妞迷上赌 提交于 2019-12-21 04:28:23
问题 I have a data frame with several factor columns containing NaN 's that I would like to convert to NA 's (the NaN seems to be a problem for using linear regression objects to predict on new data). > tester1 <- c("2", "2", "3", "4", "2", "3", NaN) > tester1 [1] "2" "2" "3" "4" "2" "3" "NaN" > tester1[is.nan(tester1)] = NA > tester1 [1] "2" "2" "3" "4" "2" "3" "NaN" > tester1[is.nan(tester1)] = "NA" > tester1 [1] "2" "2" "3" "4" "2" "3" "NaN" 回答1: Here's the problem: Your vector is character in

Converting Character to Numeric without NA Coercion in R

馋奶兔 提交于 2019-12-21 00:15:24
问题 I'm working in R and have a dataframe, dd_2006, with numeric vectors. When I first imported the data, I needed to remove $'s, decimal points, and some blank spaces from 3 of my variables: SumOfCost, SumOfCases, and SumOfUnits. To do that, I used str_replace_all . However, once I used str_replace_all , the vectors were converted to characters. So I used as.numeric(var) to convert the vectors to numeric, but NAs were introduced, even though when I ran the code below BEFORE I ran the as.numeric

How do I specify different color ranges for different levels?

和自甴很熟 提交于 2019-12-20 19:47:15
问题 I am making a lattice levelplot from x and y factors that range from [0,1]: x y level 1 m3134 m3134 1.0000000 2 m3134 m416B 0.4189057 3 m416B m3134 0.2696508 4 m3134 mA20 0.3322170 5 mA20 m3134 0.2454191 6 m3134 mB 0.3176792 ... Here is the R script that I use to make the figure from this data: #!/foo/bar/bin/Rscript --vanilla args <- commandArgs(TRUE) mtxFn <- args[1] pdfFn <- args[2] mtx <- read.table(mtxFn, col.names=c("x", "y", "level")) mtx$level[(mtx$level == 1)] <- NA library(lattice)

How to omit rows with NA in only two columns in R?

…衆ロ難τιáo~ 提交于 2019-12-20 10:40:04
问题 I want to omit rows where NA appears in both of two columns. I'm familiar with na.omit , is.na , and complete.cases , but can't figure out how to use these to get what I want. For example, I have the following dataframe: (df <- structure(list(x = c(1L, 2L, NA, 3L, NA), y = c(4L, 5L, NA, 6L, 7L), z = c(8L, 9L, 10L, 11L, NA)), .Names = c("x", "y", "z"), class = "data.frame", row.names = c(NA, -5L))) x y z 1 4 8 2 5 9 NA NA 10 3 6 11 NA 7 NA and I want to remove only those rows where NA appears

Seasonal decompose of monthly data including NA in r

陌路散爱 提交于 2019-12-20 10:10:02
问题 I need help from you guys to decompose my monthly data which have seasonality, but it does not work because NA values are not removed..There may be another problem. Please look at my data and errors as below. ts.monthly<-ts(monthly$rBC.median, frequency=12, start=c(2006, 4)) ts.monthly Jan Feb Mar Apr May Jun 2006 5.1656479 6.2847959 19.4833690 2007 1.4252665 2.9127775 2.8912652 7.5326158 8.6182227 23.2129310 2008 NA 1.8200842 1.3488755 2.0700927 5.3541366 8.6916708 2009 1.2531161 1.5075780 2