paste(letters[1:5], as.character(1:5))
[1] "a 1" "b 2" "c 3" "d 4" "e 5"
> paste(letters[1:5], as.character(1:3))
[1] "a 1" "b 2" "c 3" "d 1" "e 2"
> expand.grid(pants = c("blue", "black"), shirt = c("white", "grey", "plaid")) # 모든 조합 생성?
  pants shirt
1  blue white
2 black white
3  blue  grey
4 black  grey
5  blue plaid
6 black plaid



> install.packages("gtools")
> library(gtools)
> permutations(5,2)
      [,1] [,2]
 [1,]    1    2
 [2,]    1    3
 [3,]    1    4
 [4,]    1    5
 [5,]    2    1
 [6,]    2    3
 [7,]    2    4
 [8,]    2    5
 [9,]    3    1
[10,]    3    2
[11,]    3    4
[12,]    3    5
[13,]    4    1
[14,]    4    2
[15,]    4    3
[16,]    4    5
[17,]    5    1
[18,]    5    2
[19,]    5    3
[20,]    5    4
> combinations(5,2)
      [,1] [,2]
 [1,]    1    2
 [2,]    1    3
 [3,]    1    4
 [4,]    1    5
 [5,]    2    3
 [6,]    2    4
 [7,]    2    5
 [8,]    3    4
 [9,]    3    5
[10,]    4    5

> all_phone_numbers <- permutations(10, 7, v = 0:9)
> n <- nrow(all_phone_numbers)
> n
[1] 604800
> index <- sample(n, 5)
> index
[1] 124574 106782 415511 232305 465598
> all_phone_numbers[index,]
     [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]    2    0    6    4    1    8    5
[2,]    1    7    9    0    8    2    4
[3,]    6    8    7    4    3    2    5
[4,]    3    8    5    4    9    1    0
[5,]    7    6    2    1    9    8    3

> suits <- c("d", "c", "h", "s")
> numbers <- c("a", "j", "q", "k", as.character(1:10))
> deck <- expand.grid(number=numbers, suit=suits)
> deck<-paste(deck$number, deck$suit)
> deck
 [1] "a d"  "j d"  "q d"  "k d"  "1 d"  "2 d" 
 [7] "3 d"  "4 d"  "5 d"  "6 d"  "7 d"  "8 d" 
[13] "9 d"  "10 d" "a c"  "j c"  "q c"  "k c" 
[19] "1 c"  "2 c"  "3 c"  "4 c"  "5 c"  "6 c" 
[25] "7 c"  "8 c"  "9 c"  "10 c" "a h"  "j h" 
[31] "q h"  "k h"  "1 h"  "2 h"  "3 h"  "4 h" 
[37] "5 h"  "6 h"  "7 h"  "8 h"  "9 h"  "10 h"
[43] "a s"  "j s"  "q s"  "k s"  "1 s"  "2 s" 
[49] "3 s"  "4 s"  "5 s"  "6 s"  "7 s"  "8 s" 
[55] "9 s"  "10 s"
> kings<-paste("k", suits)
> kings
[1] "k d" "k c" "k h" "k s"
> mean(deck %in% kings)
[1] 0.07142857

> hands <- permutations(52, 2, v=deck) #deck 중에서 2개씩 뽑기
> nrows(hands)
[1] 2652
> first_card <- hands[,1] #first column
> second_card <- hands[,2]
> sum(first_card %in% kings)
[1] 204
> sum(first_card %in% kings & second_card%in% kings)/sum(first_card %in% kings)
[1] 0.05882353

> combinations(3,2)
     [,1] [,2]
[1,]    1    2
[2,]    1    3
[3,]    2    3





'programing > R studio' 카테고리의 다른 글

[Rstudio] rep, replicate, sample, table, prop.table  (0) 2021.06.28
R 패키지 설치 에러  (3) 2019.06.09
R 단축키  (0) 2019.03.23
시계열 ts()  (0) 2019.01.30
approx VS approxfun  (0) 2019.01.30

> beads<-rep(c("red","blue"), 3)
> beads
[1] "red"  "blue" "red"  "blue" "red"  "blue"


> beads<-rep(c("red","blue"), times=c(2,3))
> beads
[1] "red"  "red"  "blue" "blue" "blue"

> sample(beads, 1)
[1] "blue"

> A<-10000
> events<-replicate(A, sample(beads, 1))
> table(events)
events
blue  red 
5967 4033 
> prop.table(table(events))
events
  blue    red 
0.5967 0.4033 

> events<-replicate(100000, sample(beads, 1))
> prop.table(table(events))
events
   blue     red 
0.59903 0.40097 

> events<-replicate(100, sample(beads, 1))
> prop.table(table(events))
events
blue  red 
0.55 0.45 

> events<-sample(beads, A, replace = TRUE)
> prop.table(table(events))
events
  blue    red 
0.5999 0.4001 

'programing > R studio' 카테고리의 다른 글

[Rstudio]  (0) 2021.06.28
R 패키지 설치 에러  (3) 2019.06.09
R 단축키  (0) 2019.03.23
시계열 ts()  (0) 2019.01.30
approx VS approxfun  (0) 2019.01.30

파이썬 설치 파일 클릭 - modify 클릭 - Add Python to environment variables 클릭 -> 자동으로 path 설정됨!

'programing' 카테고리의 다른 글

데이터 분석 준전문가 ADsP 시험 신청하는 곳  (0) 2018.06.18
csv 한글 깨짐 현상  (0) 2018.05.09
[통계] 귀무가설, 대립가설, p-value  (0) 2018.05.03
DOM node/hover  (0) 2018.04.04
WAS (Web Application Server)  (0) 2018.04.04

https://stackoverflow.com/questions/40060353/not-able-to-install-packages-in-pycharm

 

Not able to install packages in Pycharm

I have pycharm community edition(latest stable build) installed on my Ubuntu 16.04 LTS, I am not able to install packages via pycharm, was able to install them before. I can install the packages v...

stackoverflow.com

 

 

17

I have got a solution, i reffered to https://youtrack.jetbrains.com/issue/PY-20081#u=1468410176856.

Here they have tried to add https://pypi.python.org/pypi as a repository.

To add it as a repository,

1.) Go to Settings 2.) Project interpreter 3.) Click the + sign on top right edge 4.) Go to manage repositories, 5.) Press the + Sign, then add https://pypi.python.org/pypi 6.) Press Ok

Now all the packages should load.

Thanks Hami Torun & Simon, I was able to solve it by luck.

 

 

repository에 저 링크 입력해주면 됨!

 

pip버전 문제인줄 알았는데.. 

근데 저 링크는 뭐지

'programing > Python' 카테고리의 다른 글

윈도우 pandas 설치법  (0) 2018.06.18
Python 기초 - type()  (0) 2018.04.09
Python 기초 - input()  (0) 2018.04.09
Python 기초 - print()  (0) 2018.04.09
Python 기초 - 리스트  (0) 2018.04.09

cannot create dir 'C:/어쩌구/저쩌구' , reason 'Invalid argument'

 

R studio를 관리자권한으로 다시 열면 됩니다.

'programing > R studio' 카테고리의 다른 글

[Rstudio]  (0) 2021.06.28
[Rstudio] rep, replicate, sample, table, prop.table  (0) 2021.06.28
R 단축키  (0) 2019.03.23
시계열 ts()  (0) 2019.01.30
approx VS approxfun  (0) 2019.01.30

%>% : Ctrl+Shift+M

#(주석) : Ctrl+Shift+C


'programing > R studio' 카테고리의 다른 글

[Rstudio] rep, replicate, sample, table, prop.table  (0) 2021.06.28
R 패키지 설치 에러  (3) 2019.06.09
시계열 ts()  (0) 2019.01.30
approx VS approxfun  (0) 2019.01.30
특정 행 or 열 이름만 바꾸기  (0) 2018.12.03

시계열 ts()

R로 시계열 분석 시, frequency를 나눌 때는 데이터가 frequency대로 정확하게 떨어지게 나눠야 함

ex)

ts(data, start=c(2012,3), frequency = 12) 

2012년 1월~2018년 2월 자료까지 밖에 없는 경우

2012년 3월을 start 점으로 해줘야 함

'programing > R studio' 카테고리의 다른 글

R 패키지 설치 에러  (3) 2019.06.09
R 단축키  (0) 2019.03.23
approx VS approxfun  (0) 2019.01.30
특정 행 or 열 이름만 바꾸기  (0) 2018.12.03
duplicated(), unique(), distinct()  (0) 2018.09.17

approx VS approxfun


1. approx

- 지정된 점 혹은 지전된 수의 근사함수의 값을 리턴한다

- 알고 있는 지점에서 근사값(approximation)이 필요한 경우에 사용


2. approxfun

- 특정 시점에서 평가할 수 있는 함수를 반환한다

- 추후에 주어진 인수에 대해 근사값을 반환하는 함수가 필요한 경우에 사용



'programing > R studio' 카테고리의 다른 글

R 단축키  (0) 2019.03.23
시계열 ts()  (0) 2019.01.30
특정 행 or 열 이름만 바꾸기  (0) 2018.12.03
duplicated(), unique(), distinct()  (0) 2018.09.17
merge 함수의 all.x = TRUE  (0) 2018.09.10

특정 행 or 열 이름만 바꾸기


# temp데이터의 1열 이름을 date로 바꾸기

colnames(temp)[1]<-"date"


# temp데이터의 2행 이름을 seoul로 바꾸기

rownames(temp)[2]<-"seoul"

'programing > R studio' 카테고리의 다른 글

시계열 ts()  (0) 2019.01.30
approx VS approxfun  (0) 2019.01.30
duplicated(), unique(), distinct()  (0) 2018.09.17
merge 함수의 all.x = TRUE  (0) 2018.09.10
R - 기본함수 - paste / paste0  (0) 2018.08.22

> x <- c(1, 1, 4, 5, 4, 6)

 

> duplicated(x)

[1] FALSE  TRUE FALSE FALSE  TRUE FALSE

 

 

> x[duplicated(x)] # 중복된 애들 하나씩만 나열; 1,4=중복됨

[1] 1 4

 

> x[duplicated(x) | duplicated(x, fromLast = T)]

# 모든 중복된 애들; 1, 1, 4, 4

[1] 1 1 4 4

 

 

> # 중복된 애들 제거하고 나열

> x[! duplicated(x)]

[1] 1 4 5 6

> unique(x)

[1] 1 4 5 6

 

 

> # Remove duplicated rows based on col1 and col2

> library(dplyr)

> distinct(data, col1, col2)


+ Recent posts