두 개의 data.frames
을 각각 series_id
이라는 공통된 열 이름을 기반으로 병합하려고합니다. 내가지고있어 오류가 as.vector에서조회 테이블을 참조하여 두 개의 data.frames를 R로 병합하는 방법
오류 (y를)
merge(test_growth_series_LUT, test_growth_series, by = intersect(series_id, series_id))
입니다
: 오브젝트 도움말이 제공
를 찾을 수 없습니다 'series_id'여기 내 병합 성명 이 설명,하지만 난 왜 series_id
을 찾을 수없는 볼 수 없습니다. 예제 데이터는 아래와 같습니다.
### S3 method for class 'data.frame':
#merge(x, y, by = intersect(names(x), names(y)),
# by.x = by, by.y = by, all = FALSE, all.x = all, all.y = all,
# sort = TRUE, suffixes = c(".x",".y"), ...)
# Create a long data.frame to store data...
test_growth_series = data.frame ("read_day" = c(0, 3, 9, 0, 3, 9, 0, 2, 8),
"series_id" = c("p1s1", "p1s1", "p1s1", "p1s2", "p1s2", "p1s2", "p3s4", "p3s4", "p3s4"),
"mean_od" = c(0.6, 0.9, 1.3, 0.3, 0.6, 1.0, 0.2, 0.5, 1.2),
"sd_od" = c(0.1, 0.2, 0.2, 0.1, 0.1, 0.3, 0.04, 0.1, 0.3),
"n_in_stat" = c(8, 8, 8, 8, 7, 5, 8, 7, 2)
)
# Create a name LUT
test_growth_series_LUT = data.frame ("series_id" = c("p1s1", "p1s2", "p3s4", "p4s2", "p5s2", "p6s2", "p7s4", "p8s4", "p9s4"),"description" = c("blah1", "blah2", "blah3", "blah4", "blah5", "blah6", "blah7", "blah8", "blah9")
)
> test_growth_series
read_day series_id mean_od sd_od n_in_stat
1 0 p1s1 0.6 0.10 8
2 3 p1s1 0.9 0.20 8
3 9 p1s1 1.3 0.20 8
4 0 p1s2 0.3 0.10 8
5 3 p1s2 0.6 0.10 7
6 9 p1s2 1.0 0.30 5
7 0 p3s4 0.2 0.04 8
8 2 p3s4 0.5 0.10 7
9 8 p3s4 1.2 0.30 2
> test_growth_series_LUT
series_id description
1 p1s1 blah1
2 p1s2 blah2
3 p3s4 blah3
4 p4s2 blah4
5 p5s2 blah5
6 p6s2 blah6
7 p7s4 blah7
8 p8s4 blah8
9 p9s4 blah9
>
this is what I'm trying to achieve:
> new_test_growth_series
read_day series_id mean_od sd_od n_in_stat description
1 0 p1s1 0.6 0.10 8 blah1
2 3 p1s1 0.9 0.20 8 blah1
3 9 p1s1 1.3 0.20 8 blah1
4 0 p1s2 0.3 0.10 8 blah2
5 3 p1s2 0.6 0.10 7 blah2
6 9 p1s2 1.0 0.30 5 blah2
7 0 p3s4 0.2 0.04 8 blah3
8 2 p3s4 0.5 0.10 7 blah3
9 8 p3s4 1.2 0.30 2 blah3
에서 논의 난 당신이 그냥 ... 너무 문자 그대로 그것을 읽는했다 생각 "= 의해 교차 (이름 (X), 이름 (Y))"란, "당신이 (예를 들어 = "id"로) 결합 할 이름을 지정할 수 있지만 기본값은 x 이름과 y 이름의 교차입니다. " –