2012-02-19 3 views
-4

100x100 데이터 세트가 있다고 가정합니다. 우리는 모든 수의 로그를 취하여이를 변환하려고합니다. R에서는 어떻게 할 수 있습니까?기존 데이터 세트 수정

+10

'로그 (data_set)'여기에서 시작 – mbq

+3

: http://cran.r-project.org/ doc/manuals/R-intro.pdf –

답변

11

먼저 예제 데이터를 만들어 보겠습니다. 나는 100 x 100 매트릭스에 양의 난수로 채웠다.

## Save the fake data into the object called "Data" 
> Data <- matrix(abs(rnorm(10000)),100,100) 

## We can confirm the dimensions of the matrix like so 
> dim(Data) 
[1] 100 100 

## We can confirm that it is a matrix like so 
> class(Data) 
[1] "matrix" 

## We can take a peak at rows 1 to 5 and columns 1 to 2 like so 
> Data[1:5,1:2] 
      [,1]  [,2] 
[1,] 1.5814281 0.216556739 
[2,] 0.8939682 0.007296336 
[3,] 1.7937537 0.955205600 
[4,] 0.4994752 1.982777723 
[5,] 1.3459607 1.328990348 

이제이 숫자의 로그를 가져 와서 새 개체로 저장해 봅시다.

## First we can take the natural log and save it in the object "Natural" 
Natural <- log(Data) 

## Or we can take the log base 10 and save it in the object "Base10" 
Base10 <- log10(Data) 

## To see all of the objects in your working memory, we can type the following 
ls() 

희망이 있습니다. 당신이 더 많은 도움이 필요하면 R 기본 사항이 웹 사이트를 시도으로 :

  1. http://www.r-tutor.com/
  2. http://twitter.com/#!/RLangTip
+1

훌륭하고, 완전하며 정중 한 대답입니다. 잘 했어. –

+1

하단에있는 두 개의 링크는 매우 가치가 있습니다. – Iterator