search for: alabama

Displaying 20 results from an estimated 194 matches for "alabama".

2009 Jun 23
2
Weighting column entries in a data frame
Hi Guys, I would like to weight column entries in a data frame by the population of each state. For example, here is some data: state statenum year income popul ALABAMA 1 1 9.703193 3973.00 ALABAMA 1 2 9.745950 3992.00 ALABAMA 1 3 9.762092 4015.00 ALASKA 2 1 10.221640 532.00 ALASKA 2 2 10.169600 544.00 ALASKA 2 3 10.101300 539.00 I would like to adjust "inc...
2003 Aug 13
7
Regexpr with "."
I'm trying to use the regexpr function to locate the decimal in a character string. Regardless of the position of the decimal, the function returns 1. For example, > regexpr(".", "Female.Alabama") [1] 1 attr(,"match.length") [1] 1 In trying to figure out what was going on here, I tried the below command: > gsub(".", ",", "Female.Alabama") [1] ",,,,,,,,,,,,,," It looks like R is treating every character in the string as if it were...
2013 Feb 10
3
Constrained Optimization in R (alabama)
...rameters are the exponents to the matrix mm. The constraints specify that each row of the parameter matrix should sum to 1 and their product to 0. I don't understand why the constraints are not satisfied at the solution. I must be misinterpreting how to specify the constrains somehow. library(alabama) ff <- function (x) { mm <- matrix(c(10, 25, 5, 10), 2, 2) matx <- matrix(x, 2, 2) -sum(apply(mm ^ matx, 1, prod)) } ### constraints heq <- function(x) { h <- rep(NA, 1) h[1] <- x[1] + x[3] -1 h[2] <- x[2] + x[4] -1 h[3] <- x[1] * x[3] h[4] <- x[2] * x...
2008 Jan 29
1
Correlation matrix for data in long format
Hello, I cannot figure out how to use "tapply" to compute the correlation matrix in the variable "x" between the states? The data is in long format, e.g.: state,year,x Alabama,2001,0.45 Alabama,2002,0.47 Alabama,2003,0.48 Alabama,2004,0.44 Arizona,2001,0.34 Arizona,2002,0.32 Arizona,2003,0.38 Arizona,2004,0.36 Thank you in advance for your help, Serguei Kaniovski
2011 Jul 23
2
sum part of a vector
Dear colleagues, I have a data set that looks roughly like this; mydat<-data.frame(state=c(rep("Alabama", 5), rep("Delaware", 5), rep("California", 5)), news=runif(15, min=0, max=8), cum.news=rep(0, 15)) For each state, I'd like to cumulatively sum the value of "news" and make that put that value in cum.news. I'm trying as follows but I get really weird re...
2023 Mar 20
0
Optimizing with constraints using alabama
Hi, I am testing code that is working successfully using constrOptim. I am replacing constrOptim with other solvers to compare benefits and performance. My belief was that, like constrOptim, auglag in the alabama package would eliminate beta vectors that failed the constraints prior to calling the objective function. These betas are not only not in the solution space but also cause chaos for my objective function. I can see via debugging that hin is working correctly, but I am finding that these be...
2011 Aug 15
1
Read variable column width data
Reading data with variable column widths. Here are several lines of a txt data set I would like to read. The number of variables is fixed at 13 . The problem is how to read the first variable when it can contain blank space-- for example " Alabama (Seasonally Adjusted)" , "St. Clair", etc. Alabama (Seasonally Adjusted) 2,168,870 2,162,604 2,122,787 1,954,895 1,956,026 1,925,007 213,975 206,578 197,780 9.9% 9.6% 9.3% Alabama (Not Seasonally Adjusted) 2,185,690 2,155,322 2,135,467 1,955,512 1,951,696 1,930,257 230,178 203,626 2...
2008 Feb 12
2
how to specify modes of certain fields in read.table
...decimal number as. 641673.8 3607081 641436.6 3607108 641165.3 3607137 640879.6 3607116 640683.5 3607105 My question is how to specify these two columns in read.table. Maybe colClasses helps but I have 50 columns... Thanks Weidong Gu, Department of Medicine University of Alabama, Birmingham 1900 University Blvd., Birmingham, Alabama 35294 Email: wgu@uab.edu PH: (205)-975-9053 [[alternative HTML version deleted]]
2010 Sep 21
2
Trouble with Optimization in "Alabama" Package
...arameters based on the initial par argument fed to it, I had to include an additional argument to the functions so I could bring the parameters of the utility functions and the initial production into the optimization. I've written the following code but I keep getting strange errors: library(alabama) # y is a vector of initial allocations and CobbDouglas preference parameters #y=c(r1,r2,b1,b2,alpha1,alpha2) y=c(5,50,60,5,.3,.7) # p1=c(r1bar,r1bar,b1bar,b1bar) a feasible allocation p1=c(15,40,50,15) fn=function(x,...){ return(-1*(((x[1]^y[5])*(x[3]^(1-y[5])))*(((x[2]^y[6])*(x[4]^(1-y[...
2008 Feb 11
2
how to generate a column based on other columns in a data frame
...ortunately, there is no 'site' entry. I would like to add a column of 'site' based on the coordinates of samples so that samples from the same sites have the same site ID like S1, S2,.... How to do this in R way? Thanks. Weidong Gu, Department of Medicine University of Alabama, Birmingham 1900 University Blvd., Birmingham, Alabama 35294 Email: wgu@uab.edu PH: (205)-975-9053 [[alternative HTML version deleted]]
2007 Aug 11
0
Rubyists in Lower Alabama?
I''ve been at the Ruby Hoedown in Raleigh, and have had a fantastic two days. I finally decided to get off my butt and really try to organize a LowerAlabama.rb ... Soooooo...... http://groups.google.com/group/loweralrb If you''re in Baldwin or Mobile counties in AL, or Pensacola FL, or Eastern MS...go sign up! I''m sure I''m not the only one down here. My plan is still to meet at the Barnes and Noble in Spanish Fort, unless...
2010 Mar 26
7
seed data
...a", :abbr => ''AB'',:fips => ''01'', :country_id => 2 }, { :name => "Alaska", :abbr => ''AK'',:fips => ''02'', :country_id => 1 } ]) State.destroy_all State.create(:id => 1,:name => "Alabama", :abbr => ''AL'',:fips => ''01'', :country_id => 1) And now when I do select * from states; I get unexpected result as +-----+------+-----------------------+------+------------+ | id | abbr | name | fips | country_id | +-----+-...
2005 Oct 15
2
how to import such data to R?
the data file has such structure: 1992 6245 49 . . 20 1 0 0 8.739536 0 . . . . . . . . "alabama" . 0 . 1993 7677 58 . . 15 1 0 0 8.945984 1 . 0 .2064476 -5 0 . 0 8.739536 "alabama" 9 0...
2010 Nov 25
1
RODBC
...uot;USArrests", rownames = "state") # get the lot foo <- cbind(state=row.names(USArrests), USArrests)[1:3, c(1,3)] foo[1:3,2] <- 9999 sqlUpdate(accesChannel , foo, "USArrests") The sqlSave and sqlFetch command seem to work fine. > foo state Assault Alabama Alabama 9999 Alaska Alaska 9999 Arizona Arizona 9999 > sqlUpdate(accesChannel , foo, "USArrests") Error in sqlUpdate(accesChannel, foo, "USArrests") : cannot update 'USArrests' without unique column > I am using R 2.12.0(2010-10-15) Using Micro...
2012 Mar 12
3
lapply to change variable names and variable values
Hi: I'm sure this is a very easy problem. I've consulted Data Manipulation With R and the R Book and can't find an answer. Sample list of data frames looks as follows: .xx<-list(df<-data.frame(Var1=rep('Alabama', 400), Var2=rep(c(2004, 2005, 2006, 2007), 400)), df2<-data.frame(Var1=rep('Tennessee', 400), Var2=rep(c(2004,2005,2006,2007), 400)), df3<-data.frame(Var1=rep('Alaska', 400), Var2=rep(c(2004,2005,2006,2007), 400)) ) I would like to accomplish the following two tasks. Fi...
2011 Oct 13
3
US States percentage change plot
...i, I would like to make a plot of the US states (or lower 48) that are colored based upon a percentage change column. Ideally, it would gradually be more blue the larger the positive change, and more red the more negative is the change. The data I have looks like: State Percent.Change 1 Alabama 0.004040547 2 Alaska -0.000202211 3 Arizona -0.002524567 4 Arkansas -0.008525333 5 California 0.001828754 6 Colorado 0.011116150 I have read help for the maps library and similar plots online but can't grasp how to map the percentage.change column to the map. thank in...
2008 Sep 07
1
run optim() on a list
...hen I run lapply(sp,function(x) optim (0.1,like,control=list(fnscale=-1))) #But it gives an estimation based on the full data, not separately on sp[[1]], sp[[2]],... I tried do.call without success. So, your help would be appreciated. Weidong Gu Department of Medicine University of Alabama, Birmingham 1900 University Blvd., Birmingham, Alabama 35294 Email: wgu@uab.edu PH: (205)-975-9053 Site Pool Positivity UBA_1 22 0 UBA_1 50 0 UBA_1 23 0 UBA_1 25 0 UBA_1 35 0 UBA_1 24 0 UBA_1 26 0 Cham_res 43 0 Cham_res 45 0 Cham_res 34 0 Cham_res 24 0...
2008 Feb 08
4
how to extract characters from a character string
...tween sites, I need to reformat the coordinates from, for example, 32?35.421 N, to 35.421, i.e. I need to delete all digits before symbol ? and a space and N at the end of the string. What functions I should use? Thanks in advance. Weidong Gu, Department of Medicine University of Alabama, Birmingham [[alternative HTML version deleted]]
2011 May 18
1
Constrainted Nonlinear Optimization - lack of convergence
Hello, I am attempting to utilize the 'alabama' package to solve a constrained nonlinear optimization problem. The problem has both equality and inequality constraints (heq and hin functions are used). All constraints are smooth, i.e. I can differentiate easily to produce heq.jac and hin.jac functions. My initial solution is feasible; I...
2003 Dec 17
2
Easiest way to get the mean of a row of a data.frame?
Dear r-helpers! I am kind of new to R. I would like to calculate the mean of the numbers of this expression: data(USArrests) USArrests[row.names(M) == "Alabama",] class() tells me it's a ``data.frame,'' what I actually desire is to get all numbers of a row as a vector or a list to let mean() calculate the mean of the whole row. (I know this doesn't make sense with USArrests, I just used it here instead of my very own data.frame.) T...