Hi,
Is there a way to easily convert the list of course terms into sequential
integers in the dataframe (see code below)?
eg. "199801" = 1; "199808"=2
I know I can use recode but shouldn't "which" work?
Thanks in advance!
sc = data.frame(c("200208", "200701", "201201"))
names(sc) = c("TERM")
I'm confused:
Thanks in advance.
> which(LETTERS == c("A"))
[1] 1
> which(LETTERS == c("A","B"))
[1] 1 2
> which(LETTERS == c("A","B","C"))
[1] 1 2 3
Warning message:
In LETTERS == c("A", "B", "
.
>>
>> __**
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posti
risons. With the
>vector with length equal to the number of observations on the left hand
>side.
>
>Hope this helps,
>
>Rui Barradas
>
>Em 13-07-2012 12:12, Charles Stangor escreveu:
>> Why does the subset not work in the which() version below?
>>
>>
Why does the subset not work in the which() version below?
Thank you
v1 <- subset(t1,
version_1==as.character("100-1")
| version_1==as.character("100-2"))
a<-c("100-1", "100-2")
v1 <- subset(t1, which(a==as.character(version_1)) != 0)
[[alternative HTML version deleted]]
___
thanks!
On Fri, Jul 13, 2012 at 4:35 AM, Jessica Streicher wrote:
> two things:
>
> - R always counts from 1, not from 0
> - listmembers are accessed by using [[ ]] , not [ ]
>
> try
>
> t1[t==ll[[1]], "v"] <- 99
>
> greetings Jessi
>
>
> On
Say I want to perform transformations on row subsets of my dataframe.
Do I have to break the dataframe into subsets, perform the analysis on each
subset, and rbind() them together again?
..or is there another way.
Thank you!
[[alternative HTML version deleted]]
Why does this sapply code change df3 but not df1?
Thanks
df1 <- read.table(text="
cola colb colc cold cole
1NA59 NA 17
2NA6 NA 14 NA
3 3NA 11 15 19
4 48 12 NA 20
", header=TRUE)
df2 <-df1*2
df1
df2
df3 <-sapply(names(df1),function(x) {df
le.com/Help-with-loop-tp4636140.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www
I can't seem to determine how to get the name of a list member to
substitute as a variable name:
ll <- list("a1" = "a","a2" = "b")
t1[t==ll[1], "v"] <- 99
why doesn't this substitute to:
t1[t=="a", "v"
I can't seem to determine how to get the name of a list member to
substitute:
ll <- list("a1" = "a","a2" = "b")
t1[t==ll[0], "v"] <- 99
why doesn't this substitute to:
t1[t=="a", "v"] <- 99
Thank you!
[[alternative HTML version deleted]]
__
I can't seem to determine how to get the name of a list member to
substitute:
ll <- list("a1" = "a","a2" = "b")
t1[t==ll[0], "v"] <- 99
why doesn't this substitute to:
t1[t=="a", "v"] <- 99
12 matches
Mail list logo