For the 30 women in the study with a history of premature labor, a proportion of 18/30 = 0.60 (60%) had babies with low birth weight. For the remaining 159 women, a proportion of 41/159 = 0.26 (26%) had babies with low birth weight.
In the instructions below, x1 and x2 represent the number of successes in the two samples, and n1 and n2 are the respective sample sizes.
So you need to substitute 18 for x1, 41 for x2, 30 for n1, and 159 for n2 and then run the code:
Note: Using R -- The test conducted by R for the two proportions test is equivalent to our test, but uses a probability distribution known as chi-square = X2. For a two-proportions test, the chi-square test is equivalent to the Z-test covered here, and the chi-square test statistic is the square of the Z-statistic. The P-value is the same for either test.