search for: mtb954

Displaying 20 results from an estimated 86 matches for "mtb954".

2006 Feb 24
3
Sorting alphanumerically
I'm trying to sort a DATAFRAME by a column "ID" that contains alphanumeric data. Specifically,"ID" contains integers all preceeded by the character "g" as in: g1, g6, g3, g19, g100, g2, g39 I am using the following code: DATAFRAME=DATAFRAME[order(DATAFRAME1$ID),] and was hoping it would sort the dataframe by ID in the following manner g1, g2, g3, g6, g19,
2006 Feb 24
2
Sorting a dataframe by one column?
Given the following dataframe: A=1:10 B=(a-5)^2 DATAFRAME=data.frame(A,B) How can I sort DATAFRAME increasing (or decreasing, for that matter) by B without making reference to A, or any other column? I've read ?order and ?sort but cannot seem to figure this out. Thank you. Mark
2005 Oct 25
5
Graphics window always overlaps console window!
Does anyone know how I can set up R so that when I make a graphic, the graphics window remains behind the console window? It's annoying to have to reach for the mouse every time I want to type another line of code (e.g., to add another line to the plot). Thanks.
2007 Apr 16
2
Histograms of lots of variables
Hi R-helpers, I wish to produce frequency histograms of all of the variables in my dataframe (except some identifying variables). I have tried >hist(dataframe[,3:20]) to produce histograms of the 3rd through 20th variables in my dataframe, but R doesn't like that. Could anyone provide a suggestion? Also, once I produce the histograms, I'd like to save them as graphic files on my
2006 Feb 20
2
glob2rx function not working
Dear R users, Inspired by previous list discussion of the glob2rxc function, I am attempting to create a new vector called TOTAL by summing all vectors whose names begin with ABC: TOTAL = sum(list = ls(pattern = glob2rx("ABC*"))) I'm running R 2.2.1 on Windows XP. Can anyone say what I'm missing? Thank you, Mark
2006 Feb 24
1
Read SAS .sd2 file into R?
Does anyone know how to import a SAS .sd2 file into R? I can't see anything in library(foreign). Thank you. Mark
2007 Mar 26
2
How to drop variables using a wildcard and logic...
Dear R users I would like to make a new dataframe from an existing dataframe, retaining ONLY those variables that end in the letter "t" I have searched the help archives and consulted several reference books but cannot seem to find an example. Any ideas...? Thanks! Mark [[alternative HTML version deleted]]
2008 Aug 06
4
How to calculate GLM least square means?
Hello R-helpers, I would like to calculate least square means after having built a GLM with quasipoisson errors. In my model the dependent variable is continuous, I have one continuous independent variable and one categorical independent variable (that is the variable for which I would like to calculate the least square means). I've looked around for the command to calculate the least
2009 Jun 02
3
How to convert blanks to NA
Hi R-helpers, I have imported data from Excel using the following code: library(xlsReadWrite) data <- read.xls(data,colClasses=c("character")) and this results in all of the empty (blank) cells in the imported Excel file also being empty (blank) in the resulting dataframe. I am not used to having blanks (rather NAs) and I think these are caused by the colClasses argument. I would
2010 Mar 18
4
Please help with loop, thanks
Dear R helpers, I would like to write a loop that makes 4 objects (called A, B, C, and D) each of which contains ten random numbers. This attempt: individuals<-c("A","B","C","D") for(i in 1:length(individuals)) { individuals[i]<-rnorm(10) } does not work because "individuals[i]" is not the proper way to extract each letter from the
2009 Jul 23
2
Antw: How to extract the upper xlim and ylim of my plot?
You may want to use the function corner.label from the plotrix-package. Frank >>> Mark Na <mtb954@gmail.com> 21.07.2009 23:03 >>> Dear R-helpers, I wish to place some text in a plot, at approx 10% of my upper xlim and approx 90% of my upper ylim, i.e. > plot(log(all$SR,10)~log(all$AREA,10)) > text(.1*max(xlim),.9*max(ylim),"text to be placed") (I know how to give...
2007 Apr 19
1
Histogram with uneven bins
Hi R-helpers I would like to produce a histogram with uneven bins (e.g., 0, 1-2, 3-5, 6-10, 10-20, >20) but I would like the resulting bars to be the same width ( i.e., a bar's width would not be proportional to its corresponding bin size). Also, the x and y axes of my histograms frequently (almost always, actually) extend beyond the axis labels (i.e., there are unlabeled bars). I would
2008 Mar 25
2
Combining logical operators to extract columns from a dataframe
Hi R-helpers, I have a dataframe (called data) with 100 columns, the columns of which are named with integers ranging from 1900 to 1999. I wish to extract those columns which names are >=1950 and <=1970. I tried: data2<-subset(data,select=(names(data)>=1950 & names(data)<=1970)) but that doesn't work. Any ideas? Thanks! Mark [[alternative HTML version deleted]]
2008 Sep 05
2
xls to csv conversion via WinXP's context menu?
Frequently I need to convert a .xls to a .csv (for import into R) and I do this by opening the file in excel and saving it as a csv. I would rather do this using WinXP's context menu (right click the xls, choose "convert to csv") but I don't know of a utility that does this. Any ideas? Thanks, Mark
2013 Jan 21
2
Regex for ^ (the caret symbol)?
Hello R-helpers, I am trying to search for string that includes the caret symbol, using the following code: grepl("latitude^2",temp) And R doesn't like that. It gives me: > temp<-c("latitude^2","latitude and latitude^2","longitude^2","longitude and longitude^2") > temp [1] "latitude^2" "latitude and
2009 Jun 23
4
Apply as.factor (or as.numeric etc) to multiple columns
Hi R-helpers, I have a dataframe with 60columns and I would like to convert several columns to factor, others to numeric, and yet others to dates. Rather than having 60 lines like this: data$Var1<-as.factor(data$Var1) I wonder if it's possible to write one line of code (per data type, e.g. factor) that would apply a function (e.g., as.factor) to several (non-contiguous) columns. So, I
2013 Feb 03
2
Compare each element of a list to a vector
Hello R-helpers, I have a vector x<-c(1,2,3) and a list that contains vectors datalist<-list(c(1,2,3),c(2,3,4),c(3,4,5),c(4,5,6)) and I would like to identify those list elements that are identical to x. I tried > datalist %in% x [1] FALSE FALSE FALSE FALSE but I am obviously using %in% incorrectly. I also tried messing around with lapply but I can't figure out how to specify
2009 Jun 17
2
How to translate a dataframe into the R code that makes that dataframe?
Hi, I am helping another R user (off list) and I would like to email her an R script containing the data she needs and the code to solve her problem. I have made a small dummy dataset, but instead of sending her a CSV I would prefer to send the data embedded in the script, so there would be a like in the script like: my.df<-c( etc, etc, etc I have made the dataframe (in a spreadsheet) and
2009 Dec 07
2
How to apply five lines of code to ten dataframes?
Hello R-helpers, I have 10 dataframes (named data1, data2, ... data10) and I would like to add 5 new columns to each dataframe using the following code: data1$LogDepth<-log10(data1[,2]/data1[,4]) data1$LogArea<-log10(data1[,3]/data1[,5]) data1$p<-2*data1[,6]/data1[,7] data1$Exp<-data1[,2]^(2/data1[,8]) data1$s<-data1[,3]/data1[,9] ...but I would prefer not to repeat this chunk of
2006 Feb 21
6
How to sum values across multiple variables using a wildcard?
I have a dataframe called "data" with 5 records (in rows) each of which has been scored on each of many variables (in columns). Five of the variables are named var1, var2, var3, var4, var5 using headers. The other variables are named using other conventions. I can create a new variable called var6 with the value 15 for each record with this code: > var6=var1+var2+var3+var4+var5