similar to: Deleting columns based on the number of non-blank observations

Displaying 20 results from an estimated 6000 matches similar to: "Deleting columns based on the number of non-blank observations"

2008 Feb 14
1
deleting certain observations in a data frame
Hi, I'm wondering what the fastest way is to delete certain data points (observations) in a data frame. I have a vector of the indices/row.names I would like to delete. I have tried replacing list by list, but it always complains about different lengths, "replacing list of length a with length b" and so on. Another way to think of it is that it's a generazation of na.rm I
2011 Mar 21
3
Computing row differences in new columns
Hi I have the following columns with dates and results, sorted by subject and date. I'd like to compute the differences in dates and results for each patient, based on the previous row. Obviously the last entry for each subject should be a NA. Which would be the best way to accomplished that ? I guess questions like that have been already answered a thousand times, so I apologize for
2002 Dec 16
3
Manipulating the output from read.spss
This seems like a problem that others may have run into before. I got a merged dataset from SPSS. It has ~750 columns X 3400 rows. Most of the cell entries are NA. There are about 375 rows that contain observations on all variables and I want to extract this subset from the original list (of lists). I'm pretty sure I can do it programmatically in R but it will take me a few hours to write
2008 Aug 20
4
Looping over groups
Hello, My R skills are somewhere between novice and intermediary, and I am hoping that some of you very helpful forum members, whom I've seen work your magic on other peoples' problems/questions, can help me here. I have a matrix with the following format: (i) individual plants comprising many different genotype groups (i.e., a plant is genotype 1 or genotype 2 or genotype 3, etc). The
2005 Aug 05
6
Computing sums of the columns of an array
Hi, I have a 5x731 array A, and I want to compute the sums of the columns. Currently I do: apply(A, 2, sum) But it turns out, this is slow: 70% of my CPU time is spent here, even though there are many complicated steps in my computation. Is there a faster way? Thanks, Martin
2013 Jan 01
1
Order variables automatically
Hi, I have a dataset with 6 categorical variables. I have used this following code to make the variables u1-u6 ordered factors and this works well. cat1cat2 cat3 cat4 cat5 cat6 ? 0 ? ?? 1 ? ? 1????? 0 ??? 0? ?? 1 ? 1 ? ?? 1 ? ? 0 ? ?? 0 ? ? 0 ? ? 0 ....... .... ############ data<-read,table("example.txt") data <- as.data.frame(lapply(data, ordered)) ############ Now,
2006 Jun 21
3
sort matrix by sum of columns
Hi all, I would like to know how can I sort the cols of a matrix by the sum of their elements. a <- matrix(as.integer(rnorm(25,4,2)),10,5) colnames(a) = c("alfa","bravo","charlie","delta","echo") I guess I should use colSums, and then rearrange the matrix somehow according to the result. My idea is to display a "sorted" barplot:
2008 Nov 24
8
matching matrix columns to a vector
I need help with (hopefully) just one more thing. I have been fussing with this for quite some time and have decided just to give up and ask! I want to match a column in a matrix to a vector. I found a "which" command that I thought would be helpful as it does the following: > g=c(1,5,3,2,7) > which(g==5) [1] 2 As the above gave which placement in the g vector corresponded to
2009 Jan 28
2
Logical subset of the columns in a dataframe
Hi R-helpers, I've been struggling with a problem for most of the day (!) so am finally resorting to R-help. I would like to subset the columns of my dataframe based on the frequency with which the columns contain non-zero values. For example, let's say that I want to retain only those columns which contain non-zero values in at least 1% of their rows. In Excel I would calculate a row
2007 Jan 21
1
identify selected substances across individuals
An embedded and charset-unspecified text was scrubbed... Name: inte tillg?nglig Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070121/436ed377/attachment.pl
2009 Jan 20
2
Summing Select Columns of a Data Frame?
Hi, I would like to operate on certain columns in a dataframe, but not others. My data looks like this: x1 x2 x3 1 2 3 4 5 6 7 8 9 I want to create a new column named x4 that is the sum of x1 and x2, but NOT x3. I looked at colSums and apply, but those functions seem to use all the columns in a dataframe. How do I only use select columns? If it helps, in Stata this would be gen x4
2009 Aug 18
4
Remove columns
Hi Everbody Could somebody help me.? I need to remove the columns where the sum of it components is equal to zero. For example > a<-matrix(c(0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,1,0,0,1,0), ncol=4) > a [,1] [,2] [,3] [,4] [1,] 0 0 0 1 [2,] 0 1 0 1 [3,] 0 0 0 0 [4,] 0 1 0 0 [5,] 0 0 0 1 [6,] 0 0 0 0 Columns
2011 Feb 17
4
Find and replace all the elements in a data frame
Hi all, I'm having a problem once again, trying to do something very simple. Consider the following data frame: x <- read.table(textConnection("locus1 locus2 locus3 A T C A T NA T C C A T G"), header = TRUE) closeAllConnections() I am trying to make a new data frame, replacing "A" with "A/A", "T" with "T/T", "G" with
2012 Nov 06
1
plm(): observations not used for modelling
Hello, I have posted this problem before, but thought I try to explain it a bit better. I'm using the function plm to create a fixed effects model for panel data, my method is therefor "within" my effect is "twoways". My Data contains unbalanced Panels due to missing Values, but contains 309 observation for 11 variables (incl. response), with no missing Values. These 309
2013 Jan 17
1
Help with interpolation
hi guys I need to interpolate values for the zero coupon yield curve. Following data is given date days rate 1996 01
2009 Jun 17
3
how to read in only some columns of a data file
Hello, I have a data file (.csv) that has a size of about 2.6 GB. I am not able to read in the whole data set because of the memory limit. I actually only need some columns (3 columns) of the data set, is there a way to read in specified columns? I am using windows. Thanks, Julia -- View this message in context:
2012 Nov 05
1
Plot 3 lines in one graph
I'm new with R. I want to plot 3 lines in one graph. This is my data: print(x) V1 V2 V3 V41 -4800 25195.73 7415.219 7264.282 -2800 15195.73 5415.219 7264.28 I tried using matplot, but I cannot get exactly what I want. This is what I get, and this is my code: matplot(x[,1],x[,-1],type='b', xlab = "epsilon_h", ylab = "Value2", xlim=
2010 Jun 09
1
Subset columns by prefix
Hello R listserve, I would appreciate someone's help with this problem. Consider the following toy dataset: x <- read.table(textConnection("worldclim.1 worldclim.2 cru.1 cru.2 indv.1 7 8 32 658 indv.2 7 7 39 422"), header = TRUE) How could I create a subset of the data based on the column prefix? For instance, let's say I wanted to subset only the columns with the
2010 Sep 23
1
looking for a faster way to compare two columns of a matrix
Please consider this matrix: x <- structure(c(5, 4, 3, 2, 1, 6, 3, 2, 1, 0, 3, 2, 1, 0, 0, 2, 1, 1, 0, 0, 2, 0, 0, 0, 0), .Dim = c(5L, 5L)) For each pair of columns, I want to calculate the proportion of entries different than 0 in column j (i > j) that have lower values than the entries in the same row in column i: x[, 1:2] sum((x[,1] > x[,2]) & (x[,2] > 0))/sum(x[,2] > 0)
2010 Oct 06
2
Pointing to a specific place on the x-axis with an arrow
Hi all, I am trying to do something simple, but which is deviling me. I want to add an up-arrow to the x-axis, pointing to a specific location on the axis. I want the arrow to be as large as possible. Here is where I'm at with my code: #this part if from the ?plot example: require(stats) plot(cars) lines(lowess(cars)) #I am trying to use mtext to add the arrow... but I don't know how