Hi,
If you had really just used:
wbpractice %>%
mutate(gap = total.food.exp-total.nfood.exp) #gen a variable
and then checked by:
names(wbpractice)
then the problem is just with missed assignment, i.e. it should be:
wbpractice <- wbpractice %>%
mutate(gap = total.food.exp-total.nfood.exp) #
Hi
I cannot say anything about mutate but
read.csv results in data frame
you can use then
wbpractice$gap <- with(wbpractice, total.food.exp-total.nfood.exp)
Cheers
Petr
BTW, do not use HTML formating your email is a mess.
> -Original Message-
> From: R-help On Behalf Of Admire Tari
On Tue, Mar 19, 2013 at 4:33 AM, Nicole Ford wrote:
>
> Hello, all.
>
> The following is for my own research.
>
> I have attached the relevant data in pdf from Transparency International. I
> am only interested in the "CPI 2010 scores" column.
>
> I am interested in creating a variable for sever
Hello,
Try the following.
levels <- c("democrat", "republican", "other")
dem <- c(1,1,1,1,0,0,0,0)
rep <- c(1,1,1,0,0,0,0,0)
other <- c(1,0,0,0,0,0,0,0)
party <- factor(rep(levels, c(sum(dem), sum(rep), sum(other
party
Hope this helps,
Rui Barradas
Em 19-02-2013 00:01, Nicole Ford escre
On 02/19/2013 11:01 AM, Nicole Ford wrote:
hello, all.
in my previous research, i have always used existing data. i am trying
something new as an exploratory exercise and have never create my own variable
form scratch.
essentially, i am creating a variable for party affiliation.
here is an
Hi Nicole,
On Mon, Feb 18, 2013 at 7:01 PM, Nicole Ford wrote:
> hello, all.
>
> in my previous research, i have always used existing data. i am trying
> something new as an exploratory exercise and have never create my own
> variable form scratch.
>
> essentially, i am creating a variable for
On Jan 26, 2011, at 2:06 PM, Melanie Zoelck wrote:
Hi,
I am relatively new to R and have a question regarding code. I have
a data set which has data organised by location (site names, which
are factors). I now want to add a new variable Region (this will be
non numerical, as it will be n
Hi:
I had Harold's idea (matrix indexing), but I was curious to see which of
these ran fastest. I simulated
1000 rows and three columns of binary data, along with a fourth column that
sampled the values 1:3
1000 times. Here are the timings:
> f <- as.data.frame(matrix(rbinom(3000, 1, 0.4), nrow =
Try this:
f$E <- diag(as.matrix(f[f$D]))
On Wed, Jun 9, 2010 at 11:03 AM, Malcolm Fairbrother <
m.fairbrot...@bristol.ac.uk> wrote:
> Dear all,
>
> I have a data frame f, with four variables:
>
> f <- data.frame(A=c(0,0,1,1), B=c(0,1,0,1), C=c(1,1,0,1), D=c(3,1,2,3))
> f
> A B C D
> 1 0 0 1 3
How about this:
f <- data.frame(A=c(0,0,1,1), B=c(0,1,0,1), C=c(1,1,0,1), D=c(3,1,2,3))
N <- nrow(f)
mat <- cbind(1:N,f$D)
f$E <- f[mat]
f
A B C D E
1 0 0 1 3 1
2 0 1 1 1 0
3 1 0 0 2 0
4 1 1 1 3 1
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project
Can your data.frame be properly coerced to a matrix like your example?
If so,
apply(f, 1, function(x) x[eval(x)["D"]])
Malcolm Fairbrother wrote:
Dear all,
I have a data frame f, with four variables:
f <- data.frame(A=c(0,0,1,1), B=c(0,1,0,1), C=c(1,1,0,1), D=c(3,1,2,3))
f
A B C D
1 0 0 1
11 matches
Mail list logo