similar to: sub() of matrix returns a vector and not a matrix

Displaying 20 results from an estimated 30000 matches similar to: "sub() of matrix returns a vector and not a matrix"

2006 Nov 29
4
Why the factor levels returned by cut() are not ordered?
What is the reason, that the levels of the factor returned by cut() are not marked as ordered levels? > is.ordered( cut( breaks=3, sample(10 ) ) ) FALSE > help(factor) ... If 'ordered' is 'TRUE', the factor levels are assumed to be ordered. ... Wolfram
2005 Apr 11
6
How to change letters after space into capital letters
What is the easiest way to change within vector of strings each letter after a space into a capital letter? E.g.: c( "this is an element of the vector of strings", "second element" ) becomes: c( "This Is An Element Of The Vector Of Strings", "Second Element" ) My reason to try to do this is to get more readable abbreviations. (A suggestion would be to
2004 Oct 04
11
inverse function of order()
I have: d <- sample(10:100, 9) o <- order(d) r <- d[o] How I can get d (in the original order), knowing only r and o? Thanks - Wolfram
2003 Jan 24
4
new function: showcolors {base}
I propose to add a function that allows to display colors selected by a text pattern or by color vectors in a plot. Wolfram Fischer #--- showcolors.R showcolors <- function( col = "red" , index = NULL , pie = TRUE , lwd = 6 , cex = 1.0 , main = NULL , sub = NULL , ... ){ n.colors <- length( col ) if( n.colors > 1 ){ main <- deparse( substitute( col ) )
2003 Aug 29
2
length() and nchar()
I would propose to add " See also: `nchar' for counting the number of character in character vectors. " to the helpfile of length(), because it is rather difficult to find nchar() if one has only search terms as "length", "len", "strlen" in mind. Sincerly Wolfram Fischer
2004 Dec 07
1
how to test the existence of a name in a dataframe
I wanted to test if there exists already a name (which is incidentally a substring of another name) in a dataframe. I did e.g.: > data(swiss) > names(swiss) [1] "Fertility" "Agriculture" "Examination" "Education" [5] "Catholic" "Infant.Mortality" > ! is.null(swiss$EduX) [1] FALSE > !
2002 May 21
1
plotting functions with line width (lwd) as vectors
If I want to plot different widths of line segments or arrows I have to program loops to plot each line apartly. Is that right? n <- 6 x <- 1:n y <- rnorm(1:n) q <- ( x %% 3 + 1 ) * 2 plot( x, y, cex=q ) for( i in 1:(n-1) ) lines( x[i:(i+1)], y[i:(i+1)], lwd=q[i], col=q[i] ) Would it not be possible to make plotting functions accept vectors of line widths (as they
2005 Apr 15
4
function corresponding to map of perl
Is there a function in R that corresponds to the function ``map'' of perl? It could be called like: vector.a <- map( vector.b, FUN, args.for.FUN ) It should execute for each element ele.b of vector.b: FUN( vector.b, args.for.FUN) It should return a vector (or data.frame) of the results of the calls of FUN. It nearly works using: apply( data.frame( vector.b ), 1, FUN,
2007 Feb 15
2
Problems with 'delay'/'delayedAssign' when installing data package
I downloaded: http://www.bioconductor.org/data/metaData/hgu95av2_1.7.0.tar.gz described as: Package: hgu95av2 Title: A data package containing annotation data for hgu95av2 Version: 1.7.0 Created: Wed Jan 12 16:57:23 2005 Author: Lin,Chenwei Description: Annotation data file for hgu95av2 assembled using data from public data repositories Maintainer:
2006 Dec 08
1
lattice: defining an own function using args for "formula" and "groups"
x.fun <- function( formula, data ) dotplot( formula, data ) x.grp <- function( formula, groups, data ) dotplot( formula, groups, data ) data( barley ) > x.fun( variety ~ yield | site, data=barley ) # no problem > dotplot( variety ~ yield | site, groups=year, data=barley ) # no problem > x.grp( variety ~ yield | site, groups=year, data=barley ) object "year" not found
2004 Jul 08
2
Getting elements of a matrix by a vector of column indice s
See if the following helps: > m <- outer(letters[1:5], 1:4, paste, sep="") > m [,1] [,2] [,3] [,4] [1,] "a1" "a2" "a3" "a4" [2,] "b1" "b2" "b3" "b4" [3,] "c1" "c2" "c3" "c4" [4,] "d1" "d2" "d3" "d4" [5,]
2004 Oct 22
1
ave gives unexpected NA's
[R 2.0.0 on Linux] I tried: > df <- data.frame( grp1=factor( c('A' ,'A' ,'A' ,'D', 'D' ) ) , grp2=factor( c('a1','a2','a2','d1','d1') ) ) > df grp1 grp2 val 1 A a1 1 2 A a2 2 3 A a2 4 4 D d1 8 5 D d1 16 I got: > with( df, ave( val, grp1, grp2, FUN=sum ) )
2002 Nov 11
2
repeating a dataframe n times in the direction of the rows
Question: How can a repeat a dataframe n times in the direction of the rows? (Or: How I can rbind a dataframe n times ?) Example Data: x <- data.frame( alpha=letters[1:3], num=1:3 ) n <- 4 Complicated solution: To rbind a dataframe n times I can program a loop: xr <- x for( i in 2:n ) xr <- rbind( xr, n ) Observation: To cbind a dataframe n times I
2008 Feb 14
1
{lattice/grid} "Error using packet 1" and traceback
On some errors during the plot of a lattice/grid graphics, there is written a message like "Error using packet 1: missing value where TRUE/FALSE needed" into the concering panel and the next panel is plotted. Which option I could use to stop the execution to have a look at the error by a traceback? Regards - Wolfram
2003 Dec 22
1
[R] lattice: levelplot: error: min not meaningful for factor (PR#6005)
R 1.8.1: ___COMMAND____________________________________________ levelplot( yield ~ year * variety | site, barley ) ___ERROR_MESSAGE______________________________________ Error in Summary.factor(..., na.rm = na.rm) : "min" not meaningful for factors ___COMMENT____________________________________________ levelplot( yield ~ as.numeric(year) * as.numeric(variety) | site,
2002 Nov 04
1
[R] CTRL-C suspends echo of shell (R versions 1.6.0 and 1.6.1) (PR#2253)
Problem: - Shell does not echo anymore after using CTRL-C (to interrupt calculations) once during a R session. Procedure: - [start session] R - [input] CTRL-C - [end session] q() Some details: - `stty` before: speed 38400 baud; line = 0; lnext = <undef>; - `stty` after: speed 38400 baud; line = 0; lnext = <undef>; min = 1; time = 0; -icrnl -icanon -echo I
2003 Jan 22
1
text() does not accept data of type POSIXlt (PR#2487)
[R 1.6.1] PROBLEM If text() is called with an argument of type POSIXlt, I get the following error message: "Error in as.double.default(x) : (list) object cannot be coerced to vector type 14" REMARK plot() accepts this data. EXAMPLE data( Lifeboats, package='vcd' ) attach(Lifeboats) plot( launch, total ) text( launch, total,
2003 Dec 05
1
R 1.8.1 ./configure with "," in working directory (PR#5536)
PROBLEM ``./configure'' creates empty Makefiles and the following error messages if there is a ``,'' in the name of the working directory. REMARK As I have seen, ``,'' is used as separator for the sed statements in config.status. Would it be possible to use instead a character which cannot be used in a pathname, e.g. ``;''? ERROR MESSAGES ... checking for lpr...
2005 Aug 12
3
General expression of a unitary matrix
Hi, all, Does anybody got the most general expression of a unitary matrix? I found one in the book, four entries of the matrix are: (cos\theta) exp(j\alpha); -(sin\theta)exp(j(\alpha-\Omega)); (sin\theta)exp(j(\beta+\Omega)); (cos\theta) exp(j\beta); where "j" is for complex. However, since for any two unitary matrices, their product should also be a unitary matrix. When I
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists: xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) ) xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site , FUN=function(z)yield[z])) I can convert xa to a dataframe easily with: as.data.frame(xa) But if i try the same with xb I get: as.data.frame(xb) Error in as.data.frame.default(xb) : can't coerce array into a data.frame What