similar to: how to do a IF ELSE in a matrix format

Displaying 20 results from an estimated 2000 matches similar to: "how to do a IF ELSE in a matrix format"

2009 Mar 25
3
Converting a Matrix to a Vector
Say I have: > set.seed( 1 ) > m <- matrix( runif(5^2), nrow=5, dimnames = list( c("A","B","C","D","E"), > c("O","P","Q","R","S") ) ) > m O P Q R S A 0.2655087 0.89838968 0.2059746 0.4976992 0.9347052 B 0.3721239 0.94467527 0.1765568
2013 May 08
4
Correctly Setting New Seed
Could someone please suggest a method to store the current random seed. I'm having trouble understanding how to correctly use set.seed and .Random.seed. Specifically, I have the following code that crashes: set.seed(seed) for(i in 1:10){ print( runif(1)) } To get around this I need to split the number of iterations into chunks: set.seed(seed) for(i in 1:5){ print(runif(1))
2004 Nov 29
2
[BASIC] Solution of creating a sequence of object names
Dear R-users, I state that this is for beginners, so you may ignore this in order not to be irritated. By the way, "patience" is another important thing, together with "kindness", we should keep in mind when we teach students and our own children as Jim Lemon pointed out well in the context of the Socratic method. You may know that being kind does not mean giving
2012 Sep 15
2
How to convert the output of tapply() so that it has the same order as the input?
Hi, I try to apply a function to subsets of a data.frame. tapply() does the job, but the as output, I am looking for a vector (not an array/matrix) ordered in the same way as the original data, so I can simply cbind the result to the original data.frame. Below is a minimal example. I know that there are packages that can do these things easier, but I'm looking for a fast solution not
2008 Sep 09
1
how to split a data framed with sequences
Hi all, Given a data frame: my.df <- data.frame(a = c(1:5, 1:10, 1:20), b = runif(35)) I want to split it by "a" such that I end up with a list containing 3 components i.e. the first containing a = 1 to 5, the second a = 1 to 10 etc. In other words, sets of sequences of a. I can't seem to find the right form using the split function - can you help? Much appreciated. David
2006 Dec 10
1
how to sort random numbers according to the sample ?
Dear R-users, #### below is my code to randomized x three times. > x=c(6,8,9,11) > plan=NULL > for(i in 1:3){ + set.seed(i) + r<-runif(x) + plan=cbind(plan,r) + } ##### which gave the matrix > plan r r r [1,] 0.2655087 0.1848823 0.1680415 [2,] 0.3721239 0.7023740 0.8075164 [3,] 0.5728534 0.5733263 0.3849424 [4,]
2010 Aug 04
2
does R have a command the same with Stata's loop command: ` '
hey, Rers in Stata therer is a loop command ` ' which could do the following: forvalue i=1/10 { ?gen?x`i'=expression } this will generate variable: x1,x2,,,,,x10. so, does R have a corresponding one to this? And one more very basic question: after I open a file and modify it, such as generate some new variables and change some old ones, how to use the changed dataset in
2006 Jul 03
2
help a newbie with a loop
Hi, I am new in R and stumbled on a problem my (more experienced) friends can not help with with. Why isnt this code working? The function is working, also with the loop and the graph appears, only when I build another loop around it (for different values of p) , R stays in a loop? Can't it take more then 2 loops in one program? powerb<-function(x,sp2,a,b,b1,m) {
2005 Jun 23
3
(no subject)
Hello Rers: Let's say I have a column that looks like this: Column 167.8 292.8 363.3 1.9 115.25 I want to manipulate the above data such that I only end up with this same column but only with its decimals and not its whole numbers. So the new column would look like this (but the real column is VERY long): Column .8 .8 .3 .9 .25 Any suggestions about how I could do this? -- Do all you
2010 Oct 15
4
Set value if else...
Hi I want to set a variable to either 1 or 0 depending on an value of a dataframe and then add this as a colum to the dataframe. This could be done with a loop but as we are able to do questions on a complete row or colum without a loop it would be sweet if it could be done. for example: table: Name Age Joel 24 agust 17 maja 40 and so on... And what I want to do is a command that
2005 Apr 19
1
timeSeries Date Warning messages: Set timezone to GMT!
Hello, I must be doing something wrong that's very obvious. But I just don't see it. I changed my Windows Time Zone to GMT and my Financial Center to Montreal. But I still get several warnings. >Sys.timezone() [1] "GMT Daylight Time" >myFinCenter [1] "Montreal" >Sys.timeDate() [1] "Montreal" [1] [2005-04-19 10:55:02] Warning messages: 1: Set
1998 May 14
3
Cannot use smbpasswd for new user
More information on the problem. A couple of days ago I posted a request for help for this error msg terre{testgb}73: smbpasswd Old SMB password: New SMB password: Retype new SMB password: /opt/samba/bin/smbpasswd: machine 127.0.0.1 rejected the session setup. Error was : ERRSRV - ERRbadpw (Bad password - name/password pair in a Tree Connect or Session Setup are invalid.). This happens only
2005 Jan 10
1
IAX2 provider in Montreal, Canada
Hi all, Is there an IAX2 termination provider in Montreal that could offer unlimited local and possibly long distance calling? Would also like to get a DID in Montreal if all possible. Asterisk is so amazing! Thanks to Mark and others, great work! Thanks Stephane -------------- next part -------------- An HTML attachment was scrubbed... URL:
2009 Jun 16
2
Statistically detecting thresholds...
Rers: I have some ecological data (stream velocity vs. % cover of submerged weeds) that shows strong evidence of a thresholding step-function, e.g. below some velocity, % cover ranges from 0% to 100% (with no apparent relationship to velocity within this range of velocities), but above a certain "threshold" velocity, the % cover does not appear to exceed, say, 10%. There are good
2005 Sep 07
2
Sorting Text Frames
[Using 2.0.1 under Windows XP] There are a few pages on the internet that list equivalents of "thank you" in many languages. I downloaded one from a Google search and I thought that it would be interesting and a good R exercise to sort the file into the order of the expressions, rather than the languages. I tidied up the web page and got it into the format that it was nearly in:
2007 Nov 21
3
Packages - a great resource, but hard to find the right one.
Fellow Rers, Please forgive me if I have posted this to the wrong R list serve. Over the course of the years that I have used R and participated in this list server, I have noted a large number of questions and answers that direct people to specific packages. The multitude of packages is one of the great strengths of R. Unfortunately there is no (or at least I am not aware of) any single source
2010 Sep 21
5
Can ucminf be installed in 64 bit R and one more question?
Hey, R Users my windows is 64 bit windows 7.?I am trying to install the package ucminf into my 64 bit version R but cannot.??the package I downloaded is from http://cran.r-project.org/web/packages/ucminf/index.html?and I installed it with the "install from local zip files", due to I did not connect my computer to internet. did anyone meet this problem and is there a version of
1998 May 13
1
Compiling warnings in 1.9.18p7
I get these messages when compiling on a Sun Sparc 5 running Solaris 2.6: Compiling ipc.c ipc.c: In fonction `api_RNetServerEnum': ipc.c:1194: warning: passing arg 4 of `qsort' from incompatible pointer type Compiling nmbd_incomingrequests.c nmbd_incomingrequests.c: In function `process_node_status_request': nmbd_incomingrequests.c:380: warning: passing arg 4 of `qsort' from
2007 Jan 19
1
One User Cannot Log In
Attempting to log in through Squirrelmail. Jan 19 09:34:07 montreal dovecot: imap-login: Login: user=<steve>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured Jan 19 09:34:07 montreal dovecot: IMAP(steve): initgroups(steve, 15) failed: Invalid argument This entry appears nowhere else in the log. montreal# id steve uid=268(steve) gid=15(users) groups=15(users), 626(moodleCreators),
2005 Jun 14
1
protection stack overflow??
Hi dear Rers, I am using SSOAP package to access SOAP service at NCBI. I followed the example code in SSOAP but failed. > z <- .SOAP("http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/soap_adapter.cgi", method="run_eInfo", db="pubmed", action = I("einfo")) Error: protect(): protection stack overflow what's wrong? Thanks very much. Regards