similar to: Subsetting by a logical condition and NA's

Displaying 20 results from an estimated 10000 matches similar to: "Subsetting by a logical condition and NA's"

2003 Apr 02
19
Combining the components of a character vector
Dear Help, Suppose I have a character vector. x <- c("Bob", "loves", "Sally") I want to combine it into a single string: "Bob loves Sally" . paste(x) yields: paste(x) [1] "Bob" "loves" "Sally" The following function combines the character vector into a string in the way that I want, but it seems somewhat inelegant.
2002 Dec 20
2
vectorizing test for equality
Dear R Help, I am trying to create a boolean vector that is TRUE whenever a particular value occurs in a numeric vector, and FALSE otherwise. For example, suppose that > y <- c(5, 2, 4, 3, 1) > y [1] 5 2 4 3 1 and suppose that I want to find where 3 occurs in y. Then, the following yields the solution: > y == 3 [1] FALSE FALSE FALSE TRUE FALSE My problem arises when the
2003 Mar 22
1
extracting the names of the dataframe and variables in aov or lm
Dear R Users, I want to write a function that applies to the dataframe and variables that were used in a previous call to lm or aov. In order to do this, I need to write a function that applies to the output of lm or aov, and yields the names of the dataframe and variables that were used in the lm or aov analysis. For example, suppose that I give the command: aov.out <- aov( Rt ~
2006 Feb 24
2
converting character matrix to a dataframe
Dear R-Help, Suppose I have a character matrix, e.g., (ch.mat <- matrix(c('a','s','*','f','w','*','k','*','*','f','i','o'), ncol=3)) When I convert 'ch.mat' to a dataframe, the columns are converted to factors: (d1 <- data.frame(ch.mat)) mode(d1[,1]) is.factor(d1[,1]) To prevent
2001 Oct 31
3
t.test
Dear R-users, I am learning to use R 1.3.1 on a Pentium running Windows '98. I'm puzzled that several statistical procedures, t.test and chisq.test, do not appear to be available on R version 1.3.1. For example, if I type "t.test", I get the reply, "Object "t.test" not found". Is there a package that I have to load in order to have access to these
2002 Apr 19
4
Multidimensional scaling
A student of mine wants to use R to do some nonmetric multidimensional scaling. According to the R FAQ, there's a package called pcurve that computes multidimensional scaling solutions, but I was not able to locate it the contrib page (I am a Windows user with R version 1.4.1). Can anyone tell me whether it is possible to do nonmetric multidimensional scaling with R, and if so, how? John
2002 Dec 22
4
pasting "\" into character strings
Dear R-Help, I'm using R version 1.6.0 on a Windows computer. I am trying to create a function that, among other things, constructs strings that refer to Windows files, e.g., I might want to construct a string like 'c:\work\part1.txt'. I have found that the following does not work. > paste("c:", "\", "work", "\", "part1.txt",
2004 Apr 05
0
studentized deleted residuals and NA's
Dear R-Help, I am using the studres function from the MASS package to compute studentized deleted residuals in a oneway anova. I'm having trouble interpreting the results in situations where a factor level has only one observation. Sometimes studres yields an NaN and sometimes it produces a numeric value for cases where a factor level has only one observation. I would think it should
2002 Oct 10
2
Environment variables under Windows
Greetings, I have a question pertaining to the concept of "environment variables" that is mentioned in the R documentation for "Startup" and also in the discussion of the Windows configuration of R in the recent book "An Introduction to R" authored by Venables, Smith, and the R Development Core Team (referred to as VS in this message). The Startup documentation and
2003 Oct 14
0
Job notice at the University of Washington
UNIVERSITY OF WASHINGTON FACULTY POSITION IN QUANTITATIVE PSYCHOLOGY The Department of Psychology seeks to fill a position in Quantitative Psychology at the tenure-track assistant professor level. In exceptional circumstances, appointment at the Associate Professor or Professor level may be considered for candidates who offer extraordinary opportunities to further the University's
2002 Apr 23
0
Summary: Multidimensional scaling
I sent a query to R-Help about the availability of nonmetric multidimensional scaling (MDS) algorithms in R. I would like to thank Tony Rossini, Jonathan Baron, Sundar Dorai-Raj, and Brian Ripley for helpful replies. The gist of the replies is that isoMDS in the MASS library provides Kruskal's method for nonmetric MDS, sammon in the MASS library provides Sammon's nonlinear mapping method
2002 Apr 08
2
subsetting with NA's
Hi, I often have large dataframes with many variables and many NA's, from which I would like to subset out some rows. Here is a toy example: > x <- data.frame(a = c("x", "y", "z"), b = c(1, NA, 5)) > x a b 1 x 1 2 y NA 3 z 5 I realize that, if I know the values in x$b that I want to subset, things are easy: > x[x$b %in% c(1),] a b 1 x 1
2004 Jan 20
3
Changing workspace from within an R session
Hello R-users, is it possible to navigate from one workspace to the other from within an R session or does one has to close R and restart it from the directory where resides the desired workspace? For example from Splus I have this little function, see at the end, which I used all the time to navigate between valid Splus directories. I find this particularly usefull when I develop new
2017 Oct 25
0
Problem Subsetting Rows that Have NA's
On Tue, Oct 24, 2017 at 3:05 PM, BooBoo <booboo at gforcecable.com> wrote: > This has every appearance of being a bug. If it is not a bug, can someone > tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks. You are asking for elements of x where the second column is equal to zero. help("==") and help("[") explain what happens when
2006 Sep 04
3
Subsetting vectors based on condition
Hello, I have a question regarding subsetting of vectors. Here's an example of what I'm trying to do: vect.1 <- c(76,195, 290, 380) vect.2 <- c(63, 95, 133, 170, 215, 253, 285, 299, 325, 375) I would like to subset vect.2 so that it has the same length as vect.1, and its numbers are the first corresponging higher value compared to vect.1. The output should be: final.output =
2011 Jun 01
4
subsetting with condition
Dear R Team, I am a new R user and I am currently trying to subset my data under a special condition. I have went through several pages of the subsetting section here on the forum, but I was not able to find an answer. My data is as follows: ID NAME MS Pol. Party 1 John x F 2 Mary s S
2017 Oct 24
5
Problem Subsetting Rows that Have NA's
This has every appearance of being a bug. If it is not a bug, can someone tell me what I am asking for when I ask for "x[x[,2]==0,]". Thanks. > #here is the toy dataset > x <- rbind(c(1,1),c(2,2),c(3,3),c(4,0),c(5,0),c(6,NA), + c(7,NA),c(8,NA),c(9,NA),c(10,NA) + ) > x [,1] [,2] [1,] 1 1 [2,] 2 2 [3,] 3 3 [4,] 4 0 [5,] 5 0
2002 Sep 24
4
extracting elements from summary(aov object)
Hello. When one types "summary(fit)", where fit is an object from a call to aov(), one gets an ANOVA table. I want to save just one element of this summary. How does one extract this? As an example, here is my output from a split plot ANOVA: > summary(out)$"Error: soil.cores$block:soil.cores$treatment" Df Sum Sq Mean Sq F value Pr(>F)
2012 Apr 28
2
Segmentation Fault when Starting domUs
Hello everyone, I just put together a brand new system, and I''m getting the following when I try to start a domU: > [ 1902.049066] xend[12924]: segfault at b9ff6cd8 ip 00007f36c474afe1 sp 00007f36b9ff6af8 error 4 in libxenguest.so.4.0.0[7f36c4730000+24000] This is on an AMD CPU with the AVX instructions, and I already have this in my grub.cfg: > multiboot /xen-4.1.2.gz
2008 Aug 22
1
subset grouped data with quantile and NA's
I can't quite seem to solve a problem subsetting a data frame. Here's a reproducible example. Given a data frame: dat <- data.frame(fac = rep(c("a", "b"), each = 100), value = c(rnorm(130), rep(NA, 70)), other = rnorm(200)) What I want is a new data frame (with the same columns as dat) excluding the top 5% of "value"