Displaying 8 results from an estimated 8 matches for "aa_2000".
2017 Dec 04
3
Dynamic reference, right-hand side of function
...nd a fairly advanced Stata-user, I guess part of my problem is that my mindset (and probably my language as well) is wrong. Anyway, I have what I guess is a rather simple problem, that I now without success spent days trying to solve.
I have a bunch of datasets imported from Stata that is labelled aa_2000 aa_2001 aa_2002, etc. Each dataset is imported as a matrix, and consists of one column only. The columns consists of integer numbers. I need to convert the data to vectors, which I found several ways to do. I use, for example:
aa_2000 <- as.numeric(aa_2000[,1])
However, when trying to automate t...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...r them. E.g.
datanames <- paste0("aa_", 2000:2007)
datalist <- lapply(datanames, get)
names(datalist) <- datanames
col1 <- lapply(datalist, "[[", 1)
colnum <- lapply(col1, as.numeric)
(The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.)
-pd
> On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociology.su.se> wrote:
>
> Hi R-users!
> Being new to R, and a fairly advanced Stata-user, I guess part of my...
2017 Dec 04
3
Dynamic reference, right-hand side of function
...ver them. E.g.
datanames <- paste0("aa_", 2000:2007)
datalist <- lapply(datanames, get)
names(datalist) <- datanames
col1 <- lapply(datalist, "[[", 1)
colnum <- lapply(col1, as.numeric)
(The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.)
-pd
> On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociology.su.se> wrote:
>
> Hi R-users!
> Being new to R, and a fairly advanced Stata-user, I guess part of my...
2017 Dec 05
3
Dynamic reference, right-hand side of function
...thing we Stata-users do, I just jokingly pointed it out). Anyway, I'm really happy that you try to teach me some R-manners. Since I still get questions about what the h**k I mean by my strange question, I sort it out with an example:
I had a number of matrices, named in a consecutive manner:
aa_2000 <- as.matrix(read.csv(text="1,0,1,1,0,0,0,0,0,0,1,0,0", header=FALSE))
aa_2001 <- as.matrix(read.csv( text="0,0,0,1,0,1,1,0,0,0,0,1,0,0", header=FALSE))
aa_2002 <- as.matrix(read.csv( text="1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0", header=FALSE))
I needed them to be...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...- paste0("aa_", 2000:2007)
> datalist <- lapply(datanames, get)
> names(datalist) <- datanames
> col1 <- lapply(datalist, "[[", 1)
> colnum <- lapply(col1, as.numeric)
>
> (The 2nd line assumes that the damage has already been done so that you have aa_2000 ... aa_2007 in your workspace. You might alternatively create the list directly while importing the data.)
>
> -pd
>
>> On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociology.su.se> wrote:
>>
>> Hi R-users!
>> Being new to R, and a fairly advanced...
2017 Dec 04
2
Dynamic reference, right-hand side of function
...e0("aa_", 2000:2007)
> datalist <- lapply(datanames, get)
> names(datalist) <- datanames
> col1 <- lapply(datalist, "[[", 1)
> colnum <- lapply(col1, as.numeric)
>
> (The 2nd line assumes that the damage has already been done so that
> you have aa_2000 ... aa_2007 in your workspace. You might
> alternatively create the list directly while importing the data.)
>
> -pd
>
>> On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociology.su.se> wrote:
>>
>> Hi R-users!
>> Being new to R, and a fairly adv...
2017 Dec 05
0
Dynamic reference, right-hand side of function
...jokingly pointed it
> out). Anyway, I'm really happy that you try to teach me some R-manners.
> Since I still get questions about what the h**k I mean by my strange
> question, I sort it out with an example:
>
> I had a number of matrices, named in a consecutive manner:
>
> aa_2000 <- as.matrix(read.csv(text="1,0,1,1,0,0,0,0,0,0,1,0,0",
> header=FALSE))
> aa_2001 <- as.matrix(read.csv( text="0,0,0,1,0,1,1,0,0,0,0,1,0,0",
> header=FALSE))
> aa_2002 <- as.matrix(read.csv( text="1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0",
> header=FALS...
2017 Dec 04
0
Dynamic reference, right-hand side of function
...007)
>> datalist <- lapply(datanames, get)
>> names(datalist) <- datanames
>> col1 <- lapply(datalist, "[[", 1)
>> colnum <- lapply(col1, as.numeric)
>>
>> (The 2nd line assumes that the damage has already been done so that
>> you have aa_2000 ... aa_2007 in your workspace. You might
>> alternatively create the list directly while importing the data.)
>>
>> -pd
>>
>>> On 4 Dec 2017, at 12:33 , Love Bohman <love.bohman at sociology.su.se> wrote:
>>>
>>> Hi R-users!
>>> Bein...