l.nfood.exp)
>
> Cheers
> Petr
>
> BTW, do not use HTML formating your email is a mess.
>
>
> > -Original Message-
> > From: R-help On Behalf Of Admire Tarisirayi
> > Chirume
> > Sent: Monday, October 18, 2021 1:26 PM
> > To: Jim Lemon
Of Admire Tarisirayi
> Chirume
> Sent: Monday, October 18, 2021 1:26 PM
> To: Jim Lemon
> Cc: r-help mailing list
> Subject: [R] creating a new variable and merging it on the dataframe
>
> Good day colleagues. Below is a csv file attached which i am using in my
> analysis
Good day colleagues. Below is a csv file attached which i am using in my
analysis.
hh.id
hd17.perm
hd17employ
health.exp
total.food.exp
total.nfood.exp
1
2
yes
1654
23654
23655
2
2
yes
2564
265897
65984
3
6
no
2547
123311
52416
4
8
no
5698
13648
12544
5
6
no
1254
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, 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 several of these countries. The
idea is, they will become a country lev
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 several of these countries. The
idea is, they will become a country le
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
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 example.
var =party.
levels= democrat, repu
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 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
names). Each region will contain locations. So for example:
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
lp-boun...@r-project.org] On
Behalf Of Malcolm Fairbrother
Sent: Wednesday, June 09, 2010 10:03 AM
To: r-help@r-project.org
Subject: [R] creating a new variable, conditional on the value of an existing
variable, selected conditionally
Dear all,
I have a data frame f, with four variables:
f <-
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
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
2 0 1 1 1
3 1 0 0 2
4 1 1 1 3
I want to create a new variable (f$E), such that each of its elements is drawn
from either f$A, f$B, or f$C, accordin
17 matches
Mail list logo