similar to: Placing brackets around the values in a data frame

Displaying 20 results from an estimated 10000 matches similar to: "Placing brackets around the values in a data frame"

2011 Dec 15
1
Reordering a numeric variable
I'm running a linear model in R using the car package. I have a variable education, which i have recoded and regrouped to my wishes. However, R seems to place each element of that variable in alphabetical order. When I am running the model, don't I need the model order from lowest to highest to make an inference that a one unit change in one variable produced a one unit change in
2011 Jun 10
2
Counting the Number of Letters in a row
I'm trying to find the total number of letters in a row of a data frame. Let's say I have the following data frame. f1 <- data.frame(keyword=c("I live in Denver", I live in Kansas City, MO", "Pizza is good")) The following function gives me the number of characters in each string. So for "I live in Denver", I get 1, 4, 2, and 6. However, I want to
2011 Aug 29
1
Difference between a data frame and data table
I didn't learn about data tables until recently. (They're never covered in any intro R books). In any case, I'm not sure what (if any) is the difference between a data frame and a data table. Can anyone provide a brief explanation? Is one preferred over another or is it just dependent on the task at hand? Thanks, Abraham M. [[alternative HTML version deleted]]
2012 Aug 13
3
Using the effects package to plot logit probabilities
I'm trying to run a logit model and plot the probability curve for a number of the important predictors. I'm trying to do this with the Effects package. df=data.frame(income=c(5,5,3,3,6,5), won=c(0,0,1,1,1,0), age=c(18,18,23,50,19,39), home=c(0,0,1,0,0,1)) str(df) md1 = glm(factor(won) ~ income + age + home, data=df,
2011 Jun 14
1
Invalid Regular Expression
I'm working with some data, and am trying to generate it in the following format. state city zipcode I like pizza 0 0 0 I live in Denver 0 1 0 All the fun stuff is in Alaska 1 0 0 he lives in 66062
2012 Jul 19
3
Removing values from a string
So I have the following data frame and I want to know how I can remove all "NA" values from each string, and also remove all "|" values from the START of the string. So they should something like "auto|insurance" or "auto|insurance|quote" one = data.frame(keyword=c("|auto", "NA|auto|insurance|quote", "NA|auto|insurance",
2011 Jul 19
1
Stacked Bar Plot in ggplot2
I'm trying to develop a stacked bar plot in R with ggplot2. My data: conv = c(10, 4.76, 17.14, 25, 26.47, 37.5, 20.83, 25.53, 32.5, 16.7, 27.33) click = c(20, 42, 35, 28, 34, 48, 48, 47, 40, 30, 30) date = c("July 7", "July 8", "July 9", "July 10", "July 11", "July 12", "July 13", "July 14", "July 15",
2011 Jun 07
1
Adding values to the end of a data frame
Let's say that I'm trying to write a functions that will allow me to automate a process where I examine all possible combinations of various string groupings. Each time I run the one function, I want to include the new values to the end of a data frame. The data frame will basically be one column with a lot of rows. roots <- c("car insurance", "auto insurance")
2012 Jul 05
2
Plotting the probability curve from a logit model with 10 predictors
I have a logit model with about 10 predictors and I am trying to plot the probability curve for the model. Y=1 = 1 / 1+e^-z where z=B0 + B1X1 + ... + BnXi If the model had only one predictor, I know to do something like below. mod1 = glm(factor(won) ~ as.numeric(bid), data=mydat, family=binomial(link="logit")) all.x <- expand.grid(won=unique(won), bid=unique(bid)) y.hat.new
2011 Jun 06
1
Merge two columns of a data frame
I have the following data: prefix <- c("cheap", "budget") roots <- c("car insurance", "auto insurance") suffix <- c("quote", "quotes") prefix2 <- c("cheap", "budget") roots2 <- c("car insurance", "auto insurance") roots3 <- c("car insurance", "auto
2009 Mar 15
3
read.xls question
I'm an R newbie and had a question about the read.xls function. I've heard that this is often not a reliable function to use for importing data. However, I have created numerous xls files which contain information about voter turnout and macroeconomic indicators in India. I'm writing a paper on the relationship between economic growth and voter turnout. This is the command I use:
2011 Dec 22
1
Error message with glm
I'm working on a logistic regression in R with the car package but keep getting the following error message. It's only and warning and not an error, but I'm just not sure how to resolve the issues. glm.fit: algorithm did not converge glm.fit: fitted probabilities numerically 0 or 1 occurred d1 = data.frame(mwin=c(mwin), mbid=c(mbid)) m1 = zelig(mwin ~ mbid, data=d1,
2011 Apr 25
2
Problem installing XML in Ubuntu 10.10
Hello folks, Here's is info on what system I'm working on. > sessionInfo() R version 2.13.0 (2011-04-13) Platform: i686-pc-linux-gnu (32-bit) I'm trying to install the XML package. However, I end up with the following error message. > install.packages("XML") .... checking for xml2-config... no Cannot find xml2-config ERROR: configuration failed for package ‘XML’ *
2012 Aug 02
1
Naive Bayes in R
I'm developing a naive bayes in R. I have the following data and am trying to predict on returned (class). dat = data.frame(home=c(0,1,1,0,0), gender=c("M","M","F","M","F"), returned=c(0,0,1,1,0)) str(dat) dat$home <- as.factor(dat$home) dat$returned <- as.factor(dat$returned) library(e1071) m <- naiveBayes(returned ~ ., dat) m
2012 Aug 07
2
Re-grouping data in R
I have a data frame with a column of values that I want to bucket (group) into specific levels. > str(dat)'data.frame': 3678 obs. of 39 variables: $ id : int 23 76 129 156 166 180 200 214 296 344 ... $ final_purchase_amount : Factor w/ 32 levels "\\N","1082","1109",..: 1 1 1 1 1 1 1 1 1 1 ... So I ran the following to
2011 Apr 28
2
Subsetting Data
I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the Number>=10 condition. I've done this in the past with something like colSums or rowSums or another similar function. But I don't remember how to get the number of elements which meet that
2010 Jan 28
1
Recoding Variables in R
VAR 980490 Some people have suggested placing new limits on foreign imports in order to protect American jobs. Others say that such limits would raise consumer prices and hurt American exports. Do you FAVOR or OPPOSE placing new limits on imports, or haven't you thought much about this? 1. Favor 5. Oppose 8. DK 9. NA; RF 0. Haven't thought much about this I am trying to
2011 Nov 17
1
Error When Installing the RODBC Package
I'm running R in Ubuntu 10.10 and am trying to install the RODBC package. However, I get the following error message: ERROR: configuration failed for package ‘RODBC’ * removing ‘/home/amathew/R/i686-pc-linux-gnu-library/2.13/RODBC’ The downloaded packages are in ‘/tmp/RtmpekzPOQ/downloaded_packages’ Warning message: In install.packages() : installation of package 'RODBC' had
2011 Dec 21
1
Predicting a linear model for all combinations
Lets say I have a linear model and I want to find the average expented value of the dependent variable. So let's assume that I'm studying the price I pay for coffee. Price = B0 + B1(weather) + B2(gender) + ... What I'm trying to find is the predicted price for every possible combination of values in the independent variables. So Expected price when: weather=1, gender=male weather=1,
2012 Feb 09
1
Grouping together a time variable
I have the following variable, time, which is a character variable and it's structured as follows. > head(as.character(dat$time), 30) [1] "00:00:01" "00:00:16" "00:00:24" "00:00:25" "00:00:25" "00:00:40" "00:01:50" "00:01:54" "00:02:33" "00:02:43" "00:03:22" [12]