Displaying 20 results from an estimated 10000 matches similar to: "how to add a derived column to a data frame?"
2011 Jun 02
3
Removing rows of zeros from a matrix
Hi,
Can someone tell me how to remove rows of zeros from a matrix?
For example if I have the following matrix,
0 0
0 1
2 8
0 0
4 56
I should end up with
0 1
2 8
4 56
--
Thanks,
Jim.
[[alternative HTML version deleted]]
2012 Mar 28
6
How to get all possible combinations?
Dear all, suppose I have a vector with elements as:
Vec <- c(2,3,4,5,6)
Now I want to have all possible combination of length 3 using those
elements and without any repetition. Like, I want to have 1
possibility like 2-3-4 but not 3-2-4.
Can somebody guide me how to achieve that in R?
Thanks for your help.
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
List members,
Via searches I've seen similar discussion of this topic but have not seen
resolution of the particular issue I am experiencing. If my search on this
topic failed, I apologize for the redundancy. I am attempting to generate
random covariance matrices but would like the corresponding correlations to
be uniformly distributed between -1 and 1.
The approach I have been using is:
2011 Jan 27
2
help for a loop procedure
Hello everybody!
I’m trying to define the optimal number of surveys to detect the highest
number of species within a monitoring season/session.
To do this I want to run all the possible combinations between a set of
samples and to calculate the total number of species for each combination of
2, 3, 4 …n samples events, so that at the end I will be able to define which
is the lowest number of
2011 Apr 04
1
Support Counting
Hi,
I'm new to R and trying to some simple analysis. I have a data set with
about 88000 transactions and i want to perform a simple support count
analysis of an itemset which is say not a complete transaction but a subset
of a transaction.
say
{A,B,D} is a transaction and i want to find support of {A,B} even though it
never occurs as only A,B in the entire set
To this i needed to create
2011 Jan 05
4
Match numeric vector against rows in a matrix?
Two posts in one day is not a good day...and this question seems like it should have an obvious answer:
I have a matrix where rows are unique combinations of 1's and 0's:
> combs=as.matrix(expand.grid(c(0,1),c(0,1)))
> combs
Var1 Var2
[1,] 0 0
[2,] 1 0
[3,] 0 1
[4,] 1 1
I want a single function that will give the row index containing an exact match
2012 Jun 12
4
How to subset a matrix?
Hi all,
Lets say I have a matrix A which is m x n.
I also have a mask matrix MASK which is m x n with values in T/F, where T
values make a sub-matrix in regutangular shape...
I applied B=A[MASK] and it didn't work as expected...
Any thoughts?
[[alternative HTML version deleted]]
2010 Nov 28
4
how to divide each column in a matrix by its colSums?
Hi,
I have a matrix, say
m=matrix(c(
983,679,134,
383,416,84,
2892,2625,570
),nrow=3
)
i can find its row/col sum by
rowSums(m)
colSums(m)
How do I divide each row/column by its rowSum/colSums and still return in
the matrix form?
(i.e. the new rowSums/colSums =1)
Thanks.
Casper
--
View this message in context:
2012 Mar 22
4
Plotting patient drug timelines using ggplot2 (or some other means) -- Help!!!
Hello All,
Want very much to learn how to plot patient drug timelines. Trouble is I need to figure out how to do this today. So not much time for me to struggle with it. Hoping someone can just help me out a bit.
Below are some sample data and code that produces what I think is the beginning of a very nice graph.
Need to alter the code to:
1. Get the lines for the drugs to appear on the
2012 Aug 16
1
sum over extremely small numbers
Dear All,
I am evaluating the value of loglikelihood and it ends up with the sum of
tiny numbers.
Below is an example: suppose I would like to calculate sum_i (log (sum_j x
[i, j] )), the index of log (x) is in the range, say (-2000, 0). I am aware
that exp(-744.5) will be expressed as 0 in 32 bit R and exp
Is there a way to improve the result?
R example:
powd <- sample(-2000:0, 100,
2002 Jun 29
0
电脑配件惊爆抢购价 samba
̨ʤÏòÄãÎʺÃ!
ÎÒ¹«Ë¾³¤ÆÚ´Óʹú¼ÊóÒ×,ΪÍÚ¾òÊг¡Ç±Á¦¡¢À©´ó¾Óª¹æÄ£,ÒâÔÚ¹óµØ
ѰÕÒÁôÒ×´°¿Ú,ÌØ½«´Ë¼Ûͬ±í³Ê¹óµ¥Î»²Î¿¼.ÎÒ˾ÌṩһÁ÷Æ·ÖÊ,Ò»Á÷·þÎñ,ËÍ»õÉÏÃÅ,
»õµ½¸¶¿î, ÅúÁí¾ù¿É.»¶Ó¸÷½çÅóÓÑÀ´µç´¹Ñ¯¼°Ö§³Ö.¶àл!!!
̨ʤ¹«Ë¾
ÖйúITóÒײ¿ :ÇØ Áú ͼ
ÇëÎðÖ±½Ó»Ø¸´£¬ÓÐÒâÕßÇëÀ´µç ------0139-59726696
Ò»:±Ê¼Ç±¾µçÄÔ(È«ÇòÁª±£µ¥,ÈýÄê)
±Ê¼Ç±¾µçÄÔÊÖ»úÉÏÍø×¨ÓÃPC¿¨----------1450Ôª
A . Ë÷Äá SONY
SR/27K(4500Ôª)
2002 Jul 23
0
电脑配件惊爆价 samba
̨ÕýÏòÄãÎʺÃ!
ÎÒ¹«Ë¾³¤ÆÚ´Óʹú¼ÊóÒ×,ΪÍÚ¾òÊг¡Ç±Á¦¡¢À©´ó¾Óª¹æÄ£,ÒâÔÚ¹óµØ
ѰÕÒÁôÒ×´°¿Ú,ÌØ½«´Ë¼Ûͬ±í³Ê¹óµ¥Î»²Î¿¼.ÎÒ˾ÌṩһÁ÷Æ·ÖÊ,Ò»Á÷·þÎñ,ËÍ»õÉÏÃÅ,
»õµ½¸¶¿î, ÅúÁí¾ù¿É.»¶Ó¸÷½çÅóÓÑÀ´µç´¹Ñ¯¼°Ö§³Ö.¶àл!!!
̨ÍåÕýÈÙ¹ú¼ÊóÒ×¹«Ë¾
ÖйúITóÒײ¿ :Áø½ðÃú
ÇëÎðÖ±½Ó»Ø¸´£¬ÓÐÒâÕßÇëÀ´µç ------0138-50738839
Ò».µçÄÔÅä¼þ(RMB.Ôª):
A:Ö÷°å:
΢ÐÇ 845Pro2-LE(Socket,i845,SDRAM,AC97Éù¿¨)---530
845Pro
2009 Nov 03
2
Re place only first NA in column
Dear All,
I am trying to fill in a blank vector ("a") with one value at a time, with
the value of the number of rows in a randomized dataset with rowSums=0.
Below is the code I've got so far, but what I want to be as the last line is
" a[1st NA,]=nz"
such that this will run until all of my NAs are replaced with an integer
value based on randomizations.
2008 Sep 01
0
Plotting significance level
I am a new user of R package and I needed a help
regarding plotting confidence limits for FFT ( chisquare based) and spectrum
using the monte carlo simulations of background red noise . How do I do it
in R can any one help in this issue?
sudheer
º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤º¤ø,¸¸,ø¤º
Sudheer Joseph
Scientist
Indian National Centre for Ocean Information Services
2004 Aug 06
0
Öйú±±¾©¹ú¼Ê¿Æ¼¼²©ÀÀ»áôßÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ
µÚÎå½ì±±¾©¡°¹ú¼ÊÖÜ¡±³ÏÑûÄúµÄ(¹«Ë¾¡¢ÆóÒµ)²Î¼Ó --
Öйú±±¾©¹ú¼Ê¿Æ¼¼²©ÀÀ»áôßÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ
¡°ÊÀ½ç500Ç¿CEOÓëÖйú¶¥¼¶ÆóÒµÊ×ÄÔÂÛ̳¡±
»áÒé˵Ã÷£º
¾ÖлªÈËÃñ¹²ºÍ¹ú¹úÎñÔºÅú×¼£¬
ÖлªÈËÃñ¹²ºÍ¹ú¿ÆÑ§¼¼Êõ²¿¡¢Íâ¾Ã³²¿¡¢½ÌÓý²¿¡¢ÐÅÏ¢²úÒµ²¿¡¢Öйú¹ú¼ÊóÒ×´Ù½øÎ¯Ô±»á¡¢¹ú¼Ò֪ʶ²úȨ¾ÖºÍ±±¾©ÊÐÈËÃñÕþ¸®¹²Í¬Ö÷°ì£¬
±±¾©ÊÐó´Ù»á³Ð°ìµÄ¡ª¡ªµÚÎå½ìÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ(ÒÔϼò³Æ¿Æ²©»á(¹ú¼ÊÖÜ)£¬
2004 Aug 06
0
Öйú±±¾©¹ú¼Ê¿Æ¼¼²©ÀÀ»áôßÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ
µÚÎå½ì±±¾©¡°¹ú¼ÊÖÜ¡±³ÏÑûÄúµÄ(¹«Ë¾¡¢ÆóÒµ)²Î¼Ó --
Öйú±±¾©¹ú¼Ê¿Æ¼¼²©ÀÀ»áôßÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ
¡°ÊÀ½ç500Ç¿CEOÓëÖйú¶¥¼¶ÆóÒµÊ×ÄÔÂÛ̳¡±
»áÒé˵Ã÷£º
¾ÖлªÈËÃñ¹²ºÍ¹ú¹úÎñÔºÅú×¼£¬
ÖлªÈËÃñ¹²ºÍ¹ú¿ÆÑ§¼¼Êõ²¿¡¢Íâ¾Ã³²¿¡¢½ÌÓý²¿¡¢ÐÅÏ¢²úÒµ²¿¡¢Öйú¹ú¼ÊóÒ×´Ù½øÎ¯Ô±»á¡¢¹ú¼Ò֪ʶ²úȨ¾ÖºÍ±±¾©ÊÐÈËÃñÕþ¸®¹²Í¬Ö÷°ì£¬
±±¾©ÊÐó´Ù»á³Ð°ìµÄ¡ª¡ªµÚÎå½ìÖйú±±¾©¸ßм¼Êõ²úÒµ¹ú¼ÊÖÜ(ÒÔϼò³Æ¿Æ²©»á(¹ú¼ÊÖÜ)£¬
2002 Jan 13
0
vorbis-dev´Ô ¾È³çÇϼ¼¿ä? *^^*((¿µ¾î & ÀϾî mailing service È«º¸))*^^*
:::Happy mail::: Happymail ¹× ±âŸ ¹®ÀÇ 02-588-0510 2002³â 1¿ù
¢Ã Ä£±¸ÀÇ Ãæ°í
¢Ñ [¿µ¾î·Î ¿ô¾î¿ä] ¿ø¹®º¸±â A man and his friend were travelling on a train. They decided they
were hungry and each took out a banana. Just as the first man
took a bite of his, the train entered a tunnel and everything went
dark. The man said to
2002 Jan 13
1
vorbis´Ô ¾È³çÇϼ¼¿ä? *^^*((¿µ¾î & ÀϾî mailing service È«º¸))*^^*
:::Happy mail::: Happymail ¹× ±âŸ ¹®ÀÇ 02-588-0510 2002³â 1¿ù
¢Ã Ä£±¸ÀÇ Ãæ°í
¢Ñ [¿µ¾î·Î ¿ô¾î¿ä] ¿ø¹®º¸±â A man and his friend were travelling on a train. They decided they
were hungry and each took out a banana. Just as the first man
took a bite of his, the train entered a tunnel and everything went
dark. The man said to
2011 Feb 04
2
Avoiding two loops
Hello,
I have a R code for doing convolution of two functions:
convolveSlow <- function(x, y) {
nx <- length(x); ny <- length(y)
xy <- numeric(nx + ny - 1)
for(i in seq(length = nx)) {
xi <- x[[i]]
for(j in seq(length = ny)) {
ij <- i+j-1
xy[[ij]] <- xy[[ij]] + xi * y[[j]]
}
}
xy
}
How do I reduce the 2
2018 Mar 21
5
Sum of columns of a data frame equal to NA when all the elements are NA
Dear list users,
let me ask you this trivial question. I worked on that for a long time, by now.
Suppose to have a data frame with NAs and to sum some columns with rowSums:
df <- data.frame(A = runif(10), B = runif(10), C = rnorm(10))
df[1, ] <- NA
rowSums(df[ , which(names(df) %in% c("A","B"))], na.rm=T)
If all the elements of the selected columns are NA, rowSums