similar to: sapply and matrix command

Displaying 20 results from an estimated 300 matches similar to: "sapply and matrix command"

2010 Dec 14
3
from table to matrix
I have a table like this: Date TIME Q A a 1 A b 2 A c 3 B a 4 B b 5 B c 6 C a 7 C b 8 C c 9 I want use R language to turn it to a matrix like : a b c A 1 2 3 B 4 5 6 C 7 8 9 I am new to R , anyone can help? Thanks in advance! have a table like this: Date TIME Q A a 1 A b 2 A c 3 B a
2013 Feb 06
1
Adding Latex to text
Hi, I'd like to add "alpha" in latex code to my image. Any suggestions? library(UsingR) BagA = c(rep(10,6),rep(20,5), rep(30,4),rep(40,3),rep(50,2),60,70) BagA BagB = c(10, 20,rep(30,2),rep(40,3),rep(50,4),rep(60,5),rep(70,6)) BagB par(mfrow = c(2, 1)) DOTplot(BagA) abline(v=60,lwd=2,lty=2,col="red") text(65,3, "alpha-->", col=2) abline(v=50, lwd=2, lty=2,
2009 Jan 02
1
runif limited precision
runif appears to give 31 bits of precision, but this isn't mentioned in the documentation page. The R numeric type supports 53 digits of precision, and other numeric functions (sin, etc.) give full-precision results. So I'd think that either runif should give full precision or its documentation should mention this limitation. #integers table(runif(10000,-2^30,2^30) %% 1) 0 0.5 4972
2007 Jan 07
0
Multiple plots via sapply or lapply?
Hi all, I've got the following problem. I have a vector containing file names. I want to read these files as csv and calculate the density-function for each file (has just one column with data). Then, I'd like to plot all density functions into one window. I did the following to calculate the density data: s <- sapply(filelist, function(x) { if(file.exists(x)) { file <-
2010 Jun 13
2
Scope and sapply
I am puzzled by the scope rules that apply with sapply. If I want to modify a vector with sapply I tried... N <- 10 vec <- vector(mode="numeric", length=N) test <- function(i){ vec[i] <- i } sapply(1:N, test) vec but it not work. How can this be done? Worik [[alternative HTML version deleted]]
2002 Dec 21
1
apply vs. sapply
Hi, sapply((1:NCOL(hermes)),function(x) hist(hermes[,x],main=names(hermes)[x])) .......this works , but i would like use it with apply to generate many plots in one step! #################################################################### >>apply((1:ncol(hermes)),2,function(x) hist(hermes[,x],main=names(hermes)[x])) Error in apply(1:ncol(hermes), 2, function(x) hist(hermes[, x], main =
2007 Aug 02
1
sapply?
I have to compare four different grape varieties proteome in two different years. I don't know what test would be more suitable for my data. I think that an anova two way can be usefull also if someone suggested me to perform a manova. In addiction, I can perform each test on a single protein a time, but I can't loose my whole life carrying out anova (I have more than 1000 protein to
2013 May 26
0
SAPPLY function for COLUMN NULL
colnames(dd) #[1] "col1" "colb" null_vector<- colnames(dd) sapply(null_vector,makeNull,dd) #???? col1 colb #[1,]?? NA??? 4 #[2,]??? 2?? NA #[3,]??? 3??? 2 #[4,]??? 4?? NA #[5,]??? 1??? 4 #[6,]?? NA??? 5 #[7,]??? 1??? 6 A.K. >I am trying to make a column value in a dataframe = NA if there is a 0 or high value in that column. I need to do this process repeatedly, hence
2016 Apr 08
2
identical() versus sapply()
Sorry if this has been answered elsewhere, but I can't find any discussion of it. Wondering why the following situation occurs (duplicated on 3.2.2 CentOS6 and 3.0.1 Win2k, so I don't think it is a bug): > sapply(1, identical, 1) [1] TRUE > sapply(1:2, identical, 1) [1] FALSE FALSE > sapply(1:2, function(i) identical(as.numeric(i),1) ) [1] TRUE FALSE > sapply(1:2,
2016 Apr 09
0
identical() versus sapply()
I highly recommend making friends with the str function. Try str( 1 ) str( 1:2 ) for the clue you need, and then sapply( 1:2, identical, 1L ) -- Sent from my phone. Please excuse my brevity. On April 8, 2016 3:24:31 PM PDT, "Paulson, Ariel" <apa at stowers.org> wrote: >Sorry if this has been answered elsewhere, but I can't find any >discussion of it. >
2001 Nov 06
0
beware of sapply(x, data.class) == "numeric"
This is just a warning/hint to others; package/function writers in particular : The `cluster' package (originally S-plus from Rousseeuw et al) currently has code such as ## check type of input matrix if((!is.data.frame(x) && !is.numeric(x)) || !all(sapply(x, data.class) == "numeric")) stop("x is not a numeric dataframe or matrix.") x <-
2003 Dec 09
1
Maybe some bug on sapply and cbind (PR#5628)
Full_Name: Drouilhet R?my Version: 1.8.1 OS: Linux Submission from: (NULL) (195.221.43.136) Hi!!! Is there some mistake? This is some part of one of my R programs. I created this function to show you the trouble!!! bugTest<-function() { paramnames <- c("mean","sd") param <- list(expression(1),expression(2)) paramtmp <- list(mean=0,sd=1) if(length(param))
2006 Jul 07
1
often unnecessary duplicate in sapply / as.vector
sapply calls lapply as answer <- lapply(as.list(X), FUN, ...) which, when X is a list, causes X to be duplicated unnecessarily. The coercion is unnecessary for other mode(X) because in lapply we have if (!is.list(X)) X <- as.list(X) More generally, perhaps as.vector might not duplicate when mode(x) == mode ? Martin R version 2.4.0 Under development (unstable) (2006-07-05
2008 Aug 07
1
sapply(Date, is.numeric) (PR#12008)
Full_Name: Robert McGehee Version: 2.7.1 OS: Windows Submission from: (NULL) (192.223.226.6) R-developers, The results below seem inconsistent. From the documentation for is.numeric, I expect FALSE in both cases. > x <- data.frame(dt=Sys.Date()) > is.numeric(x$dt) [1] FALSE > sapply(x, is.numeric) dt TRUE ## Yet, sapply seems aware of the Date class > sapply(x, class) dt
2008 Aug 07
0
sapply(Date, is.numeric) (PR#12221)
FYI,=20 I've tried posting the below message twice to the bug tracking system, once by email (below), and the second time 5 days later directly to the bugs.r-project.org website. As far as I can tell, the bug tracking system hasn't picked this up. Also it looks like the latest "incoming" bug is dated 25 May 2008, so perhaps others are having difficulty as well. (cc: r-bugs)
2008 Aug 07
0
sapply(Date, is.numeric) (PR#12239)
>>>>> "RobMcG" == McGehee, Robert <Robert.McGehee at geodecapital.com> >>>>> on Tue, 29 Jul 2008 15:40:37 -0400 writes: RobMcG> FYI, RobMcG> I've tried posting the below message twice to the bug tracking system, [....... r-bugs problems discussed in a separate thread ....] RobMcG> R-developers, RobMcG> The
2002 Jun 26
0
AW: sapply() and Monte Carlo
What about "Rtips" at http://lark.cc.ukans.edu/~pauljohn/R/statsRus.html ? Regards, Heinrich. > -----Urspr?ngliche Nachricht----- > Von: rossini at blindglobe.net [mailto:rossini at blindglobe.net] > Gesendet: Mittwoch, 26. Juni 2002 14:48 > An: r.hankin at auckland.ac.nz > Cc: r-help at stat.math.ethz.ch > Betreff: Re: [R] sapply() and Monte Carlo > > >
2004 Jun 22
1
RE: summaries (was: SUMMARY: "elementary sapply question")
Ajay, thank you very much for picking up that age-old habit of posting summaries. It existed years ago on s-help and I find it is still a great thing: I would not have bothered to read your original question nor the answers you got, but I did read the summary -- and I learned something quite interesting! Maybe some others who receive multiple non-elementary answers to their questions could
2005 Feb 18
1
extracting F, df and r squared using "sapply"?
Hi, All How does one remove relevant information from a regression output besides just the coefficients? I've been able to modify the example given under "help(by)" to give me some additional information, but not everything I need. If you adjust the call statement from what is listed by adding the summary statement like so: tmp <- by(warpbreaks, tension, function(x)
2005 Aug 27
1
better than sapply
I have the following two mapping data frames (r) and (h). I want to fill teh value of r$seid with the value of r$seid where r$cid==h$cid. I can do it with sapply as such: > r$seid = sapply(r$cid, function(cid) h[h$cid==cid,]$seid) Is ther a better (faster) way to do this? > r <- data.frame(seid=NA, cid= c(2181,2221,2222)) > r seid cid 1 NA 2181 2 NA 2221 3 NA