similar to: Why does R replace all row values with NAs

Displaying 20 results from an estimated 90000 matches similar to: "Why does R replace all row values with NAs"

2015 Mar 03
2
[R] Why does R replace all row values with NAs
Diverted from R-help : .... as it gets into musing about new R language "primitives" >>>>> William Dunlap <wdunlap at tibco.com> >>>>> on Fri, 27 Feb 2015 08:04:36 -0800 writes: > You could define functions like > is.true <- function(x) !is.na(x) & x > is.false <- function(x) !is.na(x) & !x > and use
2015 Mar 03
2
[R] Why does R replace all row values with NAs
On 3/3/15 1:26 PM, Herv? Pag?s wrote: > > > On 03/03/2015 02:28 AM, Martin Maechler wrote: >> Diverted from R-help : >> .... as it gets into musing about new R language "primitives" >> >>>>>>> William Dunlap <wdunlap at tibco.com> >>>>>>> on Fri, 27 Feb 2015 08:04:36 -0800 writes: >> >> >
2015 Mar 03
0
[R] Why does R replace all row values with NAs
On 03/03/2015 02:28 AM, Martin Maechler wrote: > Diverted from R-help : > .... as it gets into musing about new R language "primitives" > >>>>>> William Dunlap <wdunlap at tibco.com> >>>>>> on Fri, 27 Feb 2015 08:04:36 -0800 writes: > > > You could define functions like > > > is.true <- function(x)
2015 Mar 03
0
[R] Why does R replace all row values with NAs
Stephanie, Actually, it's as.logical that isn't preserving matrix dimensions, because it coerces to a logical vector: > x <- matrix(sample(c(NA_integer_, 1:100), 500, replace=TRUE), nrow=50) > dim(as.logical(x)) NULL ~G On Tue, Mar 3, 2015 at 2:09 PM, Stephanie M. Gogarten < sdmorris at u.washington.edu> wrote: > > > On 3/3/15 1:26 PM, Herv? Pag?s wrote: >
2010 Mar 30
1
Efficiency question: replacing all NAs with a zero
Dear R'ers, I have a very large data frame (over 4000 rows and 2,500 columns). My task is very simple - I have to replace all NAs with a zero. My code works fine on smaller data frames - but I have to deal with a huge one and there are many NAs in each column. R runs out of memory on me ("Reached total allocation of 1535Mb: see help(memory.size)"). Is there any other, more efficient
2011 Aug 05
2
summing columns with NAs present
Hello! I have a data frame with some NAs. test<-data.frame(a=c(1,2,NA),b=c(10,NA,20)) I need to sum up values in 2 variables. However: test$a+test$b procudes NAs in rows that have NAs. How could I sum up columns while ignoring NAs (the way the function sum(..., na.rm=T) works? Thank you! -- Dimitri Liakhovitski marketfusionanalytics.com
2009 Sep 17
2
referring to a row number and to a row condition, and to columns simultaneously
Hello, dear R-ers! I have a data frame: x<-data.frame(a=c(4,2,4,1,3,4),b=c(1,3,4,1,5,0),c=c(NA,2,5,3,4,NA),d=rep(NA,6),e=rep(NA,6)) x When x$a==1, I would like to replace NAs in columns d and e with 8 and 9, respectively When x$a != 1, I would like to replace NAs in columns d and e 101 and 1022, respectively. However, I only want to do it for rows 2:5 - while ignoring what's happening in
2017 Jul 27
2
na.rm = T treatment by ggplot2's geom_bar
I think you should be more suspicious of yourself, Dimitri. A letter T variable can easily arise in the problem domain when you are not thinking of logical values at all, at which point your cavalier use of T as a synonym for TRUE can suddenly become a bug. -- Sent from my phone. Please excuse my brevity. On July 27, 2017 8:18:03 AM PDT, Dimitri Liakhovitski <dimitri.liakhovitski at
2017 Jul 27
2
na.rm = T treatment by ggplot2's geom_bar
Just a thought: Did you try na.rm = TRUE in case you have an object named "T" in scope? -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Jul 27, 2017 at 7:49 AM, Dimitri Liakhovitski <dimitri.liakhovitski at
2017 Jul 27
3
na.rm = T treatment by ggplot2's geom_bar
Hello! I am trying to understand how ggplot2's geom_bar treats NAs. The help file says: library(ggplot2) ?geom_bar na.rm: If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed. I am trying it out: md <- data.frame(a = c(letters[1:5], letters[1:4], letters[1:3], rep(NA, 3))) str(md); levels(md$a) ggplot(data = md, mapping = aes(x =
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
?hanks for the advice, Jeff. Will keep it in mind. But I am anal - I shy away from using letters and words that "look familiar" to me in R (such as mean, sd, T, etc.) But still, it's a good advice. On Thu, Jul 27, 2017 at 11:53 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > I think you should be more suspicious of yourself, Dimitri. A letter T > variable can
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
To clarify: my question is not about "who could I exclude NAs from being counted" - I know how to do that. My question is: Why na.rm = T is not working for geom_bar in this case? On Thu, Jul 27, 2017 at 8:24 AM, Dimitri Liakhovitski < dimitri.liakhovitski at gmail.com> wrote: > Hello! > > I am trying to understand how ggplot2's geom_bar treats NAs. > The help file
2017 Jul 27
0
na.rm = T treatment by ggplot2's geom_bar
Thank you, Bert! I do NOT have an object named "T" in scope (I checked - and besides, it would never occur to me to use this name). TRUE or T results in the same unexpected behavior: ggplot(data = md, mapping = aes(x = a)) + geom_bar(na.rm = TRUE) On Thu, Jul 27, 2017 at 10:57 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > Just a thought: > > Did you try
2017 Jul 27
1
na.rm = T treatment by ggplot2's geom_bar
I suspect this is by design. Questions about "why" should probably cc the contributed package maintainer(s). -- Sent from my phone. Please excuse my brevity. On July 27, 2017 7:49:47 AM PDT, Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com> wrote: >To clarify: my question is not about "who could I exclude NAs from >being >counted" - I know how to do
2010 Mar 30
4
Code is too slow: mean-centering variables in a data frame by subgroup
Dear R-ers, I have a large data frame (several thousands of rows and about 2.5 thousand columns). One variable ("group") is a grouping variable with over 30 levels. And I have a lot of NAs. For each variable, I need to divide each value by variable mean - by subgroup. I have the code but it's way too slow - takes me about 1.5 hours. Below is a data example and my code that is too
2008 Dec 19
2
Merging data frames of different length
Hello, everyone! I have list L that contains 99 data frames. All data frames have only one row, but a different number of columns. Some data frames have 3 columns, some - 6 columns, and some - 9 columns. The names of the first 3 columns are identical in all 99 data frames (e.g., A, B, and C). The names of columns 4:6 are identical in data frames that contain 6 and 9 columns (e.g., D, E, and F).
2013 Mar 20
2
Dealing with missing values in princomp (package "psych")
Hello! I am running principle components analysis using princomp function in pacakge psych. mypc <- princomp(mydataforpc, cor=TRUE) Question: I'd like to use pairwise deletion of missing cases when correlations are calculated. I.e., I'd like to have a correlation between any 2 variables to be based on all cases that have valid values on both variables. What should my na.action be in
2012 Apr 06
3
filling the matrix row by row in the order from lower to larger elements
Hello, everybody! I have a matrix "input" (see example below) - with all unique entries that are actually unique ranks (i.e., start with 1, no ties). I want to assign a value of 100 to the first row of the column that contains the minimum (i.e., value of 1). Then, I want to assign a value of 100 to the second row of the column that contains the value of 2, etc. The results I am looking
2009 Oct 13
4
replacing period with a space
Dear R-ers! I have x as a variable in a data frame x. x<-data.frame(x=c("aa.bb","cc.dd.ee")) x$x<-as.character(x$x) x I am sorry for such a simple question - but how can I replace all periods in x$x with spaces? sub('.', ' ', x$x) - removes all letters to the left of each period... Thanks a lot for your advice! -- Dimitri Liakhovitski Ninah.com
2009 Mar 26
2
Analogy for %in% for the whole columns (rather than individual values)
Hello! I have a matrix a with 2 variables (see below) that contain character strings. I need to create a 3rd variable that contains True if the value in column x is equal to the value in column y. The code below does it. a<-data.frame(x=c("john", "mary", "mary", "john"),y=c("mary","mary","john","john"))