similar to: Sorting a data frame when you don't know the columns

Displaying 20 results from an estimated 10000 matches similar to: "Sorting a data frame when you don't know the columns"

2004 Nov 16
3
Simple plot() question
Hi First a simple question to do with plot(). How do I change the x-axis labels on a plot? For example, I am plotting each row of a matrix, and I want each row to be a line on my graph. Simple really. Eg: plot(sg[1,], type="l") When I do this, the x-axis is labelled 1:38, as I have 38 columns in my matrix. When I do: plot(sg[1,order(sg[1,])], type="l") Ideally I would
2005 Feb 17
3
A vector or array of data frames
Hi A simple question again, but I can't find it by google-ing R-help. Quite simply, I want to read in the contents of a number of files, using read.table, and assign the results to elements of a vector/array/list/whatever. I want it so that, if my vector/array/whatever is "pos", that pos[1] will give me the first data frame, pos[2] will give me the second etc... Kind of basic
2005 Feb 03
5
How to convert a list to a matrix
Hi Sorry to ask such a basic question. I have a list, each element of which is a vector of two values. What I actually want is a matrix with two columns, and one row per element of the list. Obviously I have tried as.matrix(), and as.vector() but I didn't expect the latter to work. I feel so lame asking this. Any suggestions? Mick
2005 Feb 17
6
Converting a list to a matrix - I still don't think I have it right
Hi We have touched on this before, but I don't think I quite got it right. So I have a list, each element of which is a a vector of 2 numbers: > l2 $cat000_a01 [1] 0.3429944 4.5138244 $cat000_a02 [1] 0.1929336 4.3064944 $cat000_a03 [1] -0.2607796 4.1551591 What I actually want to convert this into is a matrix with the names (cat000_a01 etc) as row names, the first element of each of
2003 Jul 25
5
R won't connect to the internet on SUSE Linux 8.1
Hi Thanks once again for your help, I do appreciate it..... however.... Here is what I get with your test.... (under tcsh - i normally use bash, but I will keep everything the same) users/mwatson> env http_proxy=http://wwwcache.bbsrc.ac.uk:8080/ R >options(internet.info=0) >update.packages() trying URL `http://cran.r-project.org/src/contrib/PACKAGES' unable to connect to
2005 Jan 14
5
Replacing NAs in a data frame using is.na() fails if there are no NAs
Hi This is a difference between the way matrices and data frames work I guess. I want to replace the NA values in a data frame by 0, and the code works as long as the data frame in question actually includes an NA value. If it doesn't, there is an error: df <- data.frame(c1=c(1,1,1),c2=c(2,2,NA)) df[is.na(df)] <- 0 df df <- data.frame(c1=c(1,1,1),c2=c(2,2,2)) df[is.na(df)] <-
2005 Feb 10
3
Using a number as a name to access a list
Hi Dumb question time again, for which I apologise. I have a variable that contains the following numerical text "04010". This is the name to access a list: > as.list(KEGGPATHID2NAME)$"04010" [1] "MAPK signaling pathway" Marvellous! Except I want to do that when "04010" is assigned to a variable called path and I can't figure out how to do it!
2004 Dec 01
2
Data Frame Manipulations
Hi I have used merge() to merge two data frames, very much like performing a SQL join. Now I want to do a few different SQL-style things and I wondered if there were functions to do it... Is there a "group by" style function? For example if I merge() two data frames and end up with multiple rows for each "id", and want to take the average of the values of a particular
2003 Jul 24
3
R won't connect to the internet on Linux!
OK, I really am struggling with this one! Forgive me if I am being stupid.... I am running R 1.7.1 on Suse Linux 8.1. I connect to the internet through a proxy so I have: IAHC-LINUX03:~ # echo $http_proxy wwwcache.bbsrc.ac.uk:8080 IAHC-LINUX03:~ # echo $HTTP_PROXY wwwcache.bbsrc.ac.uk:8080 just in case ;-) SO, i go into R and I get: >
2005 Jan 05
8
Replacing all NA values in a matrix
OK, dumb question, and it is probably in the docs somewhere, but after 12 months working with R and quite a while looking at the docs, I still don't know (or have forgotten) how to replace all NA values in a matrix at once with some other value. I can do it column by column using is.na(), but I can't figure out how to do it for the whole matrix. My apologies, I am ashamed ;-) Michael
2004 May 19
7
Help with hclust() and plot()
Hi When I use plot(hclust(dist..)...)...) etc to create a dendrogram of a hierarchial cluster analysis, I end up with a vertical tree. What do I need to do to get a horizontal tree? Also, my users are used to seeing trees who's leaves all "end" at the same place (eg. Like in minitab). Is this possible in R? Thanks Mick Michael Watson Head of Informatics Institute for Animal
2003 Jul 18
4
R won't connect to the internet
Hi I can't get R to connect to the internet. I am running R 1.7.1 on Windows XP and whenever I try to download packages etc from within R using the internet, it fails. OK so I am behind a firewall and use a proxy server.... SO, if I go to my MS-DOS prompt and type: RGui.exe --internet2 everything works.... BUT i can't set up a shortcut for this as Windows (I hate Windows) complains
2006 Mar 06
4
Averaging over columns
Hi I've been reading the help for by and aggregate but can't get my head round how to do this. I have a data frame - the first three columns are replicate measurements, then the next 3 are replicates etc up to 36 (so 12 variables with 3 replicate measurements each). I want to compute the mean for each of the 12 variables, so that, for each row, I have 12 means. A grouping variable
2004 Aug 26
5
Problems with par() and labels with boxplot
Quite a simple one really! When I run boxplot(), the labels on the X axis are horizontal, and I want them vertical. So I did: par(las=3) boxplot(...) And my labels just aren't there anymore.... Any help???
2004 Oct 04
3
Help with normal distributions
Hi I have two questions, the first perhaps dumber than the second. Firstly, I have a data set, and when I plot a histogram it looks like a normal distribution. So I want to overlay a bell-shaped normal distribution on top of it, to demonstrate how similar it is to the normal distribution. I have read the help on dnorm(), rnorm(), pnorm() etc but still can't figure out how to plot a normal
2005 Jan 25
2
Rd problems when converting DVI version
Hi Running R v2.0 on SuSe linux 8.2. I'm trying to build a package (which built perfectly on Windows...) on Linux, and I ran: R CMD check mypackage I got: * checking mypackage-maual.tex ... ERROR LaTeX errors when creating DVI version This typically indicates Rd problems OK, there are no problems with my Rd - I got 3 warnings but they were all expected, and the whole package builds find
2004 Nov 16
5
Difference between two correlation matrices
Hi Now a more theoretical question. I have two correlation matrices - one of a set of variables under a particular condition, the other of the same set of variables under a different condition. Is there a statistical test I can use to see if these correlation matrices are "different"? Thanks Mick
2003 Jun 13
4
Using jpeg() function over cgi
Hi I have seen a few posts to this list regarding problems accessing the x11() device over cgi - namely, when trying to create a graphic using the jpeg() function, everything is fine from the command line but it won't work over cgi, producing the error: "Unable to open connection to X11 display" Has anyone actually solved this particular problem satisfactorily? Please reply
2003 Jul 03
4
Generating a vector for breaks in a histogram
Hi I have two lots of numbers which I would like to histogram using the hist() function. For comparative reasons, I want them to be on the same scale, which I can use the xlim and ylim options to achieve. However, having them on the same scale is meaningless unless they have the same "breaks". Consulting the documentation, there are 4 ways of defining the number of breaks, only one
2004 Dec 10
4
cbind() and factors.
Hi I'm seeing some "odd" behaviour with cbind(). My code is: > cat <- read.table("cogs_category.txt", sep="\t", header=TRUE, quote=NULL, colClasses="character") > colnames(cat) [1] "Code" "Description" > is.factor(cat$Code) [1] FALSE > is.factor(cat$Description) [1] FALSE > is.factor(rainbow(nrow(cat))) [1]