How do you refer to the row above in a data frame ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How do you refer to the row above in a data frame ?

ppaarrkk
You have a two-dimensional data frame.

Columns is easy, say

col4 <- col3 - col2

How do you do

row3 <- row2 +1

for example.
Reply | Threaded
Open this post in threaded view
|

Re: How do you refer to the row above in a data frame ?

Henrique Dallazuanna
If I understand:

data[nrow(data)+1,] <- data[nrow(data),] + 1

On 07/02/2008, ppaarrkk <[hidden email]> wrote:

>
> You have a two-dimensional data frame.
>
> Columns is easy, say
>
> col4 <- col3 - col2
>
> How do you do
>
> row3 <- row2 +1
>
> for example.
> --
> View this message in context: http://www.nabble.com/How-do-you-refer-to-the-row-above-in-a-data-frame---tp15336933p15336933.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.